Class: ModernTreasury::LedgerEntryCreateRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ModernTreasury::LedgerEntryCreateRequest
- Defined in:
- lib/modern_treasury/models/ledger_entry_create_request.rb
Overview
LedgerEntryCreateRequest Model.
Instance Attribute Summary collapse
-
#amount ⇒ Integer
Value in specified currency’s smallest unit.
-
#available_balance_amount ⇒ Hash[String, Integer]
Use ‘gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the account’s available balance.
-
#direction ⇒ Direction5
One of ‘credit`, `debit`.
-
#ledger_account_id ⇒ UUID | String
The ledger account that this ledger entry is associated with.
-
#lock_version ⇒ Integer
Lock version of the ledger account.
-
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs.
-
#pending_balance_amount ⇒ Hash[String, Integer]
Use ‘gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the account’s pending balance.
-
#posted_balance_amount ⇒ Hash[String, Integer]
Use ‘gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the account’s posted balance.
-
#show_resulting_ledger_account_balances ⇒ TrueClass | FalseClass
If true, response will include the balance of the associated ledger account for the entry.
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(amount:, direction:, ledger_account_id:, lock_version: SKIP, pending_balance_amount: SKIP, posted_balance_amount: SKIP, available_balance_amount: SKIP, show_resulting_ledger_account_balances: SKIP, metadata: SKIP, additional_properties: nil) ⇒ LedgerEntryCreateRequest
constructor
A new instance of LedgerEntryCreateRequest.
-
#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:, direction:, ledger_account_id:, lock_version: SKIP, pending_balance_amount: SKIP, posted_balance_amount: SKIP, available_balance_amount: SKIP, show_resulting_ledger_account_balances: SKIP, metadata: SKIP, additional_properties: nil) ⇒ LedgerEntryCreateRequest
Returns a new instance of LedgerEntryCreateRequest.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 103 def initialize(amount:, direction:, ledger_account_id:, lock_version: SKIP, pending_balance_amount: SKIP, posted_balance_amount: SKIP, available_balance_amount: SKIP, show_resulting_ledger_account_balances: SKIP, metadata: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @amount = amount @direction = direction @ledger_account_id = ledger_account_id @lock_version = lock_version unless lock_version == SKIP @pending_balance_amount = pending_balance_amount unless pending_balance_amount == SKIP @posted_balance_amount = posted_balance_amount unless posted_balance_amount == SKIP @available_balance_amount = available_balance_amount unless available_balance_amount == SKIP unless show_resulting_ledger_account_balances == SKIP @show_resulting_ledger_account_balances = show_resulting_ledger_account_balances end @metadata = unless == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Integer
Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000. Can be any integer up to 36 digits.
15 16 17 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 15 def amount @amount end |
#available_balance_amount ⇒ Hash[String, Integer]
Use ‘gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the account’s available balance. If any of these conditions would be false after the transaction is created, the entire call will fail with error code 422.
52 53 54 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 52 def available_balance_amount @available_balance_amount end |
#direction ⇒ Direction5
One of ‘credit`, `debit`. Describes the direction money is flowing in the transaction. A `credit` moves money from your account to someone else’s. A ‘debit` pulls money from someone else’s account to your own. Note that wire, rtp, and check payments will always be ‘credit`.
22 23 24 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 22 def direction @direction end |
#ledger_account_id ⇒ UUID | String
The ledger account that this ledger entry is associated with.
26 27 28 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 26 def ledger_account_id @ledger_account_id end |
#lock_version ⇒ Integer
Lock version of the ledger account. This can be passed when creating a ledger transaction to only succeed if no ledger transactions have posted since the given version. See our post about Designing the Ledgers API with Optimistic Locking for more details.
33 34 35 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 33 def lock_version @lock_version end |
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs. Both the key and value must be strings.
62 63 64 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 62 def @metadata end |
#pending_balance_amount ⇒ Hash[String, Integer]
Use ‘gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the account’s pending balance. If any of these conditions would be false after the transaction is created, the entire call will fail with error code 422.
39 40 41 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 39 def pending_balance_amount @pending_balance_amount end |
#posted_balance_amount ⇒ Hash[String, Integer]
Use ‘gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the account’s posted balance. If any of these conditions would be false after the transaction is created, the entire call will fail with error code 422.
45 46 47 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 45 def posted_balance_amount @posted_balance_amount end |
#show_resulting_ledger_account_balances ⇒ TrueClass | FalseClass
If true, response will include the balance of the associated ledger account for the entry.
57 58 59 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 57 def show_resulting_ledger_account_balances @show_resulting_ledger_account_balances end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 127 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : nil direction = hash.key?('direction') ? hash['direction'] : nil ledger_account_id = hash.key?('ledger_account_id') ? hash['ledger_account_id'] : nil lock_version = hash.key?('lock_version') ? hash['lock_version'] : SKIP pending_balance_amount = hash.key?('pending_balance_amount') ? hash['pending_balance_amount'] : SKIP posted_balance_amount = hash.key?('posted_balance_amount') ? hash['posted_balance_amount'] : SKIP available_balance_amount = hash.key?('available_balance_amount') ? hash['available_balance_amount'] : SKIP show_resulting_ledger_account_balances = hash.key?('show_resulting_ledger_account_balances') ? hash['show_resulting_ledger_account_balances'] : SKIP = hash.key?('metadata') ? hash['metadata'] : 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. LedgerEntryCreateRequest.new(amount: amount, direction: direction, ledger_account_id: ledger_account_id, lock_version: lock_version, pending_balance_amount: pending_balance_amount, posted_balance_amount: posted_balance_amount, available_balance_amount: available_balance_amount, show_resulting_ledger_account_balances: show_resulting_ledger_account_balances, metadata: , additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 65 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['direction'] = 'direction' @_hash['ledger_account_id'] = 'ledger_account_id' @_hash['lock_version'] = 'lock_version' @_hash['pending_balance_amount'] = 'pending_balance_amount' @_hash['posted_balance_amount'] = 'posted_balance_amount' @_hash['available_balance_amount'] = 'available_balance_amount' @_hash['show_resulting_ledger_account_balances'] = 'show_resulting_ledger_account_balances' @_hash['metadata'] = 'metadata' @_hash end |
.nullables ⇒ Object
An array for nullable fields
93 94 95 96 97 98 99 100 101 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 93 def self.nullables %w[ lock_version pending_balance_amount posted_balance_amount available_balance_amount show_resulting_ledger_account_balances ] end |
.optionals ⇒ Object
An array for optional fields
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 81 def self.optionals %w[ lock_version pending_balance_amount posted_balance_amount available_balance_amount show_resulting_ledger_account_balances metadata ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
178 179 180 181 182 183 184 185 186 187 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 178 def inspect class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount.inspect}, direction: #{@direction.inspect},"\ " ledger_account_id: #{@ledger_account_id.inspect}, lock_version: #{@lock_version.inspect},"\ " pending_balance_amount: #{@pending_balance_amount.inspect}, posted_balance_amount:"\ " #{@posted_balance_amount.inspect}, available_balance_amount:"\ " #{@available_balance_amount.inspect}, show_resulting_ledger_account_balances:"\ " #{@show_resulting_ledger_account_balances.inspect}, metadata: #{@metadata.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
167 168 169 170 171 172 173 174 175 |
# File 'lib/modern_treasury/models/ledger_entry_create_request.rb', line 167 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, direction: #{@direction}, ledger_account_id:"\ " #{@ledger_account_id}, lock_version: #{@lock_version}, pending_balance_amount:"\ " #{@pending_balance_amount}, posted_balance_amount: #{@posted_balance_amount},"\ " available_balance_amount: #{@available_balance_amount},"\ " show_resulting_ledger_account_balances: #{@show_resulting_ledger_account_balances},"\ " metadata: #{@metadata}, additional_properties: #{@additional_properties}>" end |