Class: Files::MoverPackage
- Inherits:
-
Object
- Object
- Files::MoverPackage
- Defined in:
- lib/files.com/models/mover_package.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
- .all(params = {}, options = {}) ⇒ Object
- .create_export(params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
-
.purchase(id, params = {}, options = {}) ⇒ Object
Purchase a Mover package for the current site.
Instance Method Summary collapse
-
#id ⇒ Object
int64 - Mover package ID.
-
#initialize(attributes = {}, options = {}) ⇒ MoverPackage
constructor
A new instance of MoverPackage.
-
#prepaid_bytes ⇒ Object
int64 - Total prepaid bytes included in this package.
-
#prepaid_expire_in_days ⇒ Object
int64 - Number of days this package is valid for after purchase.
-
#price ⇒ Object
decimal - Price of this mover package in the site's currency.
-
#purchase(params = {}) ⇒ Object
Purchase a Mover package for the current site.
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 = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/files.com/models/mover_package.rb', line 7 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/files.com/models/mover_package.rb', line 7 def @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 = {}, = {}) list(params, ) 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 = {}, = {}) response, = Api.send_request("/mover_packages/create_export", :post, params, ) Export.new(response.data, ) 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 = {}, = {}) 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, ) 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 = {}, = {}) 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, = Api.send_request("/mover_packages/#{params[:id]}/purchase", :post, params, ) MoverPackage.new(response.data, ) end |
Instance Method Details
#id ⇒ Object
int64 - Mover package ID
15 16 17 |
# File 'lib/files.com/models/mover_package.rb', line 15 def id @attributes[:id] end |
#prepaid_bytes ⇒ Object
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_days ⇒ Object
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 |
#price ⇒ Object
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 |