-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
57 lines (44 loc) · 1.22 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
57
package truelayer
import "time"
// Account ...
type Account struct {
ID string `json:"account_id"`
Type string `json:"account_type"`
Currency string `json:"currency"`
DisplayName string `json:"display_name"`
UpdatedAt time.Time `json:"update_timestamp"`
Description string `json:"description"`
Number *Number `json:"account_number"`
Provider *Provider `json:"provider"`
}
// Number ...
type Number struct {
IBAN string `json:"iban"`
Number string `json:"number"`
SortCode string `json:"sort_code"`
SwiftBic string `json:"swift_bic"`
}
// GetAccounts ...
func (client *Client) GetAccounts() ([]*Account, error) {
truelayerURL := client.baseURL + "data/v1/accounts"
var accounts struct {
Results []*Account `json:"results"`
}
err := client.get(truelayerURL, &accounts)
if err != nil {
return nil, err
}
return accounts.Results, nil
}
// GetAccount ...
func (client *Client) GetAccount(accountID string) (*Account, error) {
truelayerURL := client.baseURL + "data/v1/accounts/" + accountID
var account struct {
Results []*Account `json:"results"`
}
err := client.get(truelayerURL, &account)
if err != nil {
return nil, err
}
return account.Results[0], nil
}