Skip to content

Commit

Permalink
Impl /sapi/v1/margin/allAssets (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
qct committed Nov 17, 2021
1 parent 15a4341 commit 1548a5f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions v2/client.go
Expand Up @@ -662,3 +662,8 @@ func (c *Client) NewAssetDividendService() *AssetDividendService {
func (c *Client) NewUserUniversalTransferService() *CreateUserUniversalTransferService {
return &CreateUserUniversalTransferService{c: c}
}

// NewDustTransferService init Get All Margin Assets service
func (c *Client) NewGetAllMarginAssetsService() *GetAllMarginAssetsService {
return &GetAllMarginAssetsService{c: c}
}
24 changes: 24 additions & 0 deletions v2/margin_service.go
Expand Up @@ -977,3 +977,27 @@ func (s *CloseMarginUserStreamService) Do(ctx context.Context, opts ...RequestOp
_, err = s.c.callAPI(ctx, r, opts...)
return err
}

// GetAllMarginAssetsService get margin pair info
type GetAllMarginAssetsService struct {
c *Client
}

// Do send request
func (s *GetAllMarginAssetsService) Do(ctx context.Context, opts ...RequestOption) (res []*MarginAsset, err error) {
r := &request{
method: "GET",
endpoint: "/sapi/v1/margin/allAssets",
secType: secTypeAPIKey,
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return []*MarginAsset{}, err
}
res = make([]*MarginAsset, 0)
err = json.Unmarshal(data, &res)
if err != nil {
return []*MarginAsset{}, err
}
return res, nil
}

0 comments on commit 1548a5f

Please sign in to comment.