Class: ThePlaidApi::CreditBankIncomeHistoricalSummary

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

Overview

The end user’s monthly summary for the income source(s).

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(total_amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, total_amounts: SKIP, start_date: SKIP, end_date: SKIP, transactions: SKIP, additional_properties: nil) ⇒ CreditBankIncomeHistoricalSummary

Returns a new instance of CreditBankIncomeHistoricalSummary.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 111

def initialize(total_amount: SKIP, iso_currency_code: SKIP,
               unofficial_currency_code: SKIP, total_amounts: SKIP,
               start_date: SKIP, end_date: SKIP, transactions: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_amount = total_amount unless total_amount == SKIP
  @iso_currency_code = iso_currency_code unless iso_currency_code == SKIP
  @unofficial_currency_code = unofficial_currency_code unless unofficial_currency_code == SKIP
  @total_amounts = total_amounts unless total_amounts == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @transactions = transactions unless transactions == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#end_dateDate

The end date of the period included in this monthly summary. This date will be the last day of the month, unless the month being covered is a partial month because it is the last month included in the summary and the date range being requested does not end with the last day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


66
67
68
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 66

def end_date
  @end_date
end

#iso_currency_codeString

The ISO 4217 currency code of the amount or balance. Please use [‘total_amounts`](plaid.com/docs/api/products/income/#credit-bank_ income-get-response-bank-income-items-bank-income-sources-historical-summa ry-total-amounts) instead.

Returns:

  • (String)


29
30
31
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 29

def iso_currency_code
  @iso_currency_code
end

#start_dateDate

The start date of the period covered in this monthly summary. This date will be the first day of the month, unless the month being covered is a partial month because it is the first month included in the summary and the date range being requested does not begin with the first day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


57
58
59
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 57

def start_date
  @start_date
end

#total_amountFloat

Total amount of earnings for the income source(s) of the user for the month in the summary. This may return an incorrect value if the summary includes income sources in multiple currencies. Please use [‘total_amounts`](plaid.com/docs/api/products/income/#credit-bank_ income-get-response-bank-income-items-bank-income-sources-historical-summa ry-total-amounts) instead.

Returns:

  • (Float)


21
22
23
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 21

def total_amount
  @total_amount
end

#total_amountsArray[CreditAmountWithCurrency]

Total amount of earnings for the income source(s) of the user for the month in the summary. This can contain multiple amounts, with each amount denominated in one unique currency.

Returns:



48
49
50
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 48

def total_amounts
  @total_amounts
end

#transactionsArray[CreditBankIncomeTransaction]

The end date of the period included in this monthly summary. This date will be the last day of the month, unless the month being covered is a partial month because it is the last month included in the summary and the date range being requested does not end with the last day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:



75
76
77
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 75

def transactions
  @transactions
end

#unofficial_currency_codeString

The unofficial currency code associated with the amount or balance. Always ‘null` if `iso_currency_code` is non-null. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries. Please use [`total_amounts`](plaid.com/docs/api/products/income/#credit-bank_ income-get-response-bank-income-items-bank-income-sources-historical-summa ry-total-amounts) instead.

Returns:

  • (String)


41
42
43
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 41

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 129

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_amount = hash.key?('total_amount') ? hash['total_amount'] : SKIP
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : SKIP
  unofficial_currency_code =
    hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : SKIP
  # Parameter is an array, so we need to iterate through it
  total_amounts = nil
  unless hash['total_amounts'].nil?
    total_amounts = []
    hash['total_amounts'].each do |structure|
      total_amounts << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  total_amounts = SKIP unless hash.key?('total_amounts')
  start_date = hash.key?('start_date') ? hash['start_date'] : SKIP
  end_date = hash.key?('end_date') ? hash['end_date'] : SKIP
  # Parameter is an array, so we need to iterate through it
  transactions = nil
  unless hash['transactions'].nil?
    transactions = []
    hash['transactions'].each do |structure|
      transactions << (CreditBankIncomeTransaction.from_hash(structure) if structure)
    end
  end

  transactions = SKIP unless hash.key?('transactions')

  # 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.
  CreditBankIncomeHistoricalSummary.new(total_amount: total_amount,
                                        iso_currency_code: iso_currency_code,
                                        unofficial_currency_code: unofficial_currency_code,
                                        total_amounts: total_amounts,
                                        start_date: start_date,
                                        end_date: end_date,
                                        transactions: transactions,
                                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 78

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amount'] = 'total_amount'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['total_amounts'] = 'total_amounts'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['transactions'] = 'transactions'
  @_hash
end

.nullablesObject

An array for nullable fields



104
105
106
107
108
109
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 104

def self.nullables
  %w[
    iso_currency_code
    unofficial_currency_code
  ]
end

.optionalsObject

An array for optional fields



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 91

def self.optionals
  %w[
    total_amount
    iso_currency_code
    unofficial_currency_code
    total_amounts
    start_date
    end_date
    transactions
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



189
190
191
192
193
194
195
196
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 189

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount.inspect}, iso_currency_code:"\
  " #{@iso_currency_code.inspect}, unofficial_currency_code:"\
  " #{@unofficial_currency_code.inspect}, total_amounts: #{@total_amounts.inspect},"\
  " start_date: #{@start_date.inspect}, end_date: #{@end_date.inspect}, transactions:"\
  " #{@transactions.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



180
181
182
183
184
185
186
# File 'lib/the_plaid_api/models/credit_bank_income_historical_summary.rb', line 180

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount}, iso_currency_code: #{@iso_currency_code},"\
  " unofficial_currency_code: #{@unofficial_currency_code}, total_amounts: #{@total_amounts},"\
  " start_date: #{@start_date}, end_date: #{@end_date}, transactions: #{@transactions},"\
  " additional_properties: #{@additional_properties}>"
end