Class: Files::Bundle
- Inherits:
-
Object
- Object
- Files::Bundle
- Defined in:
- lib/files.com/models/bundle.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: user_id - integer - User ID.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - integer - Bundle ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - integer - User ID.
-
.share(id, params = {}, options = {}) ⇒ Object
Send email(s) with a link to bundle.
Instance Method Summary collapse
-
#code ⇒ Object
string - Bundle code.
- #code=(value) ⇒ Object
-
#created_at ⇒ Object
date-time - Bundle created at date/time.
- #delete(params = {}) ⇒ Object
-
#description ⇒ Object
string - Public description.
- #description=(value) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#expires_at ⇒ Object
date-time - Bundle expiration date/time.
- #expires_at=(value) ⇒ Object
-
#id ⇒ Object
int64 - Bundle ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Bundle
constructor
A new instance of Bundle.
-
#note ⇒ Object
string - Bundle internal note.
- #note=(value) ⇒ Object
-
#password ⇒ Object
string - Password for this bundle.
- #password=(value) ⇒ Object
-
#password_protected ⇒ Object
boolean - Is this bundle password protected?.
- #password_protected=(value) ⇒ Object
-
#paths ⇒ Object
array - A list of paths in this bundle.
- #paths=(value) ⇒ Object
- #save ⇒ Object
-
#share(params = {}) ⇒ Object
Send email(s) with a link to bundle.
-
#url ⇒ Object
string - Public URL of Share Link.
- #url=(value) ⇒ Object
-
#user_id ⇒ Object
int64 - Bundle creator user ID.
- #user_id=(value) ⇒ Object
-
#username ⇒ Object
string - Bundle creator username.
- #username=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Bundle
Returns a new instance of Bundle.
7 8 9 10 |
# File 'lib/files.com/models/bundle.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/bundle.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/bundle.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
172 173 174 |
# File 'lib/files.com/models/bundle.rb', line 172 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
user_id - integer - User ID. Provide a value of `0` to operate the current session's user.
paths (required) - array - A list of paths to include in this bundle.
password - string - Password for this bundle.
expires_at - string - Bundle expiration date/time.
description - string - Bundle public description
note - string - Bundle internal note
199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/files.com/models/bundle.rb', line 199 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: paths must be an Array") if params.dig(:paths) and !params.dig(:paths).is_a?(Array) raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String) raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String) raise InvalidParameterError.new("Bad parameter: description must be an String") if params.dig(:description) and !params.dig(:description).is_a?(String) raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String) raise MissingParameterError.new("Parameter missing: paths") unless params.dig(:paths) response, = Api.send_request("/bundles", :post, params, ) Bundle.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
230 231 232 233 234 235 236 237 238 |
# File 'lib/files.com/models/bundle.rb', line 230 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("/bundles/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
240 241 242 |
# File 'lib/files.com/models/bundle.rb', line 240 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - integer - Bundle ID.
178 179 180 181 182 183 184 185 186 |
# File 'lib/files.com/models/bundle.rb', line 178 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("/bundles/#{params[:id]}", :get, params, ) Bundle.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
188 189 190 |
# File 'lib/files.com/models/bundle.rb', line 188 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
user_id - integer - User ID. Provide a value of `0` to operate the current session's user.
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.
162 163 164 165 166 167 168 169 170 |
# File 'lib/files.com/models/bundle.rb', line 162 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) 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) response, = Api.send_request("/bundles", :get, params, ) response.data.map { |object| Bundle.new(object, ) } end |
.share(id, params = {}, options = {}) ⇒ Object
Send email(s) with a link to bundle
Parameters:
to (required) - array - A list of email addresses to share this bundle with.
note - string - Note to include in email.
217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/files.com/models/bundle.rb', line 217 def self.share(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: to must be an Array") if params.dig(:to) and !params.dig(:to).is_a?(Array) raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) raise MissingParameterError.new("Parameter missing: to") unless params.dig(:to) response, = Api.send_request("/bundles/#{params[:id]}/share", :post, params, ) response.data end |
Instance Method Details
#code ⇒ Object
string - Bundle code. This code forms the end part of the Public URL.
13 14 15 |
# File 'lib/files.com/models/bundle.rb', line 13 def code @attributes[:code] end |
#code=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/bundle.rb', line 17 def code=(value) @attributes[:code] = value end |
#created_at ⇒ Object
date-time - Bundle created at date/time
22 23 24 |
# File 'lib/files.com/models/bundle.rb', line 22 def created_at @attributes[:created_at] end |
#delete(params = {}) ⇒ Object
134 135 136 137 138 139 140 141 142 |
# File 'lib/files.com/models/bundle.rb', line 134 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("/bundles/#{@attributes[:id]}", :delete, params, @options) end |
#description ⇒ Object
string - Public description
27 28 29 |
# File 'lib/files.com/models/bundle.rb', line 27 def description @attributes[:description] end |
#description=(value) ⇒ Object
31 32 33 |
# File 'lib/files.com/models/bundle.rb', line 31 def description=(value) @attributes[:description] = value end |
#destroy(params = {}) ⇒ Object
144 145 146 |
# File 'lib/files.com/models/bundle.rb', line 144 def destroy(params = {}) delete(params) end |
#expires_at ⇒ Object
date-time - Bundle expiration date/time
36 37 38 |
# File 'lib/files.com/models/bundle.rb', line 36 def expires_at @attributes[:expires_at] end |
#expires_at=(value) ⇒ Object
40 41 42 |
# File 'lib/files.com/models/bundle.rb', line 40 def expires_at=(value) @attributes[:expires_at] = value end |
#id ⇒ Object
int64 - Bundle ID
54 55 56 |
# File 'lib/files.com/models/bundle.rb', line 54 def id @attributes[:id] end |
#id=(value) ⇒ Object
58 59 60 |
# File 'lib/files.com/models/bundle.rb', line 58 def id=(value) @attributes[:id] = value end |
#note ⇒ Object
string - Bundle internal note
63 64 65 |
# File 'lib/files.com/models/bundle.rb', line 63 def note @attributes[:note] end |
#note=(value) ⇒ Object
67 68 69 |
# File 'lib/files.com/models/bundle.rb', line 67 def note=(value) @attributes[:note] = value end |
#password ⇒ Object
string - Password for this bundle.
108 109 110 |
# File 'lib/files.com/models/bundle.rb', line 108 def password @attributes[:password] end |
#password=(value) ⇒ Object
112 113 114 |
# File 'lib/files.com/models/bundle.rb', line 112 def password=(value) @attributes[:password] = value end |
#password_protected ⇒ Object
boolean - Is this bundle password protected?
72 73 74 |
# File 'lib/files.com/models/bundle.rb', line 72 def password_protected @attributes[:password_protected] end |
#password_protected=(value) ⇒ Object
76 77 78 |
# File 'lib/files.com/models/bundle.rb', line 76 def password_protected=(value) @attributes[:password_protected] = value end |
#paths ⇒ Object
array - A list of paths in this bundle
45 46 47 |
# File 'lib/files.com/models/bundle.rb', line 45 def paths @attributes[:paths] end |
#paths=(value) ⇒ Object
49 50 51 |
# File 'lib/files.com/models/bundle.rb', line 49 def paths=(value) @attributes[:paths] = value end |
#save ⇒ Object
148 149 150 151 152 153 154 155 |
# File 'lib/files.com/models/bundle.rb', line 148 def save if @attributes[:id] raise NotImplementedError.new("The Bundle object doesn't support updates.") else new_obj = Bundle.create(@attributes, @options) @attributes = new_obj.attributes end end |
#share(params = {}) ⇒ Object
Send email(s) with a link to bundle
Parameters:
to (required) - array - A list of email addresses to share this bundle with.
note - string - Note to include in email.
121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/files.com/models/bundle.rb', line 121 def share(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: to must be an Array") if params.dig(:to) and !params.dig(:to).is_a?(Array) raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) raise MissingParameterError.new("Parameter missing: to") unless params.dig(:to) Api.send_request("/bundles/#{@attributes[:id]}/share", :post, params, @options) end |
#url ⇒ Object
string - Public URL of Share Link
81 82 83 |
# File 'lib/files.com/models/bundle.rb', line 81 def url @attributes[:url] end |
#url=(value) ⇒ Object
85 86 87 |
# File 'lib/files.com/models/bundle.rb', line 85 def url=(value) @attributes[:url] = value end |
#user_id ⇒ Object
int64 - Bundle creator user ID
90 91 92 |
# File 'lib/files.com/models/bundle.rb', line 90 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
94 95 96 |
# File 'lib/files.com/models/bundle.rb', line 94 def user_id=(value) @attributes[:user_id] = value end |
#username ⇒ Object
string - Bundle creator username
99 100 101 |
# File 'lib/files.com/models/bundle.rb', line 99 def username @attributes[:username] end |
#username=(value) ⇒ Object
103 104 105 |
# File 'lib/files.com/models/bundle.rb', line 103 def username=(value) @attributes[:username] = value end |