-
Notifications
You must be signed in to change notification settings - Fork 2
/
preview.go
46 lines (37 loc) · 885 Bytes
/
preview.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
package files_sdk
import (
"encoding/json"
)
type Preview struct {
Id int64 `json:"id,omitempty"`
Status string `json:"status,omitempty"`
DownloadUri string `json:"download_uri,omitempty"`
Type string `json:"type,omitempty"`
Size int64 `json:"size,omitempty"`
}
type PreviewCollection []Preview
func (p *Preview) UnmarshalJSON(data []byte) error {
type preview Preview
var v preview
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = Preview(v)
return nil
}
func (p *PreviewCollection) UnmarshalJSON(data []byte) error {
type previews []Preview
var v previews
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = PreviewCollection(v)
return nil
}
func (p *PreviewCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*p))
for i, v := range *p {
ret[i] = v
}
return &ret
}