Skip to content

Commit

Permalink
cosme
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokisan committed Feb 19, 2023
1 parent 0f5c9d9 commit a128db9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion integrationtest/v5/account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 9 additions & 4 deletions v5_account_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion v5_account_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions v5_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package bybit
type AccountType string

const (
UnifiedAccount AccountType = "UNIFIED"
NormalAccount AccountType = "CONTRACT"
AccountTypeUnified AccountType = "UNIFIED"
AccountTypeNormal AccountType = "CONTRACT"
)

// CategoryV5 :
Expand Down

0 comments on commit a128db9

Please sign in to comment.