Class: Files::MoverPackage

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of MoverPackage.



9
10
11
12
# File 'lib/files.com/models/mover_package.rb', line 9

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/files.com/models/mover_package.rb', line 7

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/files.com/models/mover_package.rb', line 7

def options
  @options
end

Class Method Details

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



60
61
62
# File 'lib/files.com/models/mover_package.rb', line 60

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

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



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

def self.create_export(params = {}, options = {})
  response, options = Api.send_request("/mover_packages/create_export", :post, params, options)
  Export.new(response.data, options)
end

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

Parameters:

cursor - string - Used for pagination.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10000, 1,000 or less is recommended).


51
52
53
54
55
56
57
58
# File 'lib/files.com/models/mover_package.rb', line 51

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer)

  List.new(MoverPackage, params) do
    Api.send_request("/mover_packages", :get, params, options)
  end
end

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

Purchase a Mover package for the current site



65
66
67
68
69
70
71
72
73
# File 'lib/files.com/models/mover_package.rb', line 65

def self.purchase(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/mover_packages/#{params[:id]}/purchase", :post, params, options)
  MoverPackage.new(response.data, options)
end

Instance Method Details

#idObject

int64 - Mover package ID



15
16
17
# File 'lib/files.com/models/mover_package.rb', line 15

def id
  @attributes[:id]
end

#prepaid_bytesObject

int64 - Total prepaid bytes included in this package



20
21
22
# File 'lib/files.com/models/mover_package.rb', line 20

def prepaid_bytes
  @attributes[:prepaid_bytes]
end

#prepaid_expire_in_daysObject

int64 - Number of days this package is valid for after purchase



25
26
27
# File 'lib/files.com/models/mover_package.rb', line 25

def prepaid_expire_in_days
  @attributes[:prepaid_expire_in_days]
end

#priceObject

decimal - Price of this mover package in the site's currency



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

def price
  value = @attributes[:price]
  return value if value.nil? || value.is_a?(BigDecimal)

  BigDecimal(value.to_s)
end

#purchase(params = {}) ⇒ Object

Purchase a Mover package for the current site



38
39
40
41
42
43
44
45
46
# File 'lib/files.com/models/mover_package.rb', line 38

def purchase(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[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

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