Class: ThePlaidApi::CraBankIncomeItem

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

Overview

The details and metadata for an end user’s Item.

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(bank_income_accounts:, bank_income_sources:, item_id: SKIP, accounts: SKIP, last_updated_time: SKIP, institution_id: SKIP, institution_name: SKIP, additional_properties: nil) ⇒ CraBankIncomeItem

Returns a new instance of CraBankIncomeItem.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 74

def initialize(bank_income_accounts:, bank_income_sources:, item_id: SKIP,
               accounts: SKIP, last_updated_time: SKIP,
               institution_id: SKIP, institution_name: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @item_id = item_id unless item_id == SKIP
  @accounts = accounts unless accounts == SKIP
  @bank_income_accounts = bank_income_accounts
  @bank_income_sources = bank_income_sources
  @last_updated_time = last_updated_time unless last_updated_time == SKIP
  @institution_id = institution_id unless institution_id == SKIP
  @institution_name = institution_name unless institution_name == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#accountsArray[CraBankIncomeAccount]

The Item’s accounts that have bank income data.

Returns:



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

def accounts
  @accounts
end

#bank_income_accountsArray[CraBankIncomeAccount]

This is a V1 (II1) field. For the V2 (II2) equivalent, use the ‘accounts` field. The Item’s accounts that have bank income data.

Returns:



24
25
26
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 24

def bank_income_accounts
  @bank_income_accounts
end

#bank_income_sourcesArray[CraBankIncomeSource]

This is a V1 (II1) field. For the V2 (II2) equivalent, use the report-level ‘income_streams` field. The income sources for this Item. Each entry in the array is a single income source.

Returns:



30
31
32
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 30

def bank_income_sources
  @bank_income_sources
end

#institution_idString

The unique identifier of the institution associated with the Item.

Returns:

  • (String)


39
40
41
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 39

def institution_id
  @institution_id
end

#institution_nameString

The name of the institution associated with the Item.

Returns:

  • (String)


43
44
45
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 43

def institution_name
  @institution_name
end

#item_idString

The ‘item_id` of the Item associated with this webhook, warning, or error

Returns:

  • (String)


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

def item_id
  @item_id
end

#last_updated_timeDateTime

The time when this Item’s data was last retrieved from the financial institution.

Returns:

  • (DateTime)


35
36
37
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 35

def last_updated_time
  @last_updated_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 92

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
  bank_income_accounts = nil
  unless hash['bank_income_accounts'].nil?
    bank_income_accounts = []
    hash['bank_income_accounts'].each do |structure|
      bank_income_accounts << (CraBankIncomeAccount.from_hash(structure) if structure)
    end
  end

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

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

  accounts = SKIP unless hash.key?('accounts')
  last_updated_time = if hash.key?('last_updated_time')
                        (DateTimeHelper.from_rfc3339(hash['last_updated_time']) if hash['last_updated_time'])
                      else
                        SKIP
                      end
  institution_id =
    hash.key?('institution_id') ? hash['institution_id'] : SKIP
  institution_name =
    hash.key?('institution_name') ? hash['institution_name'] : 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.
  CraBankIncomeItem.new(bank_income_accounts: bank_income_accounts,
                        bank_income_sources: bank_income_sources,
                        item_id: item_id,
                        accounts: accounts,
                        last_updated_time: last_updated_time,
                        institution_id: institution_id,
                        institution_name: institution_name,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 46

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_id'] = 'item_id'
  @_hash['accounts'] = 'accounts'
  @_hash['bank_income_accounts'] = 'bank_income_accounts'
  @_hash['bank_income_sources'] = 'bank_income_sources'
  @_hash['last_updated_time'] = 'last_updated_time'
  @_hash['institution_id'] = 'institution_id'
  @_hash['institution_name'] = 'institution_name'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 59

def self.optionals
  %w[
    item_id
    accounts
    last_updated_time
    institution_id
    institution_name
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



169
170
171
172
173
174
175
176
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 169

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} item_id: #{@item_id.inspect}, accounts: #{@accounts.inspect},"\
  " bank_income_accounts: #{@bank_income_accounts.inspect}, bank_income_sources:"\
  " #{@bank_income_sources.inspect}, last_updated_time: #{@last_updated_time.inspect},"\
  " institution_id: #{@institution_id.inspect}, institution_name:"\
  " #{@institution_name.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_last_updated_timeObject



155
156
157
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 155

def to_custom_last_updated_time
  DateTimeHelper.to_rfc3339(last_updated_time)
end

#to_sObject

Provides a human-readable string representation of the object.



160
161
162
163
164
165
166
# File 'lib/the_plaid_api/models/cra_bank_income_item.rb', line 160

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} item_id: #{@item_id}, accounts: #{@accounts}, bank_income_accounts:"\
  " #{@bank_income_accounts}, bank_income_sources: #{@bank_income_sources}, last_updated_time:"\
  " #{@last_updated_time}, institution_id: #{@institution_id}, institution_name:"\
  " #{@institution_name}, additional_properties: #{@additional_properties}>"
end