Skip to content

Commit

Permalink
Update getDeposit adddress for sapi
Browse files Browse the repository at this point in the history
  • Loading branch information
kislikjeka committed Jun 10, 2021
1 parent 90f5a4f commit 314ce9f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
43 changes: 43 additions & 0 deletions v2/borker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,49 @@ func (c *Client) SubAccountTransfer(ctx context.Context, req SubAccountTransferR
return res, nil
}

// TransferHistory makes request
func (c *Client) TransferHistory(ctx context.Context, req SubAccountTransferHistoryRequest, opts ...RequestOption) (res *TransferHistoryResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/sapi/v1/broker/transfer",
secType: secTypeSigned,
}
if req.FromID != "" {
r.setParam("fromId", req.FromID)
}
if req.ToID != "" {
r.setParam("toId", req.ToID)
}
if req.ClientTransferID != "" {
r.setParam("clientTranId", req.ClientTransferID)
}
if req.StartTime > 0 {
r.setParam("startTime", req.StartTime)
}
if req.EndTime > 0 {
r.setParam("endTime", req.EndTime)
}
if req.Limit > 0 {
r.setParam("limit", req.Limit)
}
if req.Page > 0 {
r.setParam("page", req.Page)
}

data, err := c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}

res = new(TransferHistoryResponse)
err = json.Unmarshal(data, &res)
if err != nil {
return nil, err
}

return res, nil
}

// callAPI makes API call
func (c *Client) callAPI(ctx context.Context, r *request, opts ...RequestOption) (data []byte, err error) {
err = c.parseRequest(r, opts...)
Expand Down
27 changes: 27 additions & 0 deletions v2/borker/sub_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,35 @@ type SubAccountTransferRequest struct {
Amount float64
}

// SubAccountTransferHistoryRequest is a request struct
type SubAccountTransferHistoryRequest struct {
FromID string
ToID string
ClientTransferID string
ShowAllStatus bool
StartTime int64
EndTime int64
Page int
Limit int
}

// SubAccountTransferResponse is a response struct
type SubAccountTransferResponse struct {
TxnID string `json:"txnId"`
ClientTranID string `json:"clientTranId"`
}

// TransferHistoryResponse is transfer history response
type TransferHistoryResponse []*Transfer

//Transfer is a transfer struct
type Transfer struct {
FromId string `json:"fromId"`
ToId string `json:"toId"`
Asset string `json:"asset"`
Qty string `json:"qty"`
Time int64 `json:"time"`
TxnId string `json:"txnId"`
ClientTranId string `json:"clientTranId"`
Status string `json:"status"`
}

0 comments on commit 314ce9f

Please sign in to comment.