Skip to content

Commit 3c73c28

Browse files
authored
Merge pull request #1520 from c9s/edwin/okx/add-response-validation-func
FEATURE: [okx] add response validation func
2 parents a800a59 + 3846b2a commit 3c73c28

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/exchange/okex/okexapi/client.go

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"crypto/sha256"
88
"encoding/base64"
99
"encoding/json"
10+
"fmt"
1011
"net/http"
1112
"net/url"
1213
"strings"
@@ -246,3 +247,14 @@ type APIResponse struct {
246247
Message string `json:"msg"`
247248
Data json.RawMessage `json:"data"`
248249
}
250+
251+
func (a APIResponse) Validate() error {
252+
if a.Code != "0" {
253+
return a.Error()
254+
}
255+
return nil
256+
}
257+
258+
func (a APIResponse) Error() error {
259+
return fmt.Errorf("retCode: %s, retMsg: %s", a.Code, a.Message)
260+
}

0 commit comments

Comments
 (0)