Class: Files::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/bundle.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/bundle.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/bundle.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



247
248
249
# File 'lib/files.com/models/bundle.rb', line 247

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
paths (required) - array(string) - A list of paths to include in this bundle.
password - string - Password for this bundle.
expires_at - string - Bundle expiration date/time
max_uses - int64 - Maximum number of times bundle can be accessed
description - string - Public description
note - string - Bundle internal note
code - string - Bundle code.  This code forms the end part of the Public URL.
require_registration - boolean - Show a registration page that captures the downloader's name and email address?
clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
inbox_id - int64 - ID of the associated inbox, if available.


279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/files.com/models/bundle.rb', line 279

def self.create(params = {}, options = {})
  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: max_uses must be an Integer") if params.dig(:max_uses) and !params.dig(:max_uses).is_a?(Integer)
  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 InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: clickwrap_id must be an Integer") if params.dig(:clickwrap_id) and !params.dig(:clickwrap_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: inbox_id must be an Integer") if params.dig(:inbox_id) and !params.dig(:inbox_id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: paths") unless params.dig(:paths)

  response, options = Api.send_request("/bundles", :post, params, options)
  Bundle.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



342
343
344
345
346
347
348
349
350
# File 'lib/files.com/models/bundle.rb', line 342

def self.delete(id, params = {}, options = {})
  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, _options = Api.send_request("/bundles/#{params[:id]}", :delete, params, options)
  response.data
end

.destroy(id, params = {}, options = {}) ⇒ Object



352
353
354
# File 'lib/files.com/models/bundle.rb', line 352

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - int64 - Bundle ID.


253
254
255
256
257
258
259
260
261
# File 'lib/files.com/models/bundle.rb', line 253

def self.find(id, params = {}, options = {})
  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, options = Api.send_request("/bundles/#{params[:id]}", :get, params, options)
  Bundle.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



263
264
265
# File 'lib/files.com/models/bundle.rb', line 263

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
page - int64 - Current page number.
per_page - int64 - 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.


235
236
237
238
239
240
241
242
243
244
245
# File 'lib/files.com/models/bundle.rb', line 235

def self.list(params = {}, options = {})
  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, options = Api.send_request("/bundles", :get, params, options)
  response.data.map do |entity_data|
    Bundle.new(entity_data, options)
  end
end

.share(id, params = {}, options = {}) ⇒ Object

Send email(s) with a link to bundle

Parameters:

to (required) - array(string) - A list of email addresses to share this bundle with.
note - string - Note to include in email.


301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/files.com/models/bundle.rb', line 301

def self.share(id, params = {}, options = {})
  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, _options = Api.send_request("/bundles/#{params[:id]}/share", :post, params, options)
  response.data
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

password - string - Password for this bundle.
expires_at - string - Bundle expiration date/time
max_uses - int64 - Maximum number of times bundle can be accessed
description - string - Public description
note - string - Bundle internal note
code - string - Bundle code.  This code forms the end part of the Public URL.
require_registration - boolean - Show a registration page that captures the downloader's name and email address?
clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
inbox_id - int64 - ID of the associated inbox, if available.


324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/files.com/models/bundle.rb', line 324

def self.update(id, params = {}, options = {})
  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: 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: max_uses must be an Integer") if params.dig(:max_uses) and !params.dig(:max_uses).is_a?(Integer)
  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 InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: clickwrap_id must be an Integer") if params.dig(:clickwrap_id) and !params.dig(:clickwrap_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: inbox_id must be an Integer") if params.dig(:inbox_id) and !params.dig(:inbox_id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/bundles/#{params[:id]}", :patch, params, options)
  Bundle.new(response.data, options)
end

Instance Method Details

#clickwrap_bodyObject

string - Legal text that must be agreed to prior to accessing Bundle.



58
59
60
# File 'lib/files.com/models/bundle.rb', line 58

def clickwrap_body
  @attributes[:clickwrap_body]
end

#clickwrap_body=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/bundle.rb', line 62

def clickwrap_body=(value)
  @attributes[:clickwrap_body] = value
end

#clickwrap_idObject

int64 - ID of the clickwrap to use with this bundle.



126
127
128
# File 'lib/files.com/models/bundle.rb', line 126

def clickwrap_id
  @attributes[:clickwrap_id]
end

#clickwrap_id=(value) ⇒ Object



130
131
132
# File 'lib/files.com/models/bundle.rb', line 130

def clickwrap_id=(value)
  @attributes[:clickwrap_id] = value
end

#codeObject

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_atObject

date-time - Bundle created at date/time



76
77
78
# File 'lib/files.com/models/bundle.rb', line 76

def created_at
  @attributes[:created_at]
end

#delete(params = {}) ⇒ Object



207
208
209
210
211
212
213
214
215
# File 'lib/files.com/models/bundle.rb', line 207

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

#descriptionObject

string - Public description



31
32
33
# File 'lib/files.com/models/bundle.rb', line 31

def description
  @attributes[:description]
end

#description=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/bundle.rb', line 35

def description=(value)
  @attributes[:description] = value
end

#destroy(params = {}) ⇒ Object



217
218
219
# File 'lib/files.com/models/bundle.rb', line 217

def destroy(params = {})
  delete(params)
end

#expires_atObject

date-time - Bundle expiration date/time



81
82
83
# File 'lib/files.com/models/bundle.rb', line 81

def expires_at
  @attributes[:expires_at]
end

#expires_at=(value) ⇒ Object



85
86
87
# File 'lib/files.com/models/bundle.rb', line 85

def expires_at=(value)
  @attributes[:expires_at] = value
end

#idObject

int64 - Bundle ID



67
68
69
# File 'lib/files.com/models/bundle.rb', line 67

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/bundle.rb', line 71

def id=(value)
  @attributes[:id] = value
end

#inbox_idObject

int64 - ID of the associated inbox, if available.



135
136
137
# File 'lib/files.com/models/bundle.rb', line 135

def inbox_id
  @attributes[:inbox_id]
end

#inbox_id=(value) ⇒ Object



139
140
141
# File 'lib/files.com/models/bundle.rb', line 139

def inbox_id=(value)
  @attributes[:inbox_id] = value
end

#max_usesObject

int64 - Maximum number of times bundle can be accessed



90
91
92
# File 'lib/files.com/models/bundle.rb', line 90

def max_uses
  @attributes[:max_uses]
end

#max_uses=(value) ⇒ Object



94
95
96
# File 'lib/files.com/models/bundle.rb', line 94

def max_uses=(value)
  @attributes[:max_uses] = value
end

#noteObject

string - Bundle internal note



99
100
101
# File 'lib/files.com/models/bundle.rb', line 99

def note
  @attributes[:note]
end

#note=(value) ⇒ Object



103
104
105
# File 'lib/files.com/models/bundle.rb', line 103

def note=(value)
  @attributes[:note] = value
end

#passwordObject

string - Password for this bundle.



153
154
155
# File 'lib/files.com/models/bundle.rb', line 153

def password
  @attributes[:password]
end

#password=(value) ⇒ Object



157
158
159
# File 'lib/files.com/models/bundle.rb', line 157

def password=(value)
  @attributes[:password] = value
end

#password_protectedObject

boolean - Is this bundle password protected?



40
41
42
# File 'lib/files.com/models/bundle.rb', line 40

def password_protected
  @attributes[:password_protected]
end

#password_protected=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/bundle.rb', line 44

def password_protected=(value)
  @attributes[:password_protected] = value
end

#pathsObject

array - A list of paths in this bundle



144
145
146
# File 'lib/files.com/models/bundle.rb', line 144

def paths
  @attributes[:paths]
end

#paths=(value) ⇒ Object



148
149
150
# File 'lib/files.com/models/bundle.rb', line 148

def paths=(value)
  @attributes[:paths] = value
end

#require_registrationObject

boolean - Show a registration page that captures the downloader’s name and email address?



49
50
51
# File 'lib/files.com/models/bundle.rb', line 49

def require_registration
  @attributes[:require_registration]
end

#require_registration=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/bundle.rb', line 53

def require_registration=(value)
  @attributes[:require_registration] = value
end

#saveObject



221
222
223
224
225
226
227
228
# File 'lib/files.com/models/bundle.rb', line 221

def save
  if @attributes[:id]
    update(@attributes)
  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(string) - A list of email addresses to share this bundle with.
note - string - Note to include in email.


166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/files.com/models/bundle.rb', line 166

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

#update(params = {}) ⇒ Object

Parameters:

password - string - Password for this bundle.
expires_at - string - Bundle expiration date/time
max_uses - int64 - Maximum number of times bundle can be accessed
description - string - Public description
note - string - Bundle internal note
code - string - Bundle code.  This code forms the end part of the Public URL.
require_registration - boolean - Show a registration page that captures the downloader's name and email address?
clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
inbox_id - int64 - ID of the associated inbox, if available.


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/files.com/models/bundle.rb', line 189

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: 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: max_uses must be an Integer") if params.dig(:max_uses) and !params.dig(:max_uses).is_a?(Integer)
  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 InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: clickwrap_id must be an Integer") if params.dig(:clickwrap_id) and !params.dig(:clickwrap_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: inbox_id must be an Integer") if params.dig(:inbox_id) and !params.dig(:inbox_id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/bundles/#{@attributes[:id]}", :patch, params, @options)
end

#urlObject

string - Public URL of Share Link



22
23
24
# File 'lib/files.com/models/bundle.rb', line 22

def url
  @attributes[:url]
end

#url=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/bundle.rb', line 26

def url=(value)
  @attributes[:url] = value
end

#user_idObject

int64 - Bundle creator user ID



108
109
110
# File 'lib/files.com/models/bundle.rb', line 108

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



112
113
114
# File 'lib/files.com/models/bundle.rb', line 112

def user_id=(value)
  @attributes[:user_id] = value
end

#usernameObject

string - Bundle creator username



117
118
119
# File 'lib/files.com/models/bundle.rb', line 117

def username
  @attributes[:username]
end

#username=(value) ⇒ Object



121
122
123
# File 'lib/files.com/models/bundle.rb', line 121

def username=(value)
  @attributes[:username] = value
end