Class: ApiReference::CustomerCreditBalance
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::CustomerCreditBalance
- Defined in:
- lib/api_reference/models/customer_credit_balance.rb
Overview
CustomerCreditBalance Model.
Instance Attribute Summary collapse
-
#balance ⇒ Float
User specified key-value pairs for the resource.
-
#credit_allocation ⇒ CreditBlockAllocation
The credit allocation this block was created from, including the catalog item it was allocated for.
-
#credit_block_source ⇒ CreditBlockSource
How this credit block was created:
allocation(a subscription's recurring credit allocation),top_up(an automatic balance-threshold top-up), ormanual(a manual credit ledger increment, including credits voided or expired off another block). -
#effective_date ⇒ DateTime
User specified key-value pairs for the resource.
-
#expiry_date ⇒ DateTime
User specified key-value pairs for the resource.
-
#filters ⇒ Array[BlockPriceFilter]
User specified key-value pairs for the resource.
-
#id ⇒ String
User specified key-value pairs for the resource.
-
#maximum_initial_balance ⇒ Float
User specified key-value pairs for the resource.
-
#metadata ⇒ Hash[String, String]
User specified key-value pairs for the resource.
-
#per_unit_cost_basis ⇒ String
User specified key-value pairs for the resource.
-
#status ⇒ Status3
User specified key-value pairs for the resource.
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(metadata:, id:, balance:, effective_date:, expiry_date:, per_unit_cost_basis:, status:, maximum_initial_balance:, filters:, credit_block_source:, credit_allocation: SKIP, additional_properties: nil) ⇒ CustomerCreditBalance
constructor
A new instance of CustomerCreditBalance.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_effective_date ⇒ Object
- #to_custom_expiry_date ⇒ Object
-
#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(metadata:, id:, balance:, effective_date:, expiry_date:, per_unit_cost_basis:, status:, maximum_initial_balance:, filters:, credit_block_source:, credit_allocation: SKIP, additional_properties: nil) ⇒ CustomerCreditBalance
Returns a new instance of CustomerCreditBalance.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 123 def initialize(metadata:, id:, balance:, effective_date:, expiry_date:, per_unit_cost_basis:, status:, maximum_initial_balance:, filters:, credit_block_source:, credit_allocation: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @metadata = @id = id @balance = balance @effective_date = effective_date @expiry_date = expiry_date @per_unit_cost_basis = per_unit_cost_basis @status = status @maximum_initial_balance = maximum_initial_balance @filters = filters @credit_block_source = credit_block_source @credit_allocation = credit_allocation unless credit_allocation == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#balance ⇒ Float
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
32 33 34 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 32 def balance @balance end |
#credit_allocation ⇒ CreditBlockAllocation
The credit allocation this block was created from, including the catalog item it was allocated for. Null for blocks not created via an allocation.
86 87 88 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 86 def credit_allocation @credit_allocation end |
#credit_block_source ⇒ CreditBlockSource
How this credit block was created: allocation (a subscription's
recurring credit allocation), top_up (an automatic balance-threshold
top-up), or manual (a manual credit ledger increment, including credits
voided or expired off another block).
81 82 83 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 81 def credit_block_source @credit_block_source end |
#effective_date ⇒ DateTime
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
39 40 41 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 39 def effective_date @effective_date end |
#expiry_date ⇒ DateTime
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
46 47 48 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 46 def expiry_date @expiry_date end |
#filters ⇒ Array[BlockPriceFilter]
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
74 75 76 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 74 def filters @filters end |
#id ⇒ String
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
25 26 27 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 25 def id @id end |
#maximum_initial_balance ⇒ Float
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
67 68 69 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 67 def maximum_initial_balance @maximum_initial_balance end |
#metadata ⇒ Hash[String, String]
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
18 19 20 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 18 def @metadata end |
#per_unit_cost_basis ⇒ String
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
53 54 55 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 53 def per_unit_cost_basis @per_unit_cost_basis end |
#status ⇒ Status3
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
60 61 62 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 60 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 145 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = hash.key?('metadata') ? hash['metadata'] : nil id = hash.key?('id') ? hash['id'] : nil balance = hash.key?('balance') ? hash['balance'] : nil effective_date = if hash.key?('effective_date') (DateTimeHelper.from_rfc3339(hash['effective_date']) if hash['effective_date']) end expiry_date = if hash.key?('expiry_date') (DateTimeHelper.from_rfc3339(hash['expiry_date']) if hash['expiry_date']) end per_unit_cost_basis = hash.key?('per_unit_cost_basis') ? hash['per_unit_cost_basis'] : nil status = hash.key?('status') ? hash['status'] : nil maximum_initial_balance = hash.key?('maximum_initial_balance') ? hash['maximum_initial_balance'] : nil # 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 = nil unless hash.key?('filters') credit_block_source = hash.key?('credit_block_source') ? hash['credit_block_source'] : nil credit_allocation = CreditBlockAllocation.from_hash(hash['credit_allocation']) if hash['credit_allocation'] # 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. CustomerCreditBalance.new(metadata: , id: id, balance: balance, effective_date: effective_date, expiry_date: expiry_date, per_unit_cost_basis: per_unit_cost_basis, status: status, maximum_initial_balance: maximum_initial_balance, filters: filters, credit_block_source: credit_block_source, credit_allocation: credit_allocation, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 89 def self.names @_hash = {} if @_hash.nil? @_hash['metadata'] = 'metadata' @_hash['id'] = 'id' @_hash['balance'] = 'balance' @_hash['effective_date'] = 'effective_date' @_hash['expiry_date'] = 'expiry_date' @_hash['per_unit_cost_basis'] = 'per_unit_cost_basis' @_hash['status'] = 'status' @_hash['maximum_initial_balance'] = 'maximum_initial_balance' @_hash['filters'] = 'filters' @_hash['credit_block_source'] = 'credit_block_source' @_hash['credit_allocation'] = 'credit_allocation' @_hash end |
.nullables ⇒ Object
An array for nullable fields
113 114 115 116 117 118 119 120 121 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 113 def self.nullables %w[ effective_date expiry_date per_unit_cost_basis maximum_initial_balance credit_allocation ] end |
.optionals ⇒ Object
An array for optional fields
106 107 108 109 110 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 106 def self.optionals %w[ credit_allocation ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
220 221 222 223 224 225 226 227 228 229 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 220 def inspect class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata.inspect}, id: #{@id.inspect}, balance:"\ " #{@balance.inspect}, effective_date: #{@effective_date.inspect}, expiry_date:"\ " #{@expiry_date.inspect}, per_unit_cost_basis: #{@per_unit_cost_basis.inspect}, status:"\ " #{@status.inspect}, maximum_initial_balance: #{@maximum_initial_balance.inspect}, filters:"\ " #{@filters.inspect}, credit_block_source: #{@credit_block_source.inspect},"\ " credit_allocation: #{@credit_allocation.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_effective_date ⇒ Object
200 201 202 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 200 def to_custom_effective_date DateTimeHelper.to_rfc3339(effective_date) end |
#to_custom_expiry_date ⇒ Object
204 205 206 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 204 def to_custom_expiry_date DateTimeHelper.to_rfc3339(expiry_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
209 210 211 212 213 214 215 216 217 |
# File 'lib/api_reference/models/customer_credit_balance.rb', line 209 def to_s class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata}, id: #{@id}, balance: #{@balance}, effective_date:"\ " #{@effective_date}, expiry_date: #{@expiry_date}, per_unit_cost_basis:"\ " #{@per_unit_cost_basis}, status: #{@status}, maximum_initial_balance:"\ " #{@maximum_initial_balance}, filters: #{@filters}, credit_block_source:"\ " #{@credit_block_source}, credit_allocation: #{@credit_allocation}, additional_properties:"\ " #{@additional_properties}>" end |