-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheod.go
More file actions
43 lines (37 loc) · 1.19 KB
/
Copy patheod.go
File metadata and controls
43 lines (37 loc) · 1.19 KB
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
package marketstack
import "context"
type EODOptions struct {
Symbols []string `url:"symbols,omitempty,comma"`
Exchange string `url:"exchange,omitempty"`
Sort string `url:"sort,omitempty"`
DateFrom string `url:"date_from,omitempty"`
DateTo string `url:"date_to,omitempty"`
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
}
type EODResponse struct {
Pagination Pagination `json:"pagination"`
Data []EODData `json:"data"`
}
func (c *Client) GetEOD(ctx context.Context, opts *EODOptions) (*EODResponse, error) {
var result EODResponse
if err := c.doRequest(ctx, "/eod", opts, &result); err != nil {
return nil, err
}
return &result, nil
}
func (c *Client) GetEODLatest(ctx context.Context, opts *EODOptions) (*EODResponse, error) {
var result EODResponse
if err := c.doRequest(ctx, "/eod/latest", opts, &result); err != nil {
return nil, err
}
return &result, nil
}
func (c *Client) GetEODByDate(ctx context.Context, date string, opts *EODOptions) (*EODResponse, error) {
var result EODResponse
endpoint := "/eod/" + date
if err := c.doRequest(ctx, endpoint, opts, &result); err != nil {
return nil, err
}
return &result, nil
}