-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasset.go
49 lines (44 loc) · 1.5 KB
/
asset.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
package cryptowatch
import "context"
// Asset is something that is traded, like a crypto or fiat currency.
type Asset struct {
ID int `json:"id"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Fiat bool `json:"fiat"`
Route string `json:"route"`
}
// AssetDetail holds information about an asset.
type AssetDetail struct {
ID int `json:"id"`
Symbol string `json:"symbol"`
Name string `json:"name"`
// Fiat is true when the asset is fiat currency (such as usd, and false when it is a cryptocurrency.
Fiat bool `json:"fiat"`
Markets struct {
Base []struct {
ID int `json:"id"`
Exchange string `json:"exchange"`
Pair string `json:"pair"`
Active bool `json:"active"`
Route string `json:"route"`
} `json:"base"`
Quote []struct {
ID int `json:"id"`
Exchange string `json:"exchange"`
Pair string `json:"pair"`
Active bool `json:"active"`
Route string `json:"route"`
} `json:"quote"`
} `json:"markets"`
}
// ListAssets returns all assets.
func (c *Client) ListAssets(ctx context.Context, opts ...Option) ([]Asset, error) {
var as []Asset
return as, c.doRequest(ctx, &as, append([]Option{withURL(host + `/assets`)}, opts...)...)
}
// GetAssetBySymbol returns an asset details.
func (c *Client) GetAssetBySymbol(ctx context.Context, symbol string, opts ...Option) (AssetDetail, error) {
var as AssetDetail
return as, c.doRequest(ctx, &as, append([]Option{withURL(host + `/assets/` + symbol)}, opts...)...)
}