Class: ModernTreasury::ReceivingAccount

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

Overview

ReceivingAccount 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(id: SKIP, object: SKIP, live_mode: SKIP, created_at: SKIP, updated_at: SKIP, discarded_at: SKIP, account_type: SKIP, party_type: SKIP, party_address: SKIP, name: SKIP, account_details: SKIP, routing_details: SKIP, metadata: SKIP, party_name: SKIP, contact_details: SKIP, ledger_account_id: SKIP, verification_status: SKIP, additional_properties: nil) ⇒ ReceivingAccount

Returns a new instance of ReceivingAccount.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/modern_treasury/models/receiving_account.rb', line 148

def initialize(id: SKIP, object: SKIP, live_mode: SKIP, created_at: SKIP,
               updated_at: SKIP, discarded_at: SKIP, account_type: SKIP,
               party_type: SKIP, party_address: SKIP, name: SKIP,
               account_details: SKIP, routing_details: SKIP, metadata: SKIP,
               party_name: SKIP, contact_details: SKIP,
               ledger_account_id: SKIP, verification_status: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id unless id == SKIP
  @object = object unless object == SKIP
  @live_mode = live_mode unless live_mode == SKIP
  @created_at = created_at unless created_at == SKIP
  @updated_at = updated_at unless updated_at == SKIP
  @discarded_at = discarded_at unless discarded_at == SKIP
  @account_type =  unless  == SKIP
  @party_type = party_type unless party_type == SKIP
  @party_address = party_address unless party_address == SKIP
  @name = name unless name == SKIP
  @account_details =  unless  == SKIP
  @routing_details = routing_details unless routing_details == SKIP
  @metadata =  unless  == SKIP
  @party_name = party_name unless party_name == SKIP
  @contact_details = contact_details unless contact_details == SKIP
  @ledger_account_id =  unless  == SKIP
  @verification_status = verification_status unless verification_status == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_detailsArray[AccountDetail]

A nickname for the external account. This is only for internal usage and won’t affect any payments

Returns:



61
62
63
# File 'lib/modern_treasury/models/receiving_account.rb', line 61

def 
  @account_details
end

#account_typeAccountType

Can be ‘checking`, `savings` or `other`.

Returns:



43
44
45
# File 'lib/modern_treasury/models/receiving_account.rb', line 43

def 
  @account_type
end

#contact_detailsArray[ContactDetail]

The legal name of the entity which owns the account.

Returns:



79
80
81
# File 'lib/modern_treasury/models/receiving_account.rb', line 79

def contact_details
  @contact_details
end

#created_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


29
30
31
# File 'lib/modern_treasury/models/receiving_account.rb', line 29

def created_at
  @created_at
end

#discarded_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


39
40
41
# File 'lib/modern_treasury/models/receiving_account.rb', line 39

def discarded_at
  @discarded_at
end

#idUUID | String

TODO: Write general description for this method

Returns:

  • (UUID | String)


15
16
17
# File 'lib/modern_treasury/models/receiving_account.rb', line 15

def id
  @id
end

#ledger_account_idUUID | String

If the external account links to a ledger account in Modern Treasury, the id of the ledger account will be populated here.

Returns:

  • (UUID | String)


84
85
86
# File 'lib/modern_treasury/models/receiving_account.rb', line 84

def 
  @ledger_account_id
end

#live_modeTrueClass | FalseClass

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/modern_treasury/models/receiving_account.rb', line 24

def live_mode
  @live_mode
end

#metadataHash[String, String]

Additional data represented as key-value pairs. Both the key and value must be strings.

Returns:

  • (Hash[String, String])


71
72
73
# File 'lib/modern_treasury/models/receiving_account.rb', line 71

def 
  @metadata
end

#nameString

A nickname for the external account. This is only for internal usage and won’t affect any payments

Returns:

  • (String)


56
57
58
# File 'lib/modern_treasury/models/receiving_account.rb', line 56

def name
  @name
end

#objectString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/modern_treasury/models/receiving_account.rb', line 19

def object
  @object
end

#party_addressAddress

Either ‘individual` or `business`.

Returns:



51
52
53
# File 'lib/modern_treasury/models/receiving_account.rb', line 51

def party_address
  @party_address
end

#party_nameString

The legal name of the entity which owns the account.

Returns:

  • (String)


75
76
77
# File 'lib/modern_treasury/models/receiving_account.rb', line 75

def party_name
  @party_name
end

#party_typePartyType

Either ‘individual` or `business`.

Returns:



47
48
49
# File 'lib/modern_treasury/models/receiving_account.rb', line 47

def party_type
  @party_type
end

#routing_detailsArray[RoutingDetail]

A nickname for the external account. This is only for internal usage and won’t affect any payments

Returns:



66
67
68
# File 'lib/modern_treasury/models/receiving_account.rb', line 66

def routing_details
  @routing_details
end

#updated_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


34
35
36
# File 'lib/modern_treasury/models/receiving_account.rb', line 34

def updated_at
  @updated_at
end

#verification_statusVerificationStatus

If the external account links to a ledger account in Modern Treasury, the id of the ledger account will be populated here.

Returns:



89
90
91
# File 'lib/modern_treasury/models/receiving_account.rb', line 89

def verification_status
  @verification_status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
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
# File 'lib/modern_treasury/models/receiving_account.rb', line 179

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  object = hash.key?('object') ? hash['object'] : SKIP
  live_mode = hash.key?('live_mode') ? hash['live_mode'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               else
                 SKIP
               end
  discarded_at = if hash.key?('discarded_at')
                   (DateTimeHelper.from_rfc3339(hash['discarded_at']) if hash['discarded_at'])
                 else
                   SKIP
                 end
   = hash.key?('account_type') ? hash['account_type'] : SKIP
  party_type = hash.key?('party_type') ? hash['party_type'] : SKIP
  party_address = Address.from_hash(hash['party_address']) if hash['party_address']
  name = hash.key?('name') ? hash['name'] : SKIP
  # Parameter is an array, so we need to iterate through it
   = nil
  unless hash['account_details'].nil?
     = []
    hash['account_details'].each do |structure|
       << (AccountDetail.from_hash(structure) if structure)
    end
  end

   = SKIP unless hash.key?('account_details')
  # Parameter is an array, so we need to iterate through it
  routing_details = nil
  unless hash['routing_details'].nil?
    routing_details = []
    hash['routing_details'].each do |structure|
      routing_details << (RoutingDetail.from_hash(structure) if structure)
    end
  end

  routing_details = SKIP unless hash.key?('routing_details')
   = hash.key?('metadata') ? hash['metadata'] : SKIP
  party_name = hash.key?('party_name') ? hash['party_name'] : SKIP
  # Parameter is an array, so we need to iterate through it
  contact_details = nil
  unless hash['contact_details'].nil?
    contact_details = []
    hash['contact_details'].each do |structure|
      contact_details << (ContactDetail.from_hash(structure) if structure)
    end
  end

  contact_details = SKIP unless hash.key?('contact_details')
   =
    hash.key?('ledger_account_id') ? hash['ledger_account_id'] : SKIP
  verification_status =
    hash.key?('verification_status') ? hash['verification_status'] : 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.
  ReceivingAccount.new(id: id,
                       object: object,
                       live_mode: live_mode,
                       created_at: created_at,
                       updated_at: updated_at,
                       discarded_at: discarded_at,
                       account_type: ,
                       party_type: party_type,
                       party_address: party_address,
                       name: name,
                       account_details: ,
                       routing_details: routing_details,
                       metadata: ,
                       party_name: party_name,
                       contact_details: contact_details,
                       ledger_account_id: ,
                       verification_status: verification_status,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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['discarded_at'] = 'discarded_at'
  @_hash['account_type'] = 'account_type'
  @_hash['party_type'] = 'party_type'
  @_hash['party_address'] = 'party_address'
  @_hash['name'] = 'name'
  @_hash['account_details'] = 'account_details'
  @_hash['routing_details'] = 'routing_details'
  @_hash['metadata'] = 'metadata'
  @_hash['party_name'] = 'party_name'
  @_hash['contact_details'] = 'contact_details'
  @_hash['ledger_account_id'] = 'ledger_account_id'
  @_hash['verification_status'] = 'verification_status'
  @_hash
end

.nullablesObject

An array for nullable fields



138
139
140
141
142
143
144
145
146
# File 'lib/modern_treasury/models/receiving_account.rb', line 138

def self.nullables
  %w[
    discarded_at
    party_type
    party_address
    name
    ledger_account_id
  ]
end

.optionalsObject

An array for optional fields



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/modern_treasury/models/receiving_account.rb', line 115

def self.optionals
  %w[
    id
    object
    live_mode
    created_at
    updated_at
    discarded_at
    account_type
    party_type
    party_address
    name
    account_details
    routing_details
    metadata
    party_name
    contact_details
    ledger_account_id
    verification_status
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



284
285
286
287
288
289
290
# File 'lib/modern_treasury/models/receiving_account.rb', line 284

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/modern_treasury/models/receiving_account.rb', line 305

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}, discarded_at: #{@discarded_at.inspect}, account_type:"\
  " #{@account_type.inspect}, party_type: #{@party_type.inspect}, party_address:"\
  " #{@party_address.inspect}, name: #{@name.inspect}, account_details:"\
  " #{@account_details.inspect}, routing_details: #{@routing_details.inspect}, metadata:"\
  " #{@metadata.inspect}, party_name: #{@party_name.inspect}, contact_details:"\
  " #{@contact_details.inspect}, ledger_account_id: #{@ledger_account_id.inspect},"\
  " verification_status: #{@verification_status.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_created_atObject



270
271
272
# File 'lib/modern_treasury/models/receiving_account.rb', line 270

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_discarded_atObject



278
279
280
# File 'lib/modern_treasury/models/receiving_account.rb', line 278

def to_custom_discarded_at
  DateTimeHelper.to_rfc3339(discarded_at)
end

#to_custom_updated_atObject



274
275
276
# File 'lib/modern_treasury/models/receiving_account.rb', line 274

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



293
294
295
296
297
298
299
300
301
302
# File 'lib/modern_treasury/models/receiving_account.rb', line 293

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}, discarded_at: #{@discarded_at}, account_type:"\
  " #{@account_type}, party_type: #{@party_type}, party_address: #{@party_address}, name:"\
  " #{@name}, account_details: #{@account_details}, routing_details: #{@routing_details},"\
  " metadata: #{@metadata}, party_name: #{@party_name}, contact_details: #{@contact_details},"\
  " ledger_account_id: #{@ledger_account_id}, verification_status: #{@verification_status},"\
  " additional_properties: #{@additional_properties}>"
end