-
Notifications
You must be signed in to change notification settings - Fork 2
/
status.go
48 lines (39 loc) · 990 Bytes
/
status.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
48
package files_sdk
import (
"encoding/json"
)
type Status struct {
Code int64 `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Status string `json:"status,omitempty"`
Data Auto `json:"data,omitempty"`
Errors Errors `json:"errors,omitempty"`
ClickwrapId int64 `json:"clickwrap_id,omitempty"`
ClickwrapBody string `json:"clickwrap_body,omitempty"`
}
type StatusCollection []Status
func (s *Status) UnmarshalJSON(data []byte) error {
type status Status
var v status
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = Status(v)
return nil
}
func (s *StatusCollection) UnmarshalJSON(data []byte) error {
type statuss []Status
var v statuss
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = StatusCollection(v)
return nil
}
func (s *StatusCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*s))
for i, v := range *s {
ret[i] = v
}
return &ret
}