-
Notifications
You must be signed in to change notification settings - Fork 0
/
electricity_quality.go
51 lines (46 loc) · 1.46 KB
/
electricity_quality.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package gorte
import (
"net/http"
"time"
"github.com/dhia-gharsallaoui/gorte/utils"
)
type QualityDataResp struct {
QualityData []struct {
QualityMeterPointID string `json:"quality_meter_point_id"`
DataList []struct {
DataType string `json:"data_type"`
Phase string `json:"phase"`
Unit string `json:"unit"`
StartDate time.Time `json:"start_date,omitempty"`
EndDate time.Time `json:"end_date,omitempty"`
Data []struct {
Timestamp time.Time `json:"timestamp"`
Value float64 `json:"value"`
} `json:"data"`
ValueType string `json:"value_type,omitempty"`
NominalDataPeriod int `json:"nominal_data_period,omitempty"`
HarmonicNumber interface{} `json:"harmonic_number,omitempty"`
} `json:"data_list"`
} `json:"quality_data"`
}
type GetQualityDataOptions struct {
ID int `url:"quality_meter_point_id"`
StartDate utils.Time `url:"start_date"`
EndDate utils.Time `url:"end_date"`
Type string `url:"data_type"`
}
func (co *consumption) GetQualityData(opt *GetQualityDataOptions) (*QualityDataResp, *http.Response, error) {
c := co.client
req, err := c.NewRequest(http.MethodGet, "private_api/electricity_quality/v1/quality_data", opt)
if err != nil {
c.logger.Err(err.Error())
return nil, nil, err
}
var sig *QualityDataResp
resp, err := c.Do(req, &sig)
if err != nil {
c.logger.Err(err.Error())
return nil, resp, err
}
return sig, resp, err
}