Class: ModernTreasury::Return
- Defined in:
- lib/modern_treasury/models/mreturn.rb
Overview
Return Model.
Instance Attribute Summary collapse
-
#additional_information ⇒ String
Some returns may include additional information from the bank.
-
#amount ⇒ Integer
Value in specified currency’s smallest unit.
-
#code ⇒ Code1
The return code.
-
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#currency ⇒ Currency
Three-letter ISO currency code.
-
#current_return ⇒ Return
The role of the return, can be ‘originating` or `receiving`.
-
#date_of_death ⇒ Date
If the return code is ‘R14` or `R15` this is the date the deceased counterparty passed away.
-
#failure_reason ⇒ String
If an originating return failed to be processed by the bank, a description of the failure reason will be available.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#internal_account_id ⇒ UUID | String
The ID of the relevant Internal Account.
-
#ledger_transaction_id ⇒ UUID | String
The ID of the ledger transaction linked to the return.
-
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#object ⇒ String
TODO: Write general description for this method.
-
#reason ⇒ String
Often the bank will provide an explanation for the return, which is a short human readable string.
-
#reference_numbers ⇒ Array[PaymentReference]
An array of Payment Reference objects.
-
#returnable_id ⇒ UUID | String
The ID of the object being returned or ‘null`.
-
#returnable_type ⇒ ReturnableType
The type of object being returned or ‘null`.
-
#role ⇒ Role
The role of the return, can be ‘originating` or `receiving`.
-
#status ⇒ Status4
The current status of the return.
-
#transaction_id ⇒ UUID | String
The ID of the relevant Transaction or ‘null`.
-
#transaction_line_item_id ⇒ UUID | String
The ID of the relevant Transaction Line Item or ‘null`.
-
#type ⇒ Type6
The type of return.
-
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
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(id:, object:, live_mode:, created_at:, updated_at:, returnable_id:, returnable_type:, code:, reason:, date_of_death:, additional_information:, status:, transaction_line_item_id:, transaction_id:, internal_account_id:, type:, amount:, currency:, failure_reason:, role:, current_return:, reference_numbers:, ledger_transaction_id:) ⇒ Return
constructor
A new instance of Return.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_updated_at ⇒ Object
-
#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(id:, object:, live_mode:, created_at:, updated_at:, returnable_id:, returnable_type:, code:, reason:, date_of_death:, additional_information:, status:, transaction_line_item_id:, transaction_id:, internal_account_id:, type:, amount:, currency:, failure_reason:, role:, current_return:, reference_numbers:, ledger_transaction_id:) ⇒ Return
Returns a new instance of Return.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/modern_treasury/models/mreturn.rb', line 165 def initialize(id:, object:, live_mode:, created_at:, updated_at:, returnable_id:, returnable_type:, code:, reason:, date_of_death:, additional_information:, status:, transaction_line_item_id:, transaction_id:, internal_account_id:, type:, amount:, currency:, failure_reason:, role:, current_return:, reference_numbers:, ledger_transaction_id:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @returnable_id = returnable_id @returnable_type = returnable_type @code = code @reason = reason @date_of_death = date_of_death @additional_information = additional_information @status = status @transaction_line_item_id = transaction_line_item_id @transaction_id = transaction_id @internal_account_id = internal_account_id @type = type @amount = amount @currency = currency @failure_reason = failure_reason @role = role @current_return = current_return @reference_numbers = reference_numbers @ledger_transaction_id = ledger_transaction_id end |
Instance Attribute Details
#additional_information ⇒ String
Some returns may include additional information from the bank. In these cases, this string will be present.
61 62 63 |
# File 'lib/modern_treasury/models/mreturn.rb', line 61 def additional_information @additional_information end |
#amount ⇒ Integer
Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000.
87 88 89 |
# File 'lib/modern_treasury/models/mreturn.rb', line 87 def amount @amount end |
#code ⇒ Code1
The return code. For ACH returns, this is the required ACH return code.
46 47 48 |
# File 'lib/modern_treasury/models/mreturn.rb', line 46 def code @code end |
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
29 30 31 |
# File 'lib/modern_treasury/models/mreturn.rb', line 29 def created_at @created_at end |
#currency ⇒ Currency
Three-letter ISO currency code.
91 92 93 |
# File 'lib/modern_treasury/models/mreturn.rb', line 91 def currency @currency end |
#current_return ⇒ Return
The role of the return, can be ‘originating` or `receiving`.
104 105 106 |
# File 'lib/modern_treasury/models/mreturn.rb', line 104 def current_return @current_return end |
#date_of_death ⇒ Date
If the return code is ‘R14` or `R15` this is the date the deceased counterparty passed away.
56 57 58 |
# File 'lib/modern_treasury/models/mreturn.rb', line 56 def date_of_death @date_of_death end |
#failure_reason ⇒ String
If an originating return failed to be processed by the bank, a description of the failure reason will be available.
96 97 98 |
# File 'lib/modern_treasury/models/mreturn.rb', line 96 def failure_reason @failure_reason end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/mreturn.rb', line 15 def id @id end |
#internal_account_id ⇒ UUID | String
The ID of the relevant Internal Account.
77 78 79 |
# File 'lib/modern_treasury/models/mreturn.rb', line 77 def internal_account_id @internal_account_id end |
#ledger_transaction_id ⇒ UUID | String
The ID of the ledger transaction linked to the return.
112 113 114 |
# File 'lib/modern_treasury/models/mreturn.rb', line 112 def ledger_transaction_id @ledger_transaction_id end |
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
24 25 26 |
# File 'lib/modern_treasury/models/mreturn.rb', line 24 def live_mode @live_mode end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/mreturn.rb', line 19 def object @object end |
#reason ⇒ String
Often the bank will provide an explanation for the return, which is a short human readable string.
51 52 53 |
# File 'lib/modern_treasury/models/mreturn.rb', line 51 def reason @reason end |
#reference_numbers ⇒ Array[PaymentReference]
An array of Payment Reference objects.
108 109 110 |
# File 'lib/modern_treasury/models/mreturn.rb', line 108 def reference_numbers @reference_numbers end |
#returnable_id ⇒ UUID | String
The ID of the object being returned or ‘null`.
38 39 40 |
# File 'lib/modern_treasury/models/mreturn.rb', line 38 def returnable_id @returnable_id end |
#returnable_type ⇒ ReturnableType
The type of object being returned or ‘null`.
42 43 44 |
# File 'lib/modern_treasury/models/mreturn.rb', line 42 def returnable_type @returnable_type end |
#role ⇒ Role
The role of the return, can be ‘originating` or `receiving`.
100 101 102 |
# File 'lib/modern_treasury/models/mreturn.rb', line 100 def role @role end |
#status ⇒ Status4
The current status of the return.
65 66 67 |
# File 'lib/modern_treasury/models/mreturn.rb', line 65 def status @status end |
#transaction_id ⇒ UUID | String
The ID of the relevant Transaction or ‘null`.
73 74 75 |
# File 'lib/modern_treasury/models/mreturn.rb', line 73 def transaction_id @transaction_id end |
#transaction_line_item_id ⇒ UUID | String
The ID of the relevant Transaction Line Item or ‘null`.
69 70 71 |
# File 'lib/modern_treasury/models/mreturn.rb', line 69 def transaction_line_item_id @transaction_line_item_id end |
#type ⇒ Type6
The type of return. Can be one of: ‘ach`, `ach_noc`, `au_becs`, `bacs`, `eft`, `interac`, `manual`, `paper_item`, `wire`.
82 83 84 |
# File 'lib/modern_treasury/models/mreturn.rb', line 82 def type @type end |
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
34 35 36 |
# File 'lib/modern_treasury/models/mreturn.rb', line 34 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/modern_treasury/models/mreturn.rb', line 198 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil object = hash.key?('object') ? hash['object'] : nil live_mode = hash.key?('live_mode') ? hash['live_mode'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) end returnable_id = hash.key?('returnable_id') ? hash['returnable_id'] : nil returnable_type = hash.key?('returnable_type') ? hash['returnable_type'] : nil code = hash.key?('code') ? hash['code'] : nil reason = hash.key?('reason') ? hash['reason'] : nil date_of_death = hash.key?('date_of_death') ? hash['date_of_death'] : nil additional_information = hash.key?('additional_information') ? hash['additional_information'] : nil status = hash.key?('status') ? hash['status'] : nil transaction_line_item_id = hash.key?('transaction_line_item_id') ? hash['transaction_line_item_id'] : nil transaction_id = hash.key?('transaction_id') ? hash['transaction_id'] : nil internal_account_id = hash.key?('internal_account_id') ? hash['internal_account_id'] : nil type = hash.key?('type') ? hash['type'] : nil amount = hash.key?('amount') ? hash['amount'] : nil currency = hash.key?('currency') ? hash['currency'] : nil failure_reason = hash.key?('failure_reason') ? hash['failure_reason'] : nil role = hash.key?('role') ? hash['role'] : nil current_return = Return.from_hash(hash['current_return']) if hash['current_return'] # Parameter is an array, so we need to iterate through it reference_numbers = nil unless hash['reference_numbers'].nil? reference_numbers = [] hash['reference_numbers'].each do |structure| reference_numbers << (PaymentReference.from_hash(structure) if structure) end end reference_numbers = nil unless hash.key?('reference_numbers') ledger_transaction_id = hash.key?('ledger_transaction_id') ? hash['ledger_transaction_id'] : nil # Create object from extracted values. Return.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, returnable_id: returnable_id, returnable_type: returnable_type, code: code, reason: reason, date_of_death: date_of_death, additional_information: additional_information, status: status, transaction_line_item_id: transaction_line_item_id, transaction_id: transaction_id, internal_account_id: internal_account_id, type: type, amount: amount, currency: currency, failure_reason: failure_reason, role: role, current_return: current_return, reference_numbers: reference_numbers, ledger_transaction_id: ledger_transaction_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/modern_treasury/models/mreturn.rb', line 115 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['object'] = 'object' @_hash['live_mode'] = 'live_mode' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['returnable_id'] = 'returnable_id' @_hash['returnable_type'] = 'returnable_type' @_hash['code'] = 'code' @_hash['reason'] = 'reason' @_hash['date_of_death'] = 'date_of_death' @_hash['additional_information'] = 'additional_information' @_hash['status'] = 'status' @_hash['transaction_line_item_id'] = 'transaction_line_item_id' @_hash['transaction_id'] = 'transaction_id' @_hash['internal_account_id'] = 'internal_account_id' @_hash['type'] = 'type' @_hash['amount'] = 'amount' @_hash['currency'] = 'currency' @_hash['failure_reason'] = 'failure_reason' @_hash['role'] = 'role' @_hash['current_return'] = 'current_return' @_hash['reference_numbers'] = 'reference_numbers' @_hash['ledger_transaction_id'] = 'ledger_transaction_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/modern_treasury/models/mreturn.rb', line 149 def self.nullables %w[ returnable_id returnable_type code reason date_of_death additional_information transaction_line_item_id transaction_id internal_account_id failure_reason ledger_transaction_id ] end |
.optionals ⇒ Object
An array for optional fields
144 145 146 |
# File 'lib/modern_treasury/models/mreturn.rb', line 144 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/modern_treasury/models/mreturn.rb', line 282 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.object, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.live_mode, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.created_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.updated_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.returnable_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.returnable_type, ->(val) { ReturnableType.validate(val) }) and APIHelper.valid_type?(value.code, ->(val) { Code1.validate(val) }) and APIHelper.valid_type?(value.reason, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.date_of_death, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.additional_information, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.status, ->(val) { Status4.validate(val) }) and APIHelper.valid_type?(value.transaction_line_item_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.transaction_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.internal_account_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.type, ->(val) { Type6.validate(val) }) and APIHelper.valid_type?(value.amount, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.currency, ->(val) { Currency.validate(val) }) and APIHelper.valid_type?(value.failure_reason, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.role, ->(val) { Role.validate(val) }) and APIHelper.valid_type?(value.current_return, ->(val) { Return.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.reference_numbers, ->(val) { PaymentReference.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.ledger_transaction_id, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['object'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['live_mode'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['created_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['updated_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['returnable_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['returnable_type'], ->(val) { ReturnableType.validate(val) }) and APIHelper.valid_type?(value['code'], ->(val) { Code1.validate(val) }) and APIHelper.valid_type?(value['reason'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['date_of_death'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['additional_information'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['status'], ->(val) { Status4.validate(val) }) and APIHelper.valid_type?(value['transaction_line_item_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['transaction_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['internal_account_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['type'], ->(val) { Type6.validate(val) }) and APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['currency'], ->(val) { Currency.validate(val) }) and APIHelper.valid_type?(value['failure_reason'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['role'], ->(val) { Role.validate(val) }) and APIHelper.valid_type?(value['current_return'], ->(val) { Return.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['reference_numbers'], ->(val) { PaymentReference.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['ledger_transaction_id'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/modern_treasury/models/mreturn.rb', line 407 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, object: #{@object.inspect}, live_mode:"\ " #{@live_mode.inspect}, created_at: #{@created_at.inspect}, updated_at:"\ " #{@updated_at.inspect}, returnable_id: #{@returnable_id.inspect}, returnable_type:"\ " #{@returnable_type.inspect}, code: #{@code.inspect}, reason: #{@reason.inspect},"\ " date_of_death: #{@date_of_death.inspect}, additional_information:"\ " #{@additional_information.inspect}, status: #{@status.inspect}, transaction_line_item_id:"\ " #{@transaction_line_item_id.inspect}, transaction_id: #{@transaction_id.inspect},"\ " internal_account_id: #{@internal_account_id.inspect}, type: #{@type.inspect}, amount:"\ " #{@amount.inspect}, currency: #{@currency.inspect}, failure_reason:"\ " #{@failure_reason.inspect}, role: #{@role.inspect}, current_return:"\ " #{@current_return.inspect}, reference_numbers: #{@reference_numbers.inspect},"\ " ledger_transaction_id: #{@ledger_transaction_id.inspect}>" end |
#to_custom_created_at ⇒ Object
272 273 274 |
# File 'lib/modern_treasury/models/mreturn.rb', line 272 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
276 277 278 |
# File 'lib/modern_treasury/models/mreturn.rb', line 276 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/modern_treasury/models/mreturn.rb', line 393 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, object: #{@object}, live_mode: #{@live_mode}, created_at:"\ " #{@created_at}, updated_at: #{@updated_at}, returnable_id: #{@returnable_id},"\ " returnable_type: #{@returnable_type}, code: #{@code}, reason: #{@reason}, date_of_death:"\ " #{@date_of_death}, additional_information: #{@additional_information}, status: #{@status},"\ " transaction_line_item_id: #{@transaction_line_item_id}, transaction_id:"\ " #{@transaction_id}, internal_account_id: #{@internal_account_id}, type: #{@type}, amount:"\ " #{@amount}, currency: #{@currency}, failure_reason: #{@failure_reason}, role: #{@role},"\ " current_return: #{@current_return}, reference_numbers: #{@reference_numbers},"\ " ledger_transaction_id: #{@ledger_transaction_id}>" end |