-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmessages.go
More file actions
40 lines (33 loc) · 1014 Bytes
/
messages.go
File metadata and controls
40 lines (33 loc) · 1014 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
package cloudflare
import "encoding/json"
// Response - Cloudflare API Response.
type Response struct {
Result json.RawMessage `json:"result"`
ResultInfo *ResultInfo `json:"result_info"`
Errors []*ResponseError `json:"errors"`
Success bool `json:"success"`
}
// ResultInfo - Cloudflare API Response Result Info.
type ResultInfo struct {
Page int `json:"page,omitempty"`
PerPage int `json:"per_page,omitempty"`
TotalPages int `json:"total_pages,omitempty"`
Count int `json:"count,omitempty"`
TotalCount int `json:"total_count,omitempty"`
}
// ResponseError - Cloudflare API Response error.
type ResponseError struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
}
// Err - Gets response error if any.
func (response *Response) Err() error {
if len(response.Errors) > 0 {
return response.Errors[0]
}
return nil
}
// Error - Returns response error message.
func (err *ResponseError) Error() string {
return err.Message
}