mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
Merge pull request #1520 from c9s/edwin/okx/add-response-validation-func
FEATURE: [okx] add response validation func
This commit is contained in:
commit
3c73c28141
|
@ -7,6 +7,7 @@ import (
|
|||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
@ -246,3 +247,14 @@ type APIResponse struct {
|
|||
Message string `json:"msg"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
func (a APIResponse) Validate() error {
|
||||
if a.Code != "0" {
|
||||
return a.Error()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a APIResponse) Error() error {
|
||||
return fmt.Errorf("retCode: %s, retMsg: %s", a.Code, a.Message)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user