Class: Files::Upload
- Inherits:
-
Object
- Object
- Files::Upload
- Defined in:
- lib/files.com/models/upload.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
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: path - string - File destination path.
Instance Method Summary collapse
-
#created_at ⇒ Object
date-time - File upload created at date/time.
-
#id ⇒ Object
int64 - File upload ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Upload
constructor
A new instance of Upload.
-
#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: path - string - File destination path.
-
#uploads ⇒ Object
array - A list of file parts included in this upload.
- #uploads=(value) ⇒ Object
-
#user_id ⇒ Object
int64 - User ID.
- #user_id=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Upload
Returns a new instance of Upload.
7 8 9 10 |
# File 'lib/files.com/models/upload.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/upload.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/upload.rb', line 5 def @options end |
Class Method Details
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
path - string - File destination path
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/files.com/models/upload.rb', line 72 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: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/uploads/#{params[:id]}", :patch, params, ) Upload.new(response.data, ) end |
Instance Method Details
#created_at ⇒ Object
date-time - File upload created at date/time
22 23 24 |
# File 'lib/files.com/models/upload.rb', line 22 def created_at @attributes[:created_at] end |
#id ⇒ Object
int64 - File upload ID
13 14 15 |
# File 'lib/files.com/models/upload.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/upload.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.
27 28 29 |
# File 'lib/files.com/models/upload.rb', line 27 def path @attributes[:path] end |
#path=(value) ⇒ Object
31 32 33 |
# File 'lib/files.com/models/upload.rb', line 31 def path=(value) @attributes[:path] = value end |
#save ⇒ Object
66 67 68 |
# File 'lib/files.com/models/upload.rb', line 66 def save update(@attributes) end |
#update(params = {}) ⇒ Object
Parameters:
path - string - File destination path
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/files.com/models/upload.rb', line 55 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: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/uploads/#{@attributes[:id]}", :patch, params, @options) end |
#uploads ⇒ Object
array - A list of file parts included in this upload
36 37 38 |
# File 'lib/files.com/models/upload.rb', line 36 def uploads @attributes[:uploads] end |
#uploads=(value) ⇒ Object
40 41 42 |
# File 'lib/files.com/models/upload.rb', line 40 def uploads=(value) @attributes[:uploads] = value end |
#user_id ⇒ Object
int64 - User ID
45 46 47 |
# File 'lib/files.com/models/upload.rb', line 45 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
49 50 51 |
# File 'lib/files.com/models/upload.rb', line 49 def user_id=(value) @attributes[:user_id] = value end |