mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 15:10:19 +00:00
order: Add Side type MarshalJSON method (#1726)
* Add side MarshalJSON * glorious: nits * more removal * Update exchanges/order/order_test.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -2123,6 +2123,16 @@ func TestSideUnmarshal(t *testing.T) {
|
||||
assert.ErrorAs(t, s.UnmarshalJSON([]byte(`14`)), &jErr, "non-string valid json is rejected")
|
||||
}
|
||||
|
||||
func TestSideMarshalJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
b, err := Buy.MarshalJSON()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, `"BUY"`, string(b))
|
||||
b, err = UnknownSide.MarshalJSON()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, `"UNKNOWN"`, string(b))
|
||||
}
|
||||
|
||||
func TestGetTradeAmount(t *testing.T) {
|
||||
t.Parallel()
|
||||
var s *Submit
|
||||
|
||||
@@ -1115,6 +1115,11 @@ func (s *Side) UnmarshalJSON(data []byte) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalJSON returns the JSON-encoded order side
|
||||
func (s Side) MarshalJSON() ([]byte, error) {
|
||||
return []byte(`"` + s.String() + `"`), nil
|
||||
}
|
||||
|
||||
// StringToOrderType for converting case insensitive order type
|
||||
// and returning a real Type
|
||||
func StringToOrderType(oType string) (Type, error) {
|
||||
|
||||
Reference in New Issue
Block a user