Class: ApiReference::AddAmendmentCreditLedgerEntryRequestParams

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb

Overview

AddAmendmentCreditLedgerEntryRequestParams Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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:, block_id:, metadata: SKIP, currency: SKIP, description: SKIP) ⇒ AddAmendmentCreditLedgerEntryRequestParams

Returns a new instance of AddAmendmentCreditLedgerEntryRequestParams.



74
75
76
77
78
79
80
81
82
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 74

def initialize(amount:, block_id:, metadata: SKIP, currency: SKIP,
               description: SKIP)
  @metadata =  unless  == SKIP
  @currency = currency unless currency == SKIP
  @description = description unless description == SKIP
  @entry_type = 'amendment'
  @amount = amount
  @block_id = block_id
end

Instance Attribute Details

#amountFloat

The number of credits to effect. Note that this is required for increment, decrement or void operations.

Returns:

  • (Float)


38
39
40
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 38

def amount
  @amount
end

#block_idString

The ID of the block to reverse a decrement from.

Returns:

  • (String)


42
43
44
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 42

def block_id
  @block_id
end

#currencyString

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.

Returns:

  • (String)


21
22
23
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 21

def currency
  @currency
end

#descriptionString

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.

Returns:

  • (String)


27
28
29
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 27

def description
  @description
end

#entry_typeString (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.

Returns:

  • (String)


33
34
35
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 33

def entry_type
  @entry_type
end

#metadataHash[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.

Returns:

  • (Hash[String, String])


16
17
18
# File 'lib/api_reference/models/add_amendment_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.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  block_id = hash.key?('block_id') ? hash['block_id'] : nil
   = hash.key?('metadata') ? hash['metadata'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP

  # Create object from extracted values.
  AddAmendmentCreditLedgerEntryRequestParams.new(amount: amount,
                                                 block_id: block_id,
                                                 metadata: ,
                                                 currency: currency,
                                                 description: description)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 45

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['block_id'] = 'block_id'
  @_hash
end

.nullablesObject

An array for nullable fields



66
67
68
69
70
71
72
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 66

def self.nullables
  %w[
    metadata
    currency
    description
  ]
end

.optionalsObject

An array for optional fields



57
58
59
60
61
62
63
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 57

def self.optionals
  %w[
    metadata
    currency
    description
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



105
106
107
108
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_amendment_credit_ledger_entry_request_params.rb', line 105

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 }) and
        APIHelper.valid_type?(value.block_id,
                              ->(val) { val.instance_of? String })
    )
  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 }) and
      APIHelper.valid_type?(value['block_id'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



137
138
139
140
141
142
# File 'lib/api_reference/models/add_amendment_credit_ledger_entry_request_params.rb', line 137

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}, block_id: #{@block_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



130
131
132
133
134
# File 'lib/api_reference/models/add_amendment_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}, block_id: #{@block_id}>"
end