Class: Files::Behavior
- Inherits:
-
Object
- Object
- Files::Behavior
- Defined in:
- lib/files.com/models/behavior.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.create(params = {}, options = {}) ⇒ Object
Parameters: value - string - This field stores a hash of data specific to the type of behavior.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - int64 - Behavior ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
-
.list_for(path, params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: value - string - This field stores a hash of data specific to the type of behavior.
-
.webhook_test(params = {}, options = {}) ⇒ Object
Parameters: url (required) - string - URL for testing the webhook.
Instance Method Summary collapse
-
#attachment_delete ⇒ Object
boolean - If ‘true`, delete the file stored in `attachment`.
- #attachment_delete=(value) ⇒ Object
-
#attachment_file ⇒ Object
file - Certain behaviors may require a file, for instance, the ‘watermark` behavior requires a watermark image.
- #attachment_file=(value) ⇒ Object
-
#attachment_url ⇒ Object
string - URL for attached file.
- #attachment_url=(value) ⇒ Object
-
#behavior ⇒ Object
string - Behavior type.
- #behavior=(value) ⇒ Object
- #delete(params = {}) ⇒ Object
-
#description ⇒ Object
string - Description for this behavior.
- #description=(value) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#disable_parent_folder_behavior ⇒ Object
boolean - If true, the parent folder’s behavior will be disabled for this folder and its children.
- #disable_parent_folder_behavior=(value) ⇒ Object
-
#id ⇒ Object
int64 - Folder behavior ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Behavior
constructor
A new instance of Behavior.
-
#name ⇒ Object
string - Name for this behavior.
- #name=(value) ⇒ Object
-
#path ⇒ Object
string - Folder path.
- #path=(value) ⇒ Object
-
#recursive ⇒ Object
boolean - Is behavior recursive?.
- #recursive=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: value - string - This field stores a hash of data specific to the type of behavior.
-
#value ⇒ Object
object - Settings for this behavior.
- #value=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Behavior
Returns a new instance of Behavior.
7 8 9 10 |
# File 'lib/files.com/models/behavior.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/behavior.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/behavior.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
180 181 182 |
# File 'lib/files.com/models/behavior.rb', line 180 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
value - string - This field stores a hash of data specific to the type of behavior. See The Behavior Types section for example values for each type of behavior.
attachment_file - file - Certain behaviors may require a file, for instance, the `watermark` behavior requires a watermark image. Attach that file here.
disable_parent_folder_behavior - boolean - If `true`, the parent folder's behavior will be disabled for this folder and its children. This is the main mechanism for canceling out a `recursive` behavior higher in the folder tree.
recursive - boolean - If `true`, behavior is treated as recursive, meaning that it impacts child folders as well.
name - string - Name for this behavior.
description - string - Description for this behavior.
path (required) - string - Path where this behavior should apply.
behavior (required) - string - Behavior type.
239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/files.com/models/behavior.rb', line 239 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: value must be an String") if params[:value] and !params[:value].is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: description must be an String") if params[:description] and !params[:description].is_a?(String) raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params[:behavior] and !params[:behavior].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] raise MissingParameterError.new("Parameter missing: behavior") unless params[:behavior] response, = Api.send_request("/behaviors", :post, params, ) Behavior.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
294 295 296 297 298 299 300 301 302 |
# File 'lib/files.com/models/behavior.rb', line 294 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/behaviors/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
304 305 306 307 |
# File 'lib/files.com/models/behavior.rb', line 304 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Behavior ID.
186 187 188 189 190 191 192 193 194 |
# File 'lib/files.com/models/behavior.rb', line 186 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, = Api.send_request("/behaviors/#{params[:id]}", :get, params, ) Behavior.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
196 197 198 |
# File 'lib/files.com/models/behavior.rb', line 196 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string
page - int64
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[behavior]=desc`). Valid fields are `behavior` and `impacts_ui`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `impacts_ui` and `behavior`.
filter_prefix - object - If set, return records where the specified field is prefixed by the supplied value. Valid fields are `behavior`.
166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/files.com/models/behavior.rb', line 166 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params[:action] and !params[:action].is_a?(String) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params[:page] and !params[:page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_prefix must be an Hash") if params[:filter_prefix] and !params[:filter_prefix].is_a?(Hash) List.new(Behavior, params) do Api.send_request("/behaviors", :get, params, ) end end |
.list_for(path, params = {}, options = {}) ⇒ Object
Parameters:
cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string
page - int64
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[behavior]=desc`). Valid fields are `behavior` and `impacts_ui`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `impacts_ui` and `behavior`.
filter_prefix - object - If set, return records where the specified field is prefixed by the supplied value. Valid fields are `behavior`.
path (required) - string - Path to operate on.
ancestor_behaviors - boolean - If `true`, behaviors above this path are shown.
behavior - string
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/files.com/models/behavior.rb', line 211 def self.list_for(path, params = {}, = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params[:action] and !params[:action].is_a?(String) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params[:page] and !params[:page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_prefix must be an Hash") if params[:filter_prefix] and !params[:filter_prefix].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params[:behavior] and !params[:behavior].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] List.new(Behavior, params) do Api.send_request("/behaviors/folders/#{params[:path]}", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
value - string - This field stores a hash of data specific to the type of behavior. See The Behavior Types section for example values for each type of behavior.
attachment_file - file - Certain behaviors may require a file, for instance, the `watermark` behavior requires a watermark image. Attach that file here.
disable_parent_folder_behavior - boolean - If `true`, the parent folder's behavior will be disabled for this folder and its children. This is the main mechanism for canceling out a `recursive` behavior higher in the folder tree.
recursive - boolean - If `true`, behavior is treated as recursive, meaning that it impacts child folders as well.
name - string - Name for this behavior.
description - string - Description for this behavior.
attachment_delete - boolean - If `true`, delete the file stored in `attachment`.
280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/files.com/models/behavior.rb', line 280 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be one of String, Integer, Hash") if params[:id] and [ String, Integer, Hash ].none? { |klass| params[:id].is_a?(klass) } raise InvalidParameterError.new("Bad parameter: value must be an String") if params[:value] and !params[:value].is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: description must be an String") if params[:description] and !params[:description].is_a?(String) raise InvalidParameterError.new("Bad parameter: attachment_delete must be one of String, Integer, Hash") if params[:attachment_delete] and [ String, Integer, Hash ].none? { |klass| params[:attachment_delete].is_a?(klass) } raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, = Api.send_request("/behaviors/#{params[:id]}", :patch, params, ) Behavior.new(response.data, ) end |
.webhook_test(params = {}, options = {}) ⇒ Object
Parameters:
url (required) - string - URL for testing the webhook.
method - string - HTTP request method (GET or POST).
encoding - string - Encoding type for the webhook payload. Can be JSON, XML, or RAW (form data).
headers - object - Additional request headers to send via HTTP.
body - object - Additional body parameters to include in the webhook payload.
action - string - Action for test body.
259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/files.com/models/behavior.rb', line 259 def self.webhook_test(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: url must be an String") if params[:url] and !params[:url].is_a?(String) raise InvalidParameterError.new("Bad parameter: method must be an String") if params[:method] and !params[:method].is_a?(String) raise InvalidParameterError.new("Bad parameter: encoding must be an String") if params[:encoding] and !params[:encoding].is_a?(String) raise InvalidParameterError.new("Bad parameter: headers must be an Hash") if params[:headers] and !params[:headers].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: body must be an Hash") if params[:body] and !params[:body].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: action must be an String") if params[:action] and !params[:action].is_a?(String) raise MissingParameterError.new("Parameter missing: url") unless params[:url] Api.send_request("/behaviors/webhook/test", :post, params, ) nil end |
Instance Method Details
#attachment_delete ⇒ Object
boolean - If ‘true`, delete the file stored in `attachment`.
103 104 105 |
# File 'lib/files.com/models/behavior.rb', line 103 def @attributes[:attachment_delete] end |
#attachment_delete=(value) ⇒ Object
107 108 109 |
# File 'lib/files.com/models/behavior.rb', line 107 def (value) @attributes[:attachment_delete] = value end |
#attachment_file ⇒ Object
file - Certain behaviors may require a file, for instance, the ‘watermark` behavior requires a watermark image. Attach that file here.
94 95 96 |
# File 'lib/files.com/models/behavior.rb', line 94 def @attributes[:attachment_file] end |
#attachment_file=(value) ⇒ Object
98 99 100 |
# File 'lib/files.com/models/behavior.rb', line 98 def (value) @attributes[:attachment_file] = value end |
#attachment_url ⇒ Object
string - URL for attached file
31 32 33 |
# File 'lib/files.com/models/behavior.rb', line 31 def @attributes[:attachment_url] end |
#attachment_url=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/behavior.rb', line 35 def (value) @attributes[:attachment_url] = value end |
#behavior ⇒ Object
string - Behavior type.
40 41 42 |
# File 'lib/files.com/models/behavior.rb', line 40 def behavior @attributes[:behavior] end |
#behavior=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/behavior.rb', line 44 def behavior=(value) @attributes[:behavior] = value end |
#delete(params = {}) ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/files.com/models/behavior.rb', line 132 def delete(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/behaviors/#{@attributes[:id]}", :delete, params, @options) end |
#description ⇒ Object
string - Description for this behavior.
58 59 60 |
# File 'lib/files.com/models/behavior.rb', line 58 def description @attributes[:description] end |
#description=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/behavior.rb', line 62 def description=(value) @attributes[:description] = value end |
#destroy(params = {}) ⇒ Object
142 143 144 145 |
# File 'lib/files.com/models/behavior.rb', line 142 def destroy(params = {}) delete(params) nil end |
#disable_parent_folder_behavior ⇒ Object
boolean - If true, the parent folder’s behavior will be disabled for this folder and its children.
76 77 78 |
# File 'lib/files.com/models/behavior.rb', line 76 def disable_parent_folder_behavior @attributes[:disable_parent_folder_behavior] end |
#disable_parent_folder_behavior=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/behavior.rb', line 80 def disable_parent_folder_behavior=(value) @attributes[:disable_parent_folder_behavior] = value end |
#id ⇒ Object
int64 - Folder behavior ID
13 14 15 |
# File 'lib/files.com/models/behavior.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/behavior.rb', line 17 def id=(value) @attributes[:id] = value end |
#name ⇒ Object
string - Name for this behavior.
49 50 51 |
# File 'lib/files.com/models/behavior.rb', line 49 def name @attributes[:name] end |
#name=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/behavior.rb', line 53 def name=(value) @attributes[:name] = value end |
#path ⇒ Object
string - Folder path. Note that Behavior paths cannot be updated once initially set. You will need to remove and re-create the behavior on the new path. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
22 23 24 |
# File 'lib/files.com/models/behavior.rb', line 22 def path @attributes[:path] end |
#path=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/behavior.rb', line 26 def path=(value) @attributes[:path] = value end |
#recursive ⇒ Object
boolean - Is behavior recursive?
85 86 87 |
# File 'lib/files.com/models/behavior.rb', line 85 def recursive @attributes[:recursive] end |
#recursive=(value) ⇒ Object
89 90 91 |
# File 'lib/files.com/models/behavior.rb', line 89 def recursive=(value) @attributes[:recursive] = value end |
#save ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/files.com/models/behavior.rb', line 147 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = Behavior.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#update(params = {}) ⇒ Object
Parameters:
value - string - This field stores a hash of data specific to the type of behavior. See The Behavior Types section for example values for each type of behavior.
attachment_file - file - Certain behaviors may require a file, for instance, the `watermark` behavior requires a watermark image. Attach that file here.
disable_parent_folder_behavior - boolean - If `true`, the parent folder's behavior will be disabled for this folder and its children. This is the main mechanism for canceling out a `recursive` behavior higher in the folder tree.
recursive - boolean - If `true`, behavior is treated as recursive, meaning that it impacts child folders as well.
name - string - Name for this behavior.
description - string - Description for this behavior.
attachment_delete - boolean - If `true`, delete the file stored in `attachment`.
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/files.com/models/behavior.rb', line 119 def update(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: value must be an String") if params[:value] and !params[:value].is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: description must be an String") if params[:description] and !params[:description].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/behaviors/#{@attributes[:id]}", :patch, params, @options) end |
#value ⇒ Object
object - Settings for this behavior. See the section above for an example value to provide here. Formatting is different for each Behavior type. May be sent as nested JSON or a single JSON-encoded string. If using XML encoding for the API call, this data must be sent as a JSON-encoded string.
67 68 69 |
# File 'lib/files.com/models/behavior.rb', line 67 def value @attributes[:value] end |
#value=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/behavior.rb', line 71 def value=(value) @attributes[:value] = value end |