-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommodities.go
79 lines (66 loc) · 1.38 KB
/
commodities.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
69
70
71
72
73
74
75
76
77
78
79
package goiex
import (
"net/http"
"net/url"
)
// Commodities struct to interface with /data-points endpoints
type Commodities struct {
iex
}
// NewCommodities return new Commodities
func NewCommodities(
token, version string,
base *url.URL,
httpClient *http.Client,
options ...IEXOption,
) *Commodities {
apiurl, err := url.Parse("data-points/")
if err != nil {
panic(err)
}
comm := &Commodities{
iex: iex{
token: token,
version: version,
url: base,
apiurl: apiurl,
client: httpClient,
},
}
for _, option := range options {
err := option(&comm.iex)
if err != nil {
return nil
}
}
return comm
}
// APIURL return APIURL
func (c *Commodities) APIURL() *url.URL {
return c.apiurl
}
// Client return HTTP client
func (c *Commodities) Client() *http.Client {
return c.client
}
// Token return token string
func (c *Commodities) Token() string {
return c.token
}
// URL return URL base
func (c *Commodities) URL() *url.URL {
return c.url
}
// Version return version string
func (c *Commodities) Version() string {
return c.version
}
// Retry return Retry struct that implements Retryer
func (c *Commodities) Retry() *Retry {
return c.iex.Retry
}
// CommoditiesPrices GET /data-points/market/{symbol}
func (c *Commodities) CommoditiesPrices(symbol string) (value interface{}, err error) {
err = getRaw(c, &value, "market/"+symbol, nil)
return
}