-
Notifications
You must be signed in to change notification settings - Fork 2
/
style.go
66 lines (52 loc) · 1.75 KB
/
style.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package files_sdk
import (
"encoding/json"
"io"
lib "github.com/Files-com/files-sdk-go/v2/lib"
)
type Style struct {
Id int64 `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"`
Path string `json:"path,omitempty" path:"path,omitempty" url:"path,omitempty"`
Logo Image `json:"logo,omitempty" path:"logo,omitempty" url:"logo,omitempty"`
Thumbnail Image `json:"thumbnail,omitempty" path:"thumbnail,omitempty" url:"thumbnail,omitempty"`
File io.Reader `json:"file,omitempty" path:"file,omitempty" url:"file,omitempty"`
}
func (s Style) Identifier() interface{} {
return s.Id
}
type StyleCollection []Style
type StyleFindParams struct {
Path string `url:"-,omitempty" required:"false" json:"-,omitempty" path:"path"`
}
type StyleUpdateParams struct {
Path string `url:"-,omitempty" required:"false" json:"-,omitempty" path:"path"`
File io.Writer `url:"file,omitempty" required:"true" json:"file,omitempty" path:"file"`
}
type StyleDeleteParams struct {
Path string `url:"-,omitempty" required:"false" json:"-,omitempty" path:"path"`
}
func (s *Style) UnmarshalJSON(data []byte) error {
type style Style
var v style
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
}
*s = Style(v)
return nil
}
func (s *StyleCollection) UnmarshalJSON(data []byte) error {
type styles StyleCollection
var v styles
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
}
*s = StyleCollection(v)
return nil
}
func (s *StyleCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*s))
for i, v := range *s {
ret[i] = v
}
return &ret
}