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(string)
bundle_registration_code - string
encoded_paths - array(string)


63
64
65
66
67
68
69
70
71
# File 'lib/files.com/models/zip_download.rb', line 63

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

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

Instance Method Details

#bundle_registration_codeObject

string



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

def bundle_registration_code
  @attributes[:bundle_registration_code]
end

#bundle_registration_code=(value) ⇒ Object



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

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

#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

#encoded_pathsObject

array(string)



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

def encoded_paths
  @attributes[:encoded_paths]
end

#encoded_paths=(value) ⇒ Object



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

def encoded_paths=(value)
  @attributes[:encoded_paths] = 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



48
49
50
51
52
53
54
55
56
57
# File 'lib/files.com/models/zip_download.rb', line 48

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

  @attributes = new_obj.attributes
  true
end