github.com/Files-com/files-sdk-go/v3@v3.1.81/behavior.go (about) 1 package files_sdk 2 3 import ( 4 "encoding/json" 5 "io" 6 7 lib "github.com/Files-com/files-sdk-go/v3/lib" 8 ) 9 10 type Behavior struct { 11 Id int64 `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"` 12 Path string `json:"path,omitempty" path:"path,omitempty" url:"path,omitempty"` 13 AttachmentUrl string `json:"attachment_url,omitempty" path:"attachment_url,omitempty" url:"attachment_url,omitempty"` 14 Behavior string `json:"behavior,omitempty" path:"behavior,omitempty" url:"behavior,omitempty"` 15 Name string `json:"name,omitempty" path:"name,omitempty" url:"name,omitempty"` 16 Description string `json:"description,omitempty" path:"description,omitempty" url:"description,omitempty"` 17 Value map[string]interface{} `json:"value,omitempty" path:"value,omitempty" url:"value,omitempty"` 18 DisableParentFolderBehavior *bool `json:"disable_parent_folder_behavior,omitempty" path:"disable_parent_folder_behavior,omitempty" url:"disable_parent_folder_behavior,omitempty"` 19 Recursive *bool `json:"recursive,omitempty" path:"recursive,omitempty" url:"recursive,omitempty"` 20 AttachmentFile io.Reader `json:"attachment_file,omitempty" path:"attachment_file,omitempty" url:"attachment_file,omitempty"` 21 AttachmentDelete *bool `json:"attachment_delete,omitempty" path:"attachment_delete,omitempty" url:"attachment_delete,omitempty"` 22 } 23 24 func (b Behavior) Identifier() interface{} { 25 return b.Id 26 } 27 28 type BehaviorCollection []Behavior 29 30 type BehaviorListParams struct { 31 SortBy map[string]interface{} `url:"sort_by,omitempty" required:"false" json:"sort_by,omitempty" path:"sort_by"` 32 Filter Behavior `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"` 33 FilterPrefix map[string]interface{} `url:"filter_prefix,omitempty" required:"false" json:"filter_prefix,omitempty" path:"filter_prefix"` 34 ListParams 35 } 36 37 type BehaviorFindParams struct { 38 Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"` 39 } 40 41 type BehaviorListForParams struct { 42 SortBy map[string]interface{} `url:"sort_by,omitempty" required:"false" json:"sort_by,omitempty" path:"sort_by"` 43 Filter Behavior `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"` 44 FilterPrefix map[string]interface{} `url:"filter_prefix,omitempty" required:"false" json:"filter_prefix,omitempty" path:"filter_prefix"` 45 Path string `url:"-,omitempty" required:"false" json:"-,omitempty" path:"path"` 46 AncestorBehaviors string `url:"ancestor_behaviors,omitempty" required:"false" json:"ancestor_behaviors,omitempty" path:"ancestor_behaviors"` 47 Behavior string `url:"behavior,omitempty" required:"false" json:"behavior,omitempty" path:"behavior"` 48 ListParams 49 } 50 51 type BehaviorCreateParams struct { 52 Value string `url:"value,omitempty" required:"false" json:"value,omitempty" path:"value"` 53 AttachmentFile io.Writer `url:"attachment_file,omitempty" required:"false" json:"attachment_file,omitempty" path:"attachment_file"` 54 DisableParentFolderBehavior *bool `url:"disable_parent_folder_behavior,omitempty" required:"false" json:"disable_parent_folder_behavior,omitempty" path:"disable_parent_folder_behavior"` 55 Recursive *bool `url:"recursive,omitempty" required:"false" json:"recursive,omitempty" path:"recursive"` 56 Name string `url:"name,omitempty" required:"false" json:"name,omitempty" path:"name"` 57 Description string `url:"description,omitempty" required:"false" json:"description,omitempty" path:"description"` 58 Path string `url:"path,omitempty" required:"true" json:"path,omitempty" path:"path"` 59 Behavior string `url:"behavior,omitempty" required:"true" json:"behavior,omitempty" path:"behavior"` 60 } 61 62 type BehaviorWebhookTestParams struct { 63 Url string `url:"url,omitempty" required:"true" json:"url,omitempty" path:"url"` 64 Method string `url:"method,omitempty" required:"false" json:"method,omitempty" path:"method"` 65 Encoding string `url:"encoding,omitempty" required:"false" json:"encoding,omitempty" path:"encoding"` 66 Headers map[string]interface{} `url:"headers,omitempty" required:"false" json:"headers,omitempty" path:"headers"` 67 Body map[string]interface{} `url:"body,omitempty" required:"false" json:"body,omitempty" path:"body"` 68 Action string `url:"action,omitempty" required:"false" json:"action,omitempty" path:"action"` 69 } 70 71 type BehaviorUpdateParams struct { 72 Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"` 73 Value string `url:"value,omitempty" required:"false" json:"value,omitempty" path:"value"` 74 AttachmentFile io.Writer `url:"attachment_file,omitempty" required:"false" json:"attachment_file,omitempty" path:"attachment_file"` 75 DisableParentFolderBehavior *bool `url:"disable_parent_folder_behavior,omitempty" required:"false" json:"disable_parent_folder_behavior,omitempty" path:"disable_parent_folder_behavior"` 76 Recursive *bool `url:"recursive,omitempty" required:"false" json:"recursive,omitempty" path:"recursive"` 77 Name string `url:"name,omitempty" required:"false" json:"name,omitempty" path:"name"` 78 Description string `url:"description,omitempty" required:"false" json:"description,omitempty" path:"description"` 79 Behavior string `url:"behavior,omitempty" required:"false" json:"behavior,omitempty" path:"behavior"` 80 Path string `url:"path,omitempty" required:"false" json:"path,omitempty" path:"path"` 81 AttachmentDelete *bool `url:"attachment_delete,omitempty" required:"false" json:"attachment_delete,omitempty" path:"attachment_delete"` 82 } 83 84 type BehaviorDeleteParams struct { 85 Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"` 86 } 87 88 func (b *Behavior) UnmarshalJSON(data []byte) error { 89 type behavior Behavior 90 var v behavior 91 if err := json.Unmarshal(data, &v); err != nil { 92 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{}) 93 } 94 95 *b = Behavior(v) 96 return nil 97 } 98 99 func (b *BehaviorCollection) UnmarshalJSON(data []byte) error { 100 type behaviors BehaviorCollection 101 var v behaviors 102 if err := json.Unmarshal(data, &v); err != nil { 103 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{}) 104 } 105 106 *b = BehaviorCollection(v) 107 return nil 108 } 109 110 func (b *BehaviorCollection) ToSlice() *[]interface{} { 111 ret := make([]interface{}, len(*b)) 112 for i, v := range *b { 113 ret[i] = v 114 } 115 116 return &ret 117 }