-
Notifications
You must be signed in to change notification settings - Fork 0
/
private_fees.go
54 lines (47 loc) · 1.18 KB
/
private_fees.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 bitso
import (
"encoding/json"
"fmt"
"strconv"
)
type FeesResponse struct {
Success bool `json:"success"`
Error *Error `json:"error,omitempty"`
Fees Fees `json:"payload,omitempty"`
}
type Fees struct {
Fees []Fee `json:"fees"`
WithdrawalFees interface{} `json:"withdrawal_fees"`
}
type Fee struct {
Book string `json:"book"`
TakerFeeDecimal float64 `json:"taker_fee_decimal,string"`
TakerFeePercent float64 `json:"taker_fee_percent,string"`
MakerFeeDecimal float64 `json:"maker_fee_decimal,string"`
MakerFeePercent float64 `json:"maker_fee_percent,string"`
}
func (api *API) Fees() (*Fees, error) {
err := api.haveKeys()
if err != nil {
return nil, err
}
data, err := api.askPrivateGet("fees/", "")
if err != nil {
return nil, err
}
ab := FeesResponse{}
err = json.Unmarshal(data, &ab)
if err != nil {
return nil, err
}
// turn fees_withdrawal to float64
fees := map[string]float64{}
for id, val := range ab.Fees.WithdrawalFees.(map[string]interface{}) {
fees[id], _ = strconv.ParseFloat(val.(string), 64)
}
ab.Fees.WithdrawalFees = fees
if api.Devel {
fmt.Printf("DATA RECEIVED: %+v\n", ab)
}
return &ab.Fees, nil
}