Class: ApiReference::AddDecrementCreditLedgerEntryRequestParams
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::AddDecrementCreditLedgerEntryRequestParams
- Defined in:
- lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb
Overview
AddDecrementCreditLedgerEntryRequestParams 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.
-
#entry_type ⇒ String
readonly
Optional metadata that can be specified when adding ledger results via the API.
-
#metadata ⇒ Hash[String, String]
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.
-
.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, additional_properties: nil) ⇒ AddDecrementCreditLedgerEntryRequestParams
constructor
A new instance of AddDecrementCreditLedgerEntryRequestParams.
-
#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(amount:, metadata: SKIP, currency: SKIP, description: SKIP, additional_properties: nil) ⇒ AddDecrementCreditLedgerEntryRequestParams
Returns a new instance of AddDecrementCreditLedgerEntryRequestParams.
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 69 def initialize(amount:, metadata: SKIP, currency: SKIP, description: 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 = 'decrement' @amount = amount @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_decrement_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_decrement_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_decrement_credit_ledger_entry_request_params.rb', line 27 def description @description 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_decrement_credit_ledger_entry_request_params.rb', line 33 def entry_type @entry_type 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_decrement_credit_ledger_entry_request_params.rb', line 16 def @metadata end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 83 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 # 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. AddDecrementCreditLedgerEntryRequestParams.new(amount: amount, metadata: , currency: currency, description: description, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 41 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 end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 64 65 66 67 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 61 def self.nullables %w[ metadata currency description ] end |
.optionals ⇒ Object
An array for optional fields
52 53 54 55 56 57 58 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 52 def self.optionals %w[ metadata currency description ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 109 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.
138 139 140 141 142 143 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 138 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}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
130 131 132 133 134 135 |
# File 'lib/api_reference/models/add_decrement_credit_ledger_entry_request_params.rb', line 130 def to_s class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata}, currency: #{@currency}, description:"\ " #{@description}, entry_type: #{@entry_type}, amount: #{@amount}, additional_properties:"\ " #{@additional_properties}>" end |