-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasset.go
47 lines (38 loc) · 1.16 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
package bc
import (
"context"
"fmt"
"time"
)
const (
UserAssetStatusNormal = "normal"
UserAssetStatusLocked = "locked"
)
// Asset Asset
type Asset struct {
AssetID string `json:"asset_id,omitempty"`
Name string `json:"name,omitempty"`
Symbol string `json:"symbol,omitempty"`
IconUrl string `json:"icon_url,omitempty"`
Capitalization string `json:"capitalization,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"upated_at,omitempty"`
Status string `json:"status,omitempty"`
Balance string `json:"balance,omitempty"`
}
func (c *Client) ReadAsset(ctx context.Context, assetID string) (*Asset, error) {
uri := fmt.Sprintf("/app/accounts/%s/assets/%s", c.ClientID, assetID)
var asset Asset
if err := c.Get(ctx, uri, nil, &asset); err != nil {
return nil, err
}
return &asset, nil
}
func (c *Client) ReadAssets(ctx context.Context) ([]*Asset, error) {
uri := fmt.Sprintf("/v1/app/accounts/%s/assets", c.ClientID)
var assets []*Asset
if err := c.Get(ctx, uri, nil, &assets); err != nil {
return nil, err
}
return assets, nil
}