forked from nrdcg/goinwx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.go
29 lines (24 loc) · 880 Bytes
/
response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package goinwx
import "fmt"
// Response is a INWX API response. This wraps the standard http.Response returned from INWX.
type Response struct {
Code int `xmlrpc:"code"`
Message string `xmlrpc:"msg"`
ReasonCode string `xmlrpc:"reasonCode"`
Reason string `xmlrpc:"reason"`
ResponseData map[string]interface{} `xmlrpc:"resData"`
}
// An ErrorResponse reports the error caused by an API request.
type ErrorResponse struct {
Code int `xmlrpc:"code"`
Message string `xmlrpc:"msg"`
ReasonCode string `xmlrpc:"reasonCode"`
Reason string `xmlrpc:"reason"`
}
func (r *ErrorResponse) Error() string {
if r.Reason != "" {
return fmt.Sprintf("(%d) %s. Reason: (%s) %s",
r.Code, r.Message, r.ReasonCode, r.Reason)
}
return fmt.Sprintf("(%d) %s", r.Code, r.Message)
}