diff --git a/integrationtest/v5/account/account_test.go b/integrationtest/v5/account/account_test.go index 0116146..e364a66 100644 --- a/integrationtest/v5/account/account_test.go +++ b/integrationtest/v5/account/account_test.go @@ -12,7 +12,7 @@ import ( func TestGetWalletBalance(t *testing.T) { client := bybit.NewTestClient().WithAuthFromEnv() - res, err := client.V5().Account().GetWalletBalance(bybit.UnifiedAccount, "") + res, err := client.V5().Account().GetWalletBalance(bybit.AccountTypeUnified, nil) require.NoError(t, err) { goldenFilename := "./testdata/v5-account-get-wallet-balance.json" diff --git a/v5_account_service.go b/v5_account_service.go index 7effb07..200177c 100644 --- a/v5_account_service.go +++ b/v5_account_service.go @@ -2,11 +2,12 @@ package bybit import ( "net/url" + "strings" ) // V5AccountServiceI : type V5AccountServiceI interface { - GetWalletBalance(AccountType, string) (*V5WalletBalanceResponse, error) + GetWalletBalance(AccountType, []Coin) (*V5WalletBalanceResponse, error) } // V5AccountService : @@ -64,15 +65,19 @@ type V5WalletBalanceList struct { // coin: // If not passed, it returns non-zero asset info // You can pass multiple coins to query, separated by comma. "USDT,USDC". -func (s *V5AccountService) GetWalletBalance(at AccountType, coin string) (*V5WalletBalanceResponse, error) { +func (s *V5AccountService) GetWalletBalance(at AccountType, coins []Coin) (*V5WalletBalanceResponse, error) { var ( res V5WalletBalanceResponse query = make(url.Values) ) query.Add("accountType", string(at)) - if coin != "" { - query.Add("coin", coin) + if len(coins) > 0 { + var coinsStr []string + for _, c := range coins { + coinsStr = append(coinsStr, string(c)) + } + query.Add("coin", strings.Join(coinsStr, ",")) } if err := s.client.getV5Privately("/v5/account/wallet-balance", query, &res); err != nil { diff --git a/v5_account_service_test.go b/v5_account_service_test.go index e84d813..46c57fb 100644 --- a/v5_account_service_test.go +++ b/v5_account_service_test.go @@ -62,7 +62,7 @@ func TestV5Account_GetWalletBalance(t *testing.T) { WithBaseURL(server.URL). WithAuth("test", "test") - resp, err := client.V5().Account().GetWalletBalance(UnifiedAccount, "") + resp, err := client.V5().Account().GetWalletBalance(AccountTypeUnified, nil) require.NoError(t, err) require.NotNil(t, resp) diff --git a/v5_enum.go b/v5_enum.go index 75d0d12..57f56d8 100644 --- a/v5_enum.go +++ b/v5_enum.go @@ -4,8 +4,8 @@ package bybit type AccountType string const ( - UnifiedAccount AccountType = "UNIFIED" - NormalAccount AccountType = "CONTRACT" + AccountTypeUnified AccountType = "UNIFIED" + AccountTypeNormal AccountType = "CONTRACT" ) // CategoryV5 :