Class: ApiReference::TopUp
- Defined in:
- lib/api_reference/models/top_up.rb
Overview
TopUp Model.
Instance Attribute Summary collapse
-
#amount ⇒ String
The amount to increment when the threshold is reached.
-
#currency ⇒ String
The currency or custom pricing unit to use for this top-up.
-
#expires_after ⇒ Integer
The number of days or months after which the top-up expires.
-
#expires_after_unit ⇒ ExpiresAfterUnit
The unit of expires_after.
-
#id ⇒ String
TODO: Write general description for this method.
-
#invoice_settings ⇒ TopUpInvoiceSettings2
Settings for invoices generated by triggered top-ups.
-
#per_unit_cost_basis ⇒ String
How much, in the customer's currency, to charge for each unit.
-
#threshold ⇒ String
The threshold at which to trigger the top-up.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(id:, currency:, threshold:, amount:, per_unit_cost_basis:, invoice_settings:, expires_after: SKIP, expires_after_unit: SKIP, additional_properties: nil) ⇒ TopUp
constructor
A new instance of TopUp.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id:, currency:, threshold:, amount:, per_unit_cost_basis:, invoice_settings:, expires_after: SKIP, expires_after_unit: SKIP, additional_properties: nil) ⇒ TopUp
Returns a new instance of TopUp.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/api_reference/models/top_up.rb', line 77 def initialize(id:, currency:, threshold:, amount:, per_unit_cost_basis:, invoice_settings:, expires_after: SKIP, expires_after_unit: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @currency = currency @threshold = threshold @amount = amount @per_unit_cost_basis = per_unit_cost_basis @invoice_settings = invoice_settings @expires_after = expires_after unless expires_after == SKIP @expires_after_unit = expires_after_unit unless expires_after_unit == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ String
The amount to increment when the threshold is reached.
28 29 30 |
# File 'lib/api_reference/models/top_up.rb', line 28 def amount @amount end |
#currency ⇒ String
The currency or custom pricing unit to use for this top-up. If this is a real-world currency, it must match the customer's invoicing currency.
19 20 21 |
# File 'lib/api_reference/models/top_up.rb', line 19 def currency @currency end |
#expires_after ⇒ Integer
The number of days or months after which the top-up expires. If unspecified, it does not expire.
41 42 43 |
# File 'lib/api_reference/models/top_up.rb', line 41 def expires_after @expires_after end |
#expires_after_unit ⇒ ExpiresAfterUnit
The unit of expires_after.
45 46 47 |
# File 'lib/api_reference/models/top_up.rb', line 45 def expires_after_unit @expires_after_unit end |
#id ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/api_reference/models/top_up.rb', line 14 def id @id end |
#invoice_settings ⇒ TopUpInvoiceSettings2
Settings for invoices generated by triggered top-ups.
36 37 38 |
# File 'lib/api_reference/models/top_up.rb', line 36 def invoice_settings @invoice_settings end |
#per_unit_cost_basis ⇒ String
How much, in the customer's currency, to charge for each unit.
32 33 34 |
# File 'lib/api_reference/models/top_up.rb', line 32 def per_unit_cost_basis @per_unit_cost_basis end |
#threshold ⇒ String
The threshold at which to trigger the top-up. If the balance is at or below this threshold, the top-up will be triggered.
24 25 26 |
# File 'lib/api_reference/models/top_up.rb', line 24 def threshold @threshold end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/api_reference/models/top_up.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil currency = hash.key?('currency') ? hash['currency'] : nil threshold = hash.key?('threshold') ? hash['threshold'] : nil amount = hash.key?('amount') ? hash['amount'] : nil per_unit_cost_basis = hash.key?('per_unit_cost_basis') ? hash['per_unit_cost_basis'] : nil invoice_settings = TopUpInvoiceSettings2.from_hash(hash['invoice_settings']) if hash['invoice_settings'] expires_after = hash.key?('expires_after') ? hash['expires_after'] : SKIP expires_after_unit = hash.key?('expires_after_unit') ? hash['expires_after_unit'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. TopUp.new(id: id, currency: currency, threshold: threshold, amount: amount, per_unit_cost_basis: per_unit_cost_basis, invoice_settings: invoice_settings, expires_after: expires_after, expires_after_unit: expires_after_unit, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/api_reference/models/top_up.rb', line 48 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['currency'] = 'currency' @_hash['threshold'] = 'threshold' @_hash['amount'] = 'amount' @_hash['per_unit_cost_basis'] = 'per_unit_cost_basis' @_hash['invoice_settings'] = 'invoice_settings' @_hash['expires_after'] = 'expires_after' @_hash['expires_after_unit'] = 'expires_after_unit' @_hash end |
.nullables ⇒ Object
An array for nullable fields
70 71 72 73 74 75 |
# File 'lib/api_reference/models/top_up.rb', line 70 def self.nullables %w[ expires_after expires_after_unit ] end |
.optionals ⇒ Object
An array for optional fields
62 63 64 65 66 67 |
# File 'lib/api_reference/models/top_up.rb', line 62 def self.optionals %w[ expires_after expires_after_unit ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
140 141 142 143 144 145 146 147 |
# File 'lib/api_reference/models/top_up.rb', line 140 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, currency: #{@currency.inspect}, threshold:"\ " #{@threshold.inspect}, amount: #{@amount.inspect}, per_unit_cost_basis:"\ " #{@per_unit_cost_basis.inspect}, invoice_settings: #{@invoice_settings.inspect},"\ " expires_after: #{@expires_after.inspect}, expires_after_unit:"\ " #{@expires_after_unit.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
131 132 133 134 135 136 137 |
# File 'lib/api_reference/models/top_up.rb', line 131 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, currency: #{@currency}, threshold: #{@threshold}, amount:"\ " #{@amount}, per_unit_cost_basis: #{@per_unit_cost_basis}, invoice_settings:"\ " #{@invoice_settings}, expires_after: #{@expires_after}, expires_after_unit:"\ " #{@expires_after_unit}, additional_properties: #{@additional_properties}>" end |