-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecowatt.go
35 lines (32 loc) · 832 Bytes
/
ecowatt.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
package gorte
import (
"net/http"
"time"
)
type SignalEcowattResp struct {
Signals []struct {
GenerationFichier time.Time `json:"GenerationFichier"`
Jour time.Time `json:"jour"`
Dvalue int `json:"dvalue"`
Message string `json:"message"`
Values []struct {
Pas int `json:"pas"`
Hvalue int `json:"hvalue"`
} `json:"values"`
} `json:"signals"`
}
func (co *consumption) GetSignalEcowatt() (*SignalEcowattResp, *http.Response, error) {
c := co.client
req, err := c.NewRequest(http.MethodGet, "open_api/ecowatt/v4/signals", nil)
if err != nil {
c.logger.Err(err.Error())
return nil, nil, err
}
var sig *SignalEcowattResp
resp, err := c.Do(req, &sig)
if err != nil {
c.logger.Err(err.Error())
return nil, resp, err
}
return sig, resp, err
}