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 - The value of the folder behavior.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - integer - Behavior ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: page - integer - Current page number.
-
.list_for(path, params = {}, options = {}) ⇒ Object
Parameters: page - integer - Current page number.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: value - string - The value of the folder behavior.
-
.webhook_test(params = {}, options = {}) ⇒ Object
Parameters: method - string - HTTP method(GET or POST).
Instance Method Summary collapse
-
#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
- #destroy(params = {}) ⇒ Object
-
#id ⇒ Object
int64 - Folder behavior ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Behavior
constructor
A new instance of Behavior.
-
#path ⇒ Object
string - Folder path This must be slash-delimited, but it must neither start nor end with a slash.
- #path=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: value - string - The value of the folder 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
118 119 120 |
# File 'lib/files.com/models/behavior.rb', line 118 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
value - string - The value of the folder behavior. Can be a integer, array, or hash depending on the type of folder behavior.
attachment_file - file - Certain behaviors may require a file, for instance, the "watermark" behavior requires a watermark image
path (required) - string - Folder behaviors path.
behavior (required) - string - Behavior type.
165 166 167 168 169 170 171 172 173 174 |
# File 'lib/files.com/models/behavior.rb', line 165 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: value must be an String") if params.dig(:value) and !params.dig(:value).is_a?(String) raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) raise MissingParameterError.new("Parameter missing: behavior") unless params.dig(:behavior) response, = Api.send_request("/behaviors", :post, params, ) Behavior.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
204 205 206 207 208 209 210 211 212 |
# File 'lib/files.com/models/behavior.rb', line 204 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/behaviors/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
214 215 216 |
# File 'lib/files.com/models/behavior.rb', line 214 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - integer - Behavior ID.
146 147 148 149 150 151 152 153 154 |
# File 'lib/files.com/models/behavior.rb', line 146 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/behaviors/#{params[:id]}", :get, params, ) Behavior.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
156 157 158 |
# File 'lib/files.com/models/behavior.rb', line 156 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
page - integer - Current page number.
per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
behavior - string - If set, only shows folder behaviors matching this behavior type.
108 109 110 111 112 113 114 115 116 |
# File 'lib/files.com/models/behavior.rb', line 108 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String) response, = Api.send_request("/behaviors", :get, params, ) response.data.map { |object| Behavior.new(object, ) } end |
.list_for(path, params = {}, options = {}) ⇒ Object
Parameters:
page - integer - Current page number.
per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
path (required) - string - Path to operate on.
recursive - string - Show behaviors below this path?
behavior - string - If set only shows folder behaviors matching this behavior type.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/files.com/models/behavior.rb', line 129 def self.list_for(path, params = {}, = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: recursive must be an String") if params.dig(:recursive) and !params.dig(:recursive).is_a?(String) raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) response, = Api.send_request("/behaviors/folders/#{URI.encode_www_form_component(params[:path])}", :get, params, ) response.data.map { |object| Behavior.new(object, ) } end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
value - string - The value of the folder behavior. Can be a integer, array, or hash depending on the type of folder behavior.
attachment_file - file - Certain behaviors may require a file, for instance, the "watermark" behavior requires a watermark image
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/files.com/models/behavior.rb', line 193 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: value must be an String") if params.dig(:value) and !params.dig(:value).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/behaviors/#{params[:id]}", :patch, params, ) Behavior.new(response.data, ) end |
.webhook_test(params = {}, options = {}) ⇒ Object
Parameters:
method - string - HTTP method(GET or POST).
encoding - string - HTTP encoding method. Can be JSON, XML, or RAW (form data).
test_webhook[url] (required) - string - URL for testing the webhook.
url - string - URL for testing the webhook.
181 182 183 184 185 186 187 188 |
# File 'lib/files.com/models/behavior.rb', line 181 def self.webhook_test(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: method must be an String") if params.dig(:method) and !params.dig(:method).is_a?(String) raise InvalidParameterError.new("Bad parameter: encoding must be an String") if params.dig(:encoding) and !params.dig(:encoding).is_a?(String) raise InvalidParameterError.new("Bad parameter: url must be an String") if params.dig(:url) and !params.dig(:url).is_a?(String) response, = Api.send_request("/behaviors/webhook/test", :post, params, ) response.data end |
Instance Method Details
#attachment_file ⇒ Object
file - Certain behaviors may require a file, for instance, the “watermark” behavior requires a watermark image
58 59 60 |
# File 'lib/files.com/models/behavior.rb', line 58 def @attributes[:attachment_file] end |
#attachment_file=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/behavior.rb', line 62 def (value) @attributes[:attachment_file] = value end |
#attachment_url ⇒ Object
string - URL for attached file
22 23 24 |
# File 'lib/files.com/models/behavior.rb', line 22 def @attributes[:attachment_url] end |
#attachment_url=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/behavior.rb', line 26 def (value) @attributes[:attachment_url] = value end |
#behavior ⇒ Object
string - Behavior type.
31 32 33 |
# File 'lib/files.com/models/behavior.rb', line 31 def behavior @attributes[:behavior] end |
#behavior=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/behavior.rb', line 35 def behavior=(value) @attributes[:behavior] = value end |
#delete(params = {}) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/files.com/models/behavior.rb', line 80 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.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/behaviors/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
90 91 92 |
# File 'lib/files.com/models/behavior.rb', line 90 def destroy(params = {}) delete(params) 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 |
#path ⇒ Object
string - Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
40 41 42 |
# File 'lib/files.com/models/behavior.rb', line 40 def path @attributes[:path] end |
#path=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/behavior.rb', line 44 def path=(value) @attributes[:path] = value end |
#save ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/files.com/models/behavior.rb', line 94 def save if @attributes[:id] update(@attributes) else new_obj = Behavior.create(@attributes, @options) @attributes = new_obj.attributes end end |
#update(params = {}) ⇒ Object
Parameters:
value - string - The value of the folder behavior. Can be a integer, array, or hash depending on the type of folder behavior.
attachment_file - file - Certain behaviors may require a file, for instance, the "watermark" behavior requires a watermark image
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/files.com/models/behavior.rb', line 69 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.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: value must be an String") if params.dig(:value) and !params.dig(:value).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(: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.
49 50 51 |
# File 'lib/files.com/models/behavior.rb', line 49 def value @attributes[:value] end |
#value=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/behavior.rb', line 53 def value=(value) @attributes[:value] = value end |