Class: ModernTreasury::ReversalCreateRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ModernTreasury::ReversalCreateRequest
- Defined in:
- lib/modern_treasury/models/reversal_create_request.rb
Overview
ReversalCreateRequest Model.
Instance Attribute Summary collapse
-
#ledger_transaction ⇒ LedgerTransactionCreateRequest
Additional data represented as key-value pairs.
-
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs.
-
#reason ⇒ Reason1
The reason for the reversal.
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(reason:, metadata: SKIP, ledger_transaction: SKIP, additional_properties: nil) ⇒ ReversalCreateRequest
constructor
A new instance of ReversalCreateRequest.
-
#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(reason:, metadata: SKIP, ledger_transaction: SKIP, additional_properties: nil) ⇒ ReversalCreateRequest
Returns a new instance of ReversalCreateRequest.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 50 def initialize(reason:, metadata: SKIP, ledger_transaction: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @reason = reason @metadata = unless == SKIP @ledger_transaction = ledger_transaction unless ledger_transaction == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#ledger_transaction ⇒ LedgerTransactionCreateRequest
Additional data represented as key-value pairs. Both the key and value must be strings.
26 27 28 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 26 def ledger_transaction @ledger_transaction end |
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs. Both the key and value must be strings.
21 22 23 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 21 def @metadata end |
#reason ⇒ Reason1
The reason for the reversal. Must be one of ‘duplicate`, `incorrect_amount`, `incorrect_receiving_account`, `date_earlier_than_intended`, `date_later_than_intended`.
16 17 18 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 16 def reason @reason end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. reason = hash.key?('reason') ? hash['reason'] : nil = hash.key?('metadata') ? hash['metadata'] : SKIP ledger_transaction = LedgerTransactionCreateRequest.from_hash(hash['ledger_transaction']) if hash['ledger_transaction'] # 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. ReversalCreateRequest.new(reason: reason, metadata: , ledger_transaction: ledger_transaction, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['reason'] = 'reason' @_hash['metadata'] = 'metadata' @_hash['ledger_transaction'] = 'ledger_transaction' @_hash end |
.nullables ⇒ Object
An array for nullable fields
46 47 48 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 46 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
38 39 40 41 42 43 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 38 def self.optionals %w[ metadata ledger_transaction ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
93 94 95 96 97 98 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 93 def inspect class_name = self.class.name.split('::').last "<#{class_name} reason: #{@reason.inspect}, metadata: #{@metadata.inspect},"\ " ledger_transaction: #{@ledger_transaction.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
86 87 88 89 90 |
# File 'lib/modern_treasury/models/reversal_create_request.rb', line 86 def to_s class_name = self.class.name.split('::').last "<#{class_name} reason: #{@reason}, metadata: #{@metadata}, ledger_transaction:"\ " #{@ledger_transaction}, additional_properties: #{@additional_properties}>" end |