Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impl /sapi/v1/margin/allAssets #327

Merged
merged 1 commit into from Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a new line here

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
}