diff --git a/currency.go b/currency.go index 1d36806..c9834ad 100644 --- a/currency.go +++ b/currency.go @@ -30,6 +30,7 @@ func (as *ApiService) Currencies() (*ApiResponse, error) { } // 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 != "" { @@ -39,6 +40,40 @@ func (as *ApiService) Currency(currency string, chain string) (*ApiResponse, err 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. diff --git a/currency_test.go b/currency_test.go index fc0de5c..d9b9f6c 100644 --- a/currency_test.go +++ b/currency_test.go @@ -56,6 +56,27 @@ func TestApiService_Currency(t *testing.T) { } } +func TestApiService_Currency_V2(t *testing.T) { + s := NewApiServiceFromEnv() + rsp, err := s.CurrencyV2("BTC", "") + if err != nil { + t.Fatal(err) + } + c := &CurrencyV2Model{} + if err := rsp.ReadData(c); err != nil { + t.Fatal(err) + } + t.Log(ToJsonString(c)) + switch { + case c.Name == "": + t.Error("Empty key 'name'") + case c.Currency == "": + t.Error("Empty key 'currency'") + case c.FullName == "": + t.Error("Empty key 'fullName'") + } +} + func TestApiService_Prices(t *testing.T) { s := NewApiServiceFromEnv() rsp, err := s.Prices("USD", "BTC,KCS") diff --git a/order.go b/order.go index 679b612..0c8876b 100644 --- a/order.go +++ b/order.go @@ -19,7 +19,7 @@ type CreateOrderModel struct { Price string `json:"price,omitempty"` Size string `json:"size,omitempty"` TimeInForce string `json:"timeInForce,omitempty"` - CancelAfter uint64 `json:"cancelAfter,omitempty"` + CancelAfter int64 `json:"cancelAfter,omitempty"` PostOnly bool `json:"postOnly,omitempty"` Hidden bool `json:"hidden,omitempty"` IceBerg bool `json:"iceberg,omitempty"` @@ -113,7 +113,7 @@ type OrderModel struct { Hidden bool `json:"hidden"` IceBerg bool `json:"iceberg"` VisibleSize string `json:"visibleSize"` - CancelAfter uint64 `json:"cancelAfter"` + CancelAfter int64 `json:"cancelAfter"` Channel string `json:"channel"` ClientOid string `json:"clientOid"` Remark string `json:"remark"`