forked from Kucoin/kucoin-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrency.go
90 lines (80 loc) · 2.92 KB
/
currency.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package kucoin
import (
"net/http"
)
// A CurrencyModel represents a model of known currency.
type CurrencyModel struct {
Name string `json:"name"`
Currency string `json:"currency"`
FullName string `json:"fullName"`
Precision uint8 `json:"precision"`
Confirms int64 `json:"confirms"`
ContractAddress string `json:"contractAddress"`
WithdrawalMinSize string `json:"withdrawalMinSize"`
WithdrawalMinFee string `json:"withdrawalMinFee"`
IsWithdrawEnabled bool `json:"isWithdrawEnabled"`
IsDepositEnabled bool `json:"isDepositEnabled"`
IsMarginEnabled bool `json:"isMarginEnabled"`
IsDebitEnabled bool `json:"isDebitEnabled"`
}
// A CurrenciesModel is the set of *CurrencyModel.
type CurrenciesModel []*CurrencyModel
// Currencies returns a list of known currencies.
func (as *ApiService) Currencies() (*ApiResponse, error) {
req := NewRequest(http.MethodGet, "/api/v1/currencies", nil)
return as.Call(req)
}
// Currency returns the details of the currency.
// Deprecated: Use CurrencyV2 instead.
func (as *ApiService) Currency(currency string, chain string) (*ApiResponse, error) {
params := map[string]string{}
if chain != "" {
params["chain"] = chain
}
req := NewRequest(http.MethodGet, "/api/v1/currencies/"+currency, params)
return as.Call(req)
}
// ChainsModel Chains Model
type ChainsModel struct {
ChainName string `json:"chainName"`
WithdrawalMinSize string `json:"withdrawalMinSize"`
WithdrawalMinFee string `json:"withdrawalMinFee"`
IsWithdrawEnabled bool `json:"isWithdrawEnabled"`
IsDepositEnabled bool `json:"isDepositEnabled"`
Confirms int64 `json:"confirms"`
ContractAddress string `json:"contractAddress"`
}
// CurrencyV2Model CurrencyV2 Model
type CurrencyV2Model struct {
Name string `json:"name"`
Currency string `json:"currency"`
FullName string `json:"fullName"`
Precision uint8 `json:"precision"`
Confirms int64 `json:"confirms"`
ContractAddress string `json:"contractAddress"`
IsMarginEnabled bool `json:"isMarginEnabled"`
IsDebitEnabled bool `json:"isDebitEnabled"`
Chains []*ChainsModel `json:"chains"`
}
// CurrencyV2 returns the details of the currency.
func (as *ApiService) CurrencyV2(currency string, chain string) (*ApiResponse, error) {
params := map[string]string{}
if chain != "" {
params["chain"] = chain
}
req := NewRequest(http.MethodGet, "/api/v2/currencies/"+currency, params)
return as.Call(req)
}
type PricesModel map[string]string
// Prices returns the fiat prices for currency.
func (as *ApiService) Prices(base, currencies string) (*ApiResponse, error) {
params := map[string]string{}
if base != "" {
params["base"] = base
}
if currencies != "" {
params["currencies"] = currencies
}
req := NewRequest(http.MethodGet, "/api/v1/prices", params)
return as.Call(req)
}