-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
56 lines (47 loc) · 1.29 KB
/
account.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
package bc
import (
"context"
"fmt"
"time"
)
const (
AccountStatusNormal = "normal"
AccountStatusBlocked = "blocked"
)
const (
AccountTypeUser = "user"
AccountTypeApp = "app"
)
// Account Account
type Account struct {
UserID string `json:"user_id,omitempty"`
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
Assets []*Asset `json:"assets,omitempty"`
}
// Register Register
func (c *Client) Register(ctx context.Context) (*Account, error) {
var account Account
if err := c.Post(ctx, fmt.Sprintf("/app/accounts/%s/register", c.ClientID), nil, &account); err != nil {
return nil, err
}
return &account, nil
}
// ReadUserAccount ReadUserAccount
func (c *Client) ReadUserAccount(ctx context.Context, userID string) (*Account, error) {
var account Account
if err := c.Get(ctx, fmt.Sprintf("/app/accounts/%s", userID), nil, &account); err != nil {
return nil, err
}
return &account, nil
}
// ReadMe ReadMe
func (c *Client) ReadMe(ctx context.Context) (*Account, error) {
var account Account
if err := c.Get(ctx, fmt.Sprintf("/app/accounts/%s", c.ClientID), nil, &account); err != nil {
return nil, err
}
return &account, nil
}