diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fc00d7..606078e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ Changelog ========= All notable changes to this project will be documented in this file. +v1.0.34-alpha +------------- + +### Changed + +- Fixed response struct unmarshalling issue + v1.0.33-alpha ------------- diff --git a/README.md b/README.md index 9818a27..b889e75 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Installation ----------------- ```bash -go get github.com/amir-the-h/okex@v1.0.33-alpha +go get github.com/amir-the-h/okex@v1.0.34-alpha ``` Usage diff --git a/definitions.go b/definitions.go index e75e171..d8e3b2a 100644 --- a/definitions.go +++ b/definitions.go @@ -299,7 +299,7 @@ const ( CandleStick1m = CandleStickWsBarSize("candle1m") ) -func (t JSONTime) String() string { return time.Time(t).String() } +func (t *JSONTime) String() string { return (time.Time)(*t).String() } func (t *JSONTime) UnmarshalJSON(s []byte) (err error) { r := strings.Replace(string(s), `"`, ``, -1) diff --git a/requests/rest/tradedata/trade_data_requests.go b/requests/rest/tradedata/trade_data_requests.go index a536483..e6a9328 100644 --- a/requests/rest/tradedata/trade_data_requests.go +++ b/requests/rest/tradedata/trade_data_requests.go @@ -7,7 +7,7 @@ type ( Ccy string `json:"ccy"` Begin int64 `json:"before,omitempty,string"` End int64 `json:"limit,omitempty,string"` - InstType okex.InstrumentType `json:"instType,string"` + InstType okex.InstrumentType `json:"instType"` Period okex.BarSize `json:"period,string,omitempty"` } GetRatio struct { diff --git a/responses/responses.go b/responses/responses.go index 3e4132b..220e710 100644 --- a/responses/responses.go +++ b/responses/responses.go @@ -1,28 +1,8 @@ package responses -import ( - "encoding/json" - "fmt" -) - type ( Basic struct { Code int `json:"code,string"` Msg string `json:"msg,omitempty"` } ) - -type resCode Basic - -func (b *Basic) UnmarshalJSON(bf []byte) error { - var r resCode - err := json.Unmarshal(bf, &r) - if err != nil { - return err - } - b = (*Basic)(&r) - if b.Code != 0 { - return fmt.Errorf("recevied error:%+v", b) - } - return nil -}