Class: ThePlaidApi::CreditBankStatementUploadObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/credit_bank_statement_upload_object.rb

Overview

An object containing data that has been parsed from a user-uploaded bank statement.

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(transactions:, document_metadata:, document_id:, bank_accounts:, additional_properties: nil) ⇒ CreditBankStatementUploadObject

Returns a new instance of CreditBankStatementUploadObject.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 51

def initialize(transactions:, document_metadata:, document_id:,
               bank_accounts:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @transactions = transactions
  @document_metadata = 
  @document_id = document_id
  @bank_accounts = bank_accounts
  @additional_properties = additional_properties
end

Instance Attribute Details

#bank_accountsArray[CreditBankStatementUploadBankAccount]

An array of bank accounts associated with the uploaded bank statement.



27
28
29
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 27

def bank_accounts
  @bank_accounts
end

#document_idString

An identifier of the document referenced by the document metadata.

Returns:

  • (String)


23
24
25
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 23

def document_id
  @document_id
end

#document_metadataCreditDocumentMetadata

Object representing metadata pertaining to the document.



19
20
21
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 19

def 
  @document_metadata
end

#transactionsArray[CreditBankStatementUploadTransaction]

An array of transactions appearing on the bank statement.



15
16
17
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 15

def transactions
  @transactions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  transactions = nil
  unless hash['transactions'].nil?
    transactions = []
    hash['transactions'].each do |structure|
      transactions << (CreditBankStatementUploadTransaction.from_hash(structure) if structure)
    end
  end

  transactions = nil unless hash.key?('transactions')
   = CreditDocumentMetadata.from_hash(hash['document_metadata']) if
    hash['document_metadata']
  document_id = hash.key?('document_id') ? hash['document_id'] : nil
  # Parameter is an array, so we need to iterate through it
  bank_accounts = nil
  unless hash['bank_accounts'].nil?
    bank_accounts = []
    hash['bank_accounts'].each do |structure|
      bank_accounts << (CreditBankStatementUploadBankAccount.from_hash(structure) if structure)
    end
  end

  bank_accounts = nil unless hash.key?('bank_accounts')

  # 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.
  CreditBankStatementUploadObject.new(transactions: transactions,
                                      document_metadata: ,
                                      document_id: document_id,
                                      bank_accounts: bank_accounts,
                                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transactions'] = 'transactions'
  @_hash['document_metadata'] = 'document_metadata'
  @_hash['document_id'] = 'document_id'
  @_hash['bank_accounts'] = 'bank_accounts'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
48
49
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 45

def self.nullables
  %w[
    document_id
  ]
end

.optionalsObject

An array for optional fields



40
41
42
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 40

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



116
117
118
119
120
121
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 116

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transactions: #{@transactions.inspect}, document_metadata:"\
  " #{@document_metadata.inspect}, document_id: #{@document_id.inspect}, bank_accounts:"\
  " #{@bank_accounts.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



108
109
110
111
112
113
# File 'lib/the_plaid_api/models/credit_bank_statement_upload_object.rb', line 108

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} transactions: #{@transactions}, document_metadata: #{@document_metadata},"\
  " document_id: #{@document_id}, bank_accounts: #{@bank_accounts}, additional_properties:"\
  " #{@additional_properties}>"
end