Class: Files::Upload

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, 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/upload.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @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 = {}, 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: 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, options = Api.send_request("/uploads/#{params[:id]}", :patch, params, options)
  Upload.new(response.data, options)
end

Instance Method Details

#created_atObject

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

#idObject

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

#pathObject

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

#saveObject



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

#uploadsObject

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_idObject

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