Class: ApiReference::AddVoidCreditLedgerEntryRequestParams

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

Overview

AddVoidCreditLedgerEntryRequestParams 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(block_id:, amount:, metadata: SKIP, currency: SKIP, description: SKIP, void_reason: SKIP, additional_properties: nil) ⇒ AddVoidCreditLedgerEntryRequestParams

Returns a new instance of AddVoidCreditLedgerEntryRequestParams.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 81

def initialize(block_id:, amount:, metadata: SKIP, currency: SKIP,
               description: SKIP, void_reason: 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 = 'void'
  @block_id = block_id
  @void_reason = void_reason unless void_reason == SKIP
  @amount = amount
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

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

Returns:

  • (Float)


46
47
48
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 46

def amount
  @amount
end

#block_idString

The ID of the block to void.

Returns:

  • (String)


37
38
39
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 37

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_void_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_void_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_void_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_void_credit_ledger_entry_request_params.rb', line 16

def 
  @metadata
end

#void_reasonVoidReason

Can only be specified when entry_type=void. The reason for the void.

Returns:



41
42
43
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 41

def void_reason
  @void_reason
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 98

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  block_id = hash.key?('block_id') ? hash['block_id'] : nil
  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
  void_reason = hash.key?('void_reason') ? hash['void_reason'] : 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.
  AddVoidCreditLedgerEntryRequestParams.new(block_id: block_id,
                                            amount: amount,
                                            metadata: ,
                                            currency: currency,
                                            description: description,
                                            void_reason: void_reason,
                                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 49

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['metadata'] = 'metadata'
  @_hash['currency'] = 'currency'
  @_hash['description'] = 'description'
  @_hash['entry_type'] = 'entry_type'
  @_hash['block_id'] = 'block_id'
  @_hash['void_reason'] = 'void_reason'
  @_hash['amount'] = 'amount'
  @_hash
end

.nullablesObject

An array for nullable fields



72
73
74
75
76
77
78
79
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 72

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

.optionalsObject

An array for optional fields



62
63
64
65
66
67
68
69
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 62

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 128

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



161
162
163
164
165
166
167
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 161

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

#to_sObject

Provides a human-readable string representation of the object.



153
154
155
156
157
158
# File 'lib/api_reference/models/add_void_credit_ledger_entry_request_params.rb', line 153

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} metadata: #{@metadata}, currency: #{@currency}, description:"\
  " #{@description}, entry_type: #{@entry_type}, block_id: #{@block_id}, void_reason:"\
  " #{@void_reason}, amount: #{@amount}, additional_properties: #{@additional_properties}>"
end