-
Notifications
You must be signed in to change notification settings - Fork 0
/
generation_forecast.go
47 lines (42 loc) · 1.22 KB
/
generation_forecast.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
package gorte
import (
"net/http"
"time"
"github.com/dhia-gharsallaoui/gorte/utils"
)
type ForecastsResp struct {
Forecasts []struct {
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
Type string `json:"type"`
ProductionType string `json:"production_type"`
Values []struct {
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
UpdatedDate time.Time `json:"updated_date"`
Value int `json:"value"`
} `json:"values"`
SubType string `json:"sub_type,omitempty"`
} `json:"forecasts"`
}
type GetForecastsOptions struct {
StartDate utils.Time `url:"start_date"`
EndDate utils.Time `url:"end_date"`
ProdType string `url:"production_type"`
Type string `url:"type"`
}
func (s *generation) GetForecasts(opt *GetForecastsOptions) (*ForecastsResp, *http.Response, error) {
c := s.client
req, err := c.NewRequest(http.MethodGet, "open_api/generation_forecast/v2/forecasts", opt)
if err != nil {
c.logger.Err(err.Error())
return nil, nil, err
}
sig := &ForecastsResp{}
resp, err := c.Do(req, sig)
if err != nil {
c.logger.Err(err.Error())
return nil, resp, err
}
return sig, resp, err
}