Class: ModernTreasury::ReturnCreateRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/return_create_request.rb

Overview

ReturnCreateRequest 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(returnable_id:, code: SKIP, reason: SKIP, date_of_death: SKIP, additional_information: SKIP, additional_properties: nil) ⇒ ReturnCreateRequest

Returns a new instance of ReturnCreateRequest.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/modern_treasury/models/return_create_request.rb', line 73

def initialize(returnable_id:, code: SKIP, reason: SKIP,
               date_of_death: SKIP, additional_information: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @returnable_id = returnable_id
  @code = code unless code == SKIP
  @reason = reason unless reason == SKIP
  @date_of_death = date_of_death unless date_of_death == SKIP
  @additional_information = additional_information unless additional_information == SKIP
  @returnable_type = 'incoming_payment_detail'
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_informationString

Some returns may include additional information from the bank. In these cases, this string will be present.

Returns:

  • (String)


33
34
35
# File 'lib/modern_treasury/models/return_create_request.rb', line 33

def additional_information
  @additional_information
end

#codeCode1

The return code. For ACH returns, this is the required ACH return code.

Returns:



18
19
20
# File 'lib/modern_treasury/models/return_create_request.rb', line 18

def code
  @code
end

#date_of_deathDate

If the return code is ‘R14` or `R15` this is the date the deceased counterparty passed away.

Returns:

  • (Date)


28
29
30
# File 'lib/modern_treasury/models/return_create_request.rb', line 28

def date_of_death
  @date_of_death
end

#reasonString

An optional description of the reason for the return. This is for internal usage and will not be transmitted to the bank.”

Returns:

  • (String)


23
24
25
# File 'lib/modern_treasury/models/return_create_request.rb', line 23

def reason
  @reason
end

#returnable_idUUID | String

The ID of the object being returned or ‘null`.

Returns:

  • (UUID | String)


14
15
16
# File 'lib/modern_treasury/models/return_create_request.rb', line 14

def returnable_id
  @returnable_id
end

#returnable_typeString (readonly)

The type of object being returned. Currently, this may only be incoming_payment_detail.

Returns:

  • (String)


38
39
40
# File 'lib/modern_treasury/models/return_create_request.rb', line 38

def returnable_type
  @returnable_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/modern_treasury/models/return_create_request.rb', line 89

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  returnable_id = hash.key?('returnable_id') ? hash['returnable_id'] : nil
  code = hash.key?('code') ? hash['code'] : SKIP
  reason = hash.key?('reason') ? hash['reason'] : SKIP
  date_of_death = hash.key?('date_of_death') ? hash['date_of_death'] : SKIP
  additional_information =
    hash.key?('additional_information') ? hash['additional_information'] : 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.
  ReturnCreateRequest.new(returnable_id: returnable_id,
                          code: code,
                          reason: reason,
                          date_of_death: date_of_death,
                          additional_information: additional_information,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
# File 'lib/modern_treasury/models/return_create_request.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['returnable_id'] = 'returnable_id'
  @_hash['code'] = 'code'
  @_hash['reason'] = 'reason'
  @_hash['date_of_death'] = 'date_of_death'
  @_hash['additional_information'] = 'additional_information'
  @_hash['returnable_type'] = 'returnable_type'
  @_hash
end

.nullablesObject

An array for nullable fields



63
64
65
66
67
68
69
70
71
# File 'lib/modern_treasury/models/return_create_request.rb', line 63

def self.nullables
  %w[
    returnable_id
    code
    reason
    date_of_death
    additional_information
  ]
end

.optionalsObject

An array for optional fields



53
54
55
56
57
58
59
60
# File 'lib/modern_treasury/models/return_create_request.rb', line 53

def self.optionals
  %w[
    code
    reason
    date_of_death
    additional_information
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



125
126
127
128
129
130
131
# File 'lib/modern_treasury/models/return_create_request.rb', line 125

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} returnable_id: #{@returnable_id.inspect}, code: #{@code.inspect}, reason:"\
  " #{@reason.inspect}, date_of_death: #{@date_of_death.inspect}, additional_information:"\
  " #{@additional_information.inspect}, returnable_type: #{@returnable_type.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



117
118
119
120
121
122
# File 'lib/modern_treasury/models/return_create_request.rb', line 117

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} returnable_id: #{@returnable_id}, code: #{@code}, reason: #{@reason},"\
  " date_of_death: #{@date_of_death}, additional_information: #{@additional_information},"\
  " returnable_type: #{@returnable_type}, additional_properties: #{@additional_properties}>"
end