Class: ApiReference::NewAllocationPrice
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::NewAllocationPrice
- Defined in:
- lib/api_reference/models/new_allocation_price.rb
Overview
NewAllocationPrice Model.
Instance Attribute Summary collapse
-
#amount ⇒ String
An amount of the currency to allocate to the customer at the specified cadence.
-
#cadence ⇒ Cadence34
The cadence at which to allocate the amount to the customer.
-
#currency ⇒ String
An ISO 4217 currency string or a custom pricing unit identifier in which to bill this price.
-
#custom_expiration ⇒ CustomExpiration
The custom expiration for the allocation.
-
#expires_at_end_of_cadence ⇒ TrueClass | FalseClass
Whether the allocated amount should expire at the end of the cadence or roll over to the next period.
-
#filters ⇒ Array[BlockPriceFilter]
The filters that determine which items the allocation applies to.
-
#item_id ⇒ String
The item ID that line items representing charges for this allocation will be associated with.
-
#license_type_id ⇒ String
The license type ID to associate the price with license allocation.
-
#metadata ⇒ Hash[String, String]
User-specified key/value pairs for the resource.
-
#per_unit_cost_basis ⇒ String
The (per-unit) cost basis of each created block.
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(currency:, amount:, cadence:, metadata: SKIP, expires_at_end_of_cadence: SKIP, custom_expiration: SKIP, filters: SKIP, per_unit_cost_basis: '0.00', item_id: SKIP, license_type_id: SKIP, additional_properties: nil) ⇒ NewAllocationPrice
constructor
A new instance of NewAllocationPrice.
-
#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(currency:, amount:, cadence:, metadata: SKIP, expires_at_end_of_cadence: SKIP, custom_expiration: SKIP, filters: SKIP, per_unit_cost_basis: '0.00', item_id: SKIP, license_type_id: SKIP, additional_properties: nil) ⇒ NewAllocationPrice
Returns a new instance of NewAllocationPrice.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 102 def initialize(currency:, amount:, cadence:, metadata: SKIP, expires_at_end_of_cadence: SKIP, custom_expiration: SKIP, filters: SKIP, per_unit_cost_basis: '0.00', item_id: SKIP, license_type_id: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @metadata = unless == SKIP @currency = currency @amount = amount @cadence = cadence unless expires_at_end_of_cadence == SKIP @expires_at_end_of_cadence = expires_at_end_of_cadence end @custom_expiration = custom_expiration unless custom_expiration == SKIP @filters = filters unless filters == SKIP @per_unit_cost_basis = per_unit_cost_basis unless per_unit_cost_basis == SKIP @item_id = item_id unless item_id == SKIP @license_type_id = license_type_id unless license_type_id == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ String
An amount of the currency to allocate to the customer at the specified cadence.
26 27 28 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 26 def amount @amount end |
#cadence ⇒ Cadence34
The cadence at which to allocate the amount to the customer.
30 31 32 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 30 def cadence @cadence end |
#currency ⇒ String
An ISO 4217 currency string or a custom pricing unit identifier in which to bill this price.
21 22 23 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 21 def currency @currency end |
#custom_expiration ⇒ CustomExpiration
The custom expiration for the allocation.
39 40 41 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 39 def custom_expiration @custom_expiration end |
#expires_at_end_of_cadence ⇒ TrueClass | FalseClass
Whether the allocated amount should expire at the end of the cadence or roll over to the next period. Set to null if using custom_expiration.
35 36 37 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 35 def expires_at_end_of_cadence @expires_at_end_of_cadence end |
#filters ⇒ Array[BlockPriceFilter]
The filters that determine which items the allocation applies to.
43 44 45 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 43 def filters @filters end |
#item_id ⇒ String
The item ID that line items representing charges for this allocation will be associated with. If not provided, the default allocation item for the currency will be used (e.g. 'Included Allocation (USD)').
55 56 57 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 55 def item_id @item_id end |
#license_type_id ⇒ String
The license type ID to associate the price with license allocation.
59 60 61 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 59 def license_type_id @license_type_id 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/new_allocation_price.rb', line 16 def @metadata end |
#per_unit_cost_basis ⇒ String
The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced according to the quantity and per unit cost basis specified for the allocation each cadence.
49 50 51 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 49 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.
126 127 128 129 130 131 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 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 126 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. currency = hash.key?('currency') ? hash['currency'] : nil amount = hash.key?('amount') ? hash['amount'] : nil cadence = hash.key?('cadence') ? hash['cadence'] : nil = hash.key?('metadata') ? hash['metadata'] : SKIP expires_at_end_of_cadence = hash.key?('expires_at_end_of_cadence') ? hash['expires_at_end_of_cadence'] : SKIP custom_expiration = CustomExpiration.from_hash(hash['custom_expiration']) if hash['custom_expiration'] # 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') per_unit_cost_basis = hash['per_unit_cost_basis'] ||= '0.00' item_id = hash.key?('item_id') ? hash['item_id'] : SKIP license_type_id = hash.key?('license_type_id') ? hash['license_type_id'] : 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. NewAllocationPrice.new(currency: currency, amount: amount, cadence: cadence, metadata: , expires_at_end_of_cadence: expires_at_end_of_cadence, custom_expiration: custom_expiration, filters: filters, per_unit_cost_basis: per_unit_cost_basis, item_id: item_id, license_type_id: license_type_id, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 62 def self.names @_hash = {} if @_hash.nil? @_hash['metadata'] = 'metadata' @_hash['currency'] = 'currency' @_hash['amount'] = 'amount' @_hash['cadence'] = 'cadence' @_hash['expires_at_end_of_cadence'] = 'expires_at_end_of_cadence' @_hash['custom_expiration'] = 'custom_expiration' @_hash['filters'] = 'filters' @_hash['per_unit_cost_basis'] = 'per_unit_cost_basis' @_hash['item_id'] = 'item_id' @_hash['license_type_id'] = 'license_type_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 91 def self.nullables %w[ metadata expires_at_end_of_cadence custom_expiration filters item_id license_type_id ] end |
.optionals ⇒ Object
An array for optional fields
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 78 def self.optionals %w[ metadata expires_at_end_of_cadence custom_expiration filters per_unit_cost_basis item_id license_type_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 176 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.currency, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.cadence, ->(val) { Cadence34.validate(val) }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['currency'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['cadence'], ->(val) { Cadence34.validate(val) }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
211 212 213 214 215 216 217 218 219 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 211 def inspect class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata.inspect}, currency: #{@currency.inspect}, amount:"\ " #{@amount.inspect}, cadence: #{@cadence.inspect}, expires_at_end_of_cadence:"\ " #{@expires_at_end_of_cadence.inspect}, custom_expiration: #{@custom_expiration.inspect},"\ " filters: #{@filters.inspect}, per_unit_cost_basis: #{@per_unit_cost_basis.inspect},"\ " item_id: #{@item_id.inspect}, license_type_id: #{@license_type_id.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
201 202 203 204 205 206 207 208 |
# File 'lib/api_reference/models/new_allocation_price.rb', line 201 def to_s class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata}, currency: #{@currency}, amount: #{@amount},"\ " cadence: #{@cadence}, expires_at_end_of_cadence: #{@expires_at_end_of_cadence},"\ " custom_expiration: #{@custom_expiration}, filters: #{@filters}, per_unit_cost_basis:"\ " #{@per_unit_cost_basis}, item_id: #{@item_id}, license_type_id: #{@license_type_id},"\ " additional_properties: #{@additional_properties}>" end |