-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwallet-balances.go
54 lines (48 loc) · 1004 Bytes
/
wallet-balances.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
package qiwi
import (
"encoding/json"
)
type WalletBalance struct {
Accounts []WalletBalanceAccount
}
/*
{
"alias": "mc_beeline_rub",
"fsAlias": "qb_mc_beeline",
"title": "MC",
"type": {
"id": "MC",
"title": "Счет мобильного кошелька"
},
"hasBalance": false,
"balance": null,
"currency": 643
},
*/
type WalletBalanceAccount struct {
Alias string
FsAlias string
Title string
Type struct {
ID string
Title string
}
HasBalance bool
Balance PaymentAmount
currency Currency
}
/*
GetWalletBalance
*/
func (qiwi *QiwiPersonalApi) GetWalletBalance() (*WalletBalance, error) {
resp, err := qiwi.sendRequest(qiwi.apiKey, "GET", "/funding-sources/v1/accounts/current", nil)
if err != nil {
return nil, err
}
var res WalletBalance
err = json.Unmarshal(resp, &res)
if err != nil {
return nil, err
}
return &res, nil
}