-
Notifications
You must be signed in to change notification settings - Fork 0
/
consolidated_consumption.go
68 lines (62 loc) · 2.02 KB
/
consolidated_consumption.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gorte
import (
"net/http"
"time"
"github.com/dhia-gharsallaoui/gorte/utils"
)
type ConsolidatedPowerConsumptionResp struct {
ConsolidatedPowerConsumption []struct {
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
Values []struct {
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
Value int `json:"value"`
UpdatedDate string `json:"updated_date"`
Status string `json:"status"`
} `json:"values"`
} `json:"consolidated_power_consumption"`
}
func (co *consumption) GetConsolidatedPowerConsumption(opt utils.Period) (*ConsolidatedPowerConsumptionResp, *http.Response, error) {
c := co.client
req, err := c.NewRequest(http.MethodGet, "open_api/consolidated_consumption/v1/consolidated_power_consumption", opt)
if err != nil {
c.logger.Err(err.Error())
return nil, nil, err
}
sig := &ConsolidatedPowerConsumptionResp{}
resp, err := c.Do(req, sig)
if err != nil {
c.logger.Err(err.Error())
return nil, resp, err
}
return sig, resp, err
}
type ConsolidatedEnergyConsumptionResp struct {
ConsolidatedEnergyConsumption []struct {
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
Values []struct {
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
Value int `json:"value"`
UpdatedDate string `json:"updated_date"`
Status string `json:"status"`
} `json:"values"`
} `json:"consolidated_energy_consumption"`
}
func (co *consumption) GetConsolidatedEnergyConsumption(opt utils.Period) (*ConsolidatedEnergyConsumptionResp, *http.Response, error) {
c := co.client
req, err := c.NewRequest(http.MethodGet, "open_api/consolidated_consumption/v1/consolidated_energy_consumption", opt)
if err != nil {
c.logger.Err(err.Error())
return nil, nil, err
}
sig := &ConsolidatedEnergyConsumptionResp{}
resp, err := c.Do(req, sig)
if err != nil {
c.logger.Err(err.Error())
return nil, resp, err
}
return sig, resp, err
}