-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshared_types.go
47 lines (40 loc) · 1.08 KB
/
shared_types.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cfdns
import "slices"
type cfResponseCommon struct {
Success bool `json:"success"`
Errors []struct {
Code int `json:"code"`
Message string `json:"message"`
ErrorChain []struct {
Code int `json:"code"`
Message string `json:"message"`
} `json:"error_chain"`
} `json:"errors"`
Messages []struct {
Code int `json:"code"`
Message string `json:"message"`
} `json:"messages"`
ResultInfo struct {
Count int `json:"count"`
Page int `json:"page"`
PerPage int `json:"per_page"`
TotalCount int `json:"total_count"`
} `json:"result_info"`
}
// IsAnyCFErrorCode returns true if the CloudFlare error includes any
// of the provided codes.
func (rc *cfResponseCommon) IsAnyCFErrorCode(code ...int) bool {
for _, haveErr := range rc.Errors {
if slices.Contains(code, haveErr.Code) {
return true
}
}
return false
}
func (rc *cfResponseCommon) setCFCommonResponse(v *cfResponseCommon) {
*rc = *v
}
var _ commonResponseSetter = &cfResponseCommon{}
type commonResponseSetter interface {
setCFCommonResponse(*cfResponseCommon)
}