Skip to content

Commit

Permalink
Merge branch 'adshao:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xyq-c-cpp authored Nov 13, 2023
2 parents 6a44e54 + 67358d3 commit 184be33
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const (
OrderStatusTypePendingCancel OrderStatusType = "PENDING_CANCEL"
OrderStatusTypeRejected OrderStatusType = "REJECTED"
OrderStatusTypeExpired OrderStatusType = "EXPIRED"
OrderStatusExpiredInMatch OrderStatusType = "EXPIRED_IN_MATCH" // STP Expired

SymbolTypeSpot SymbolType = "SPOT"

Expand Down
7 changes: 7 additions & 0 deletions v2/futures/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@ func WithHeaders(header http.Header) RequestOption {
r.header = header.Clone()
}
}

// WithExtraForm add extra form data of the request
func WithExtraForm(m map[string]any) RequestOption {
return func(r *request) {
r.setFormParams(m)
}
}
46 changes: 46 additions & 0 deletions v2/futures/request_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package futures

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestWithExtraForm(t *testing.T) {
tests := []struct {
name string
r *request
m map[string]any
wantRequest *request
}{
{
name: "place order use extra priceMatch and goodTillDate",
r: &request{
form: map[string][]string{
"symbol": {"BTCUSDT"},
"orderId": {"1"},
},
},
m: map[string]any{
"priceMatch": "QUEUE",
"goodTillDate": 1697796587000,
},
wantRequest: &request{
form: map[string][]string{
"symbol": {"BTCUSDT"},
"orderId": {"1"},
"priceMatch": {"QUEUE"},
"goodTillDate": {"1697796587000"},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

opt := WithExtraForm(tt.m)
opt(tt.r)

assert.Equal(t, tt.wantRequest, tt.r)
})
}
}

0 comments on commit 184be33

Please sign in to comment.