github.com/Files-com/files-sdk-go/v3@v3.1.81/image.go (about) 1 package files_sdk 2 3 import ( 4 "encoding/json" 5 6 lib "github.com/Files-com/files-sdk-go/v3/lib" 7 ) 8 9 type Image struct { 10 Name string `json:"name,omitempty" path:"name,omitempty" url:"name,omitempty"` 11 Uri string `json:"uri,omitempty" path:"uri,omitempty" url:"uri,omitempty"` 12 } 13 14 // Identifier no path or id 15 16 type ImageCollection []Image 17 18 func (i *Image) UnmarshalJSON(data []byte) error { 19 type image Image 20 var v image 21 if err := json.Unmarshal(data, &v); err != nil { 22 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{}) 23 } 24 25 *i = Image(v) 26 return nil 27 } 28 29 func (i *ImageCollection) UnmarshalJSON(data []byte) error { 30 type images ImageCollection 31 var v images 32 if err := json.Unmarshal(data, &v); err != nil { 33 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{}) 34 } 35 36 *i = ImageCollection(v) 37 return nil 38 } 39 40 func (i *ImageCollection) ToSlice() *[]interface{} { 41 ret := make([]interface{}, len(*i)) 42 for i, v := range *i { 43 ret[i] = v 44 } 45 46 return &ret 47 }