Skip to content

Commit

Permalink
Update make withdraw to sapi
Browse files Browse the repository at this point in the history
  • Loading branch information
kislikjeka committed Jun 13, 2021
1 parent 15fb07e commit 30d598f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
16 changes: 7 additions & 9 deletions v2/withdraw_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// See https://binance-docs.github.io/apidocs/spot/en/#withdraw
type CreateWithdrawService struct {
c *Client
asset string
coin string
withdrawOrderID *string
network *string
address string
Expand All @@ -20,9 +20,9 @@ type CreateWithdrawService struct {
name *string
}

// Asset sets the asset parameter (MANDATORY).
func (s *CreateWithdrawService) Asset(v string) *CreateWithdrawService {
s.asset = v
// Coin sets the asset parameter (MANDATORY).
func (s *CreateWithdrawService) Coin(v string) *CreateWithdrawService {
s.coin = v
return s
}

Expand Down Expand Up @@ -72,10 +72,10 @@ func (s *CreateWithdrawService) Name(v string) *CreateWithdrawService {
func (s *CreateWithdrawService) Do(ctx context.Context) (*CreateWithdrawResponse, error) {
r := &request{
method: "POST",
endpoint: "/wapi/v3/withdraw.html",
endpoint: "/sapi/v1/capital/withdraw/apply",
secType: secTypeSigned,
}
r.setParam("asset", s.asset)
r.setParam("coin", s.coin)
r.setParam("address", s.address)
r.setParam("amount", s.amount)
if v := s.withdrawOrderID; v != nil {
Expand Down Expand Up @@ -109,9 +109,7 @@ func (s *CreateWithdrawService) Do(ctx context.Context) (*CreateWithdrawResponse

// CreateWithdrawResponse represents a response from CreateWithdrawService.
type CreateWithdrawResponse struct {
ID string `json:"id"`
Msg string `json:"msg"`
Success bool `json:"success"`
ID string `json:"id"`
}

// ListWithdrawsService fetches withdraw history.
Expand Down
8 changes: 2 additions & 6 deletions v2/withdraw_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ func TestWithdrawService(t *testing.T) {
func (s *withdrawServiceTestSuite) TestCreateWithdraw() {
data := []byte(`
{
"msg": "success",
"success": true,
"id":"7213fea8e94b4a5593d507237e5a555b"
}
`)
Expand All @@ -35,7 +33,7 @@ func (s *withdrawServiceTestSuite) TestCreateWithdraw() {
name := "eth"
s.assertReq(func(r *request) {
e := newSignedRequest().setParams(params{
"asset": asset,
"coin": asset,
"withdrawOrderId": withdrawOrderID,
"network": network,
"address": address,
Expand All @@ -48,7 +46,7 @@ func (s *withdrawServiceTestSuite) TestCreateWithdraw() {
})

res, err := s.client.NewCreateWithdrawService().
Asset(asset).
Coin(asset).
WithdrawOrderID(withdrawOrderID).
Network(network).
Address(address).
Expand All @@ -61,8 +59,6 @@ func (s *withdrawServiceTestSuite) TestCreateWithdraw() {
r := s.r()
r.NoError(err)
r.Equal("7213fea8e94b4a5593d507237e5a555b", res.ID)
r.Equal("success", res.Msg)
r.True(res.Success)
}

func (s *withdrawServiceTestSuite) TestListWithdraws() {
Expand Down

0 comments on commit 30d598f

Please sign in to comment.