Class: ApiReference::AddIncrementCreditLedgerEntryRequestParams
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::AddIncrementCreditLedgerEntryRequestParams
- Defined in:
- lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb
Overview
AddIncrementCreditLedgerEntryRequestParams Model.
Instance Attribute Summary collapse
-
#amount ⇒ Float
The number of credits to effect.
-
#currency ⇒ String
The currency or custom pricing unit to use for this ledger entry.
-
#description ⇒ String
Optional metadata that can be specified when adding ledger results via the API.
-
#effective_date ⇒ Object
An ISO 8601 format date that denotes when this credit balance should become available for use.
-
#entry_type ⇒ String
readonly
Optional metadata that can be specified when adding ledger results via the API.
-
#expiry_date ⇒ Object
An ISO 8601 format date that denotes when this credit balance should expire.
-
#filters ⇒ Array[BlockPriceFilter]
Optional filter to specify which items this credit block applies to.
-
#invoice_settings ⇒ IncrementCreditLedgerEntryInvoiceSettings
Passing
invoice_settingsautomatically generates an invoice for the newly added credits. -
#metadata ⇒ Hash[String, String]
User-specified key/value pairs for the resource.
-
#per_unit_cost_basis ⇒ String
Can only be specified when entry_type=increment.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(amount:, metadata: SKIP, currency: SKIP, description: SKIP, expiry_date: SKIP, effective_date: SKIP, per_unit_cost_basis: SKIP, invoice_settings: SKIP, filters: SKIP, additional_properties: nil) ⇒ AddIncrementCreditLedgerEntryRequestParams
constructor
A new instance of AddIncrementCreditLedgerEntryRequestParams.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_union_type_effective_date ⇒ Object
- #to_union_type_expiry_date ⇒ 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(amount:, metadata: SKIP, currency: SKIP, description: SKIP, expiry_date: SKIP, effective_date: SKIP, per_unit_cost_basis: SKIP, invoice_settings: SKIP, filters: SKIP, additional_properties: nil) ⇒ AddIncrementCreditLedgerEntryRequestParams
Returns a new instance of AddIncrementCreditLedgerEntryRequestParams.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 111 def initialize(amount:, metadata: SKIP, currency: SKIP, description: SKIP, expiry_date: SKIP, effective_date: SKIP, per_unit_cost_basis: SKIP, invoice_settings: SKIP, filters: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @metadata = unless == SKIP @currency = currency unless currency == SKIP @description = description unless description == SKIP @entry_type = 'increment' @amount = amount @expiry_date = expiry_date unless expiry_date == SKIP @effective_date = effective_date unless effective_date == SKIP @per_unit_cost_basis = per_unit_cost_basis unless per_unit_cost_basis == SKIP @invoice_settings = invoice_settings unless invoice_settings == SKIP @filters = filters unless filters == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Float
The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations.
38 39 40 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 38 def amount @amount end |
#currency ⇒ String
The currency or custom pricing unit to use for this ledger entry. If this is a real-world currency, it must match the customer's invoicing currency.
21 22 23 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 21 def currency @currency end |
#description ⇒ String
Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc.
27 28 29 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 27 def description @description end |
#effective_date ⇒ Object
An ISO 8601 format date that denotes when this credit balance should become available for use.
48 49 50 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 48 def effective_date @effective_date end |
#entry_type ⇒ String (readonly)
Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc.
33 34 35 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 33 def entry_type @entry_type end |
#expiry_date ⇒ Object
An ISO 8601 format date that denotes when this credit balance should expire.
43 44 45 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 43 def expiry_date @expiry_date end |
#filters ⇒ Array[BlockPriceFilter]
Optional filter to specify which items this credit block applies to. If not specified, the block will apply to all items for the pricing unit.
65 66 67 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 65 def filters @filters end |
#invoice_settings ⇒ IncrementCreditLedgerEntryInvoiceSettings
Passing invoice_settings automatically generates an invoice for the
newly added credits. If invoice_settings is passed, you must specify
per_unit_cost_basis, as the calculation of the invoice total is done on
that basis.
60 61 62 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 60 def invoice_settings @invoice_settings end |
#metadata ⇒ Hash[String, String]
User-specified key/value pairs for the resource. Individual keys can be
removed by setting the value to null, and the entire metadata mapping
can be cleared by setting metadata to null.
16 17 18 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 16 def @metadata end |
#per_unit_cost_basis ⇒ String
Can only be specified when entry_type=increment. How much, in the customer's currency, a customer paid for a single credit in this block
53 54 55 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 53 def per_unit_cost_basis @per_unit_cost_basis end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 132 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : nil = hash.key?('metadata') ? hash['metadata'] : SKIP currency = hash.key?('currency') ? hash['currency'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP expiry_date = hash.key?('expiry_date') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:AddIncrementCreditLedgerEntryRequestParamsExpiryDate), hash['expiry_date'] ) : SKIP effective_date = hash.key?('effective_date') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:AddIncrementCreditLedgerEntryRequestParamsEffectiveDate), hash['effective_date'] ) : SKIP per_unit_cost_basis = hash.key?('per_unit_cost_basis') ? hash['per_unit_cost_basis'] : SKIP if hash['invoice_settings'] invoice_settings = IncrementCreditLedgerEntryInvoiceSettings.from_hash(hash['invoice_settings']) end # Parameter is an array, so we need to iterate through it filters = nil unless hash['filters'].nil? filters = [] hash['filters'].each do |structure| filters << (BlockPriceFilter.from_hash(structure) if structure) end end filters = SKIP unless hash.key?('filters') # 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. AddIncrementCreditLedgerEntryRequestParams.new(amount: amount, metadata: , currency: currency, description: description, expiry_date: expiry_date, effective_date: effective_date, per_unit_cost_basis: per_unit_cost_basis, invoice_settings: invoice_settings, filters: filters, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 68 def self.names @_hash = {} if @_hash.nil? @_hash['metadata'] = 'metadata' @_hash['currency'] = 'currency' @_hash['description'] = 'description' @_hash['entry_type'] = 'entry_type' @_hash['amount'] = 'amount' @_hash['expiry_date'] = 'expiry_date' @_hash['effective_date'] = 'effective_date' @_hash['per_unit_cost_basis'] = 'per_unit_cost_basis' @_hash['invoice_settings'] = 'invoice_settings' @_hash['filters'] = 'filters' @_hash end |
.nullables ⇒ Object
An array for nullable fields
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 98 def self.nullables %w[ metadata currency description expiry_date effective_date per_unit_cost_basis invoice_settings filters ] end |
.optionals ⇒ Object
An array for optional fields
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 84 def self.optionals %w[ metadata currency description expiry_date effective_date per_unit_cost_basis invoice_settings filters ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 196 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.entry_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.amount, ->(val) { val.instance_of? Float }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['entry_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? Float }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
227 228 229 230 231 232 233 234 235 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 227 def inspect class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata.inspect}, currency: #{@currency.inspect},"\ " description: #{@description.inspect}, entry_type: #{@entry_type.inspect}, amount:"\ " #{@amount.inspect}, expiry_date: #{@expiry_date.inspect}, effective_date:"\ " #{@effective_date.inspect}, per_unit_cost_basis: #{@per_unit_cost_basis.inspect},"\ " invoice_settings: #{@invoice_settings.inspect}, filters: #{@filters.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
217 218 219 220 221 222 223 224 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 217 def to_s class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata}, currency: #{@currency}, description:"\ " #{@description}, entry_type: #{@entry_type}, amount: #{@amount}, expiry_date:"\ " #{@expiry_date}, effective_date: #{@effective_date}, per_unit_cost_basis:"\ " #{@per_unit_cost_basis}, invoice_settings: #{@invoice_settings}, filters: #{@filters},"\ " additional_properties: #{@additional_properties}>" end |
#to_union_type_effective_date ⇒ Object
188 189 190 191 192 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 188 def to_union_type_effective_date UnionTypeLookUp.get(:AddIncrementCreditLedgerEntryRequestParamsEffectiveDate) .validate(effective_date) .serialize(effective_date) end |
#to_union_type_expiry_date ⇒ Object
182 183 184 185 186 |
# File 'lib/api_reference/models/add_increment_credit_ledger_entry_request_params.rb', line 182 def to_union_type_expiry_date UnionTypeLookUp.get(:AddIncrementCreditLedgerEntryRequestParamsExpiryDate) .validate(expiry_date) .serialize(expiry_date) end |