Class: Files::ZipDownload

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ ZipDownload

Returns a new instance of ZipDownload.



7
8
9
10
# File 'lib/files.com/models/zip_download.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/zip_download.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

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

Parameters:

paths (required) - array


41
42
43
44
45
46
47
# File 'lib/files.com/models/zip_download.rb', line 41

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: paths must be an Array") if params.dig(:paths) and !params.dig(:paths).is_a?(Array)
  raise MissingParameterError.new("Parameter missing: paths") unless params.dig(:paths)

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

Instance Method Details

#download_uriObject

string - URL for downloading the ZIP



13
14
15
# File 'lib/files.com/models/zip_download.rb', line 13

def download_uri
  @attributes[:download_uri]
end

#download_uri=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/zip_download.rb', line 17

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

#pathsObject

array(string)



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

def paths
  @attributes[:paths]
end

#paths=(value) ⇒ Object



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

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

#saveObject



30
31
32
33
34
35
36
37
# File 'lib/files.com/models/zip_download.rb', line 30

def save
  if @attributes[:id]
    raise NotImplementedError.new("The ZipDownload object doesn't support updates.")
  else
    new_obj = ZipDownload.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
end