Class: ThePlaidApi::BankPenaltiesIndicators

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

Overview

Insights into bank penalties and fees, including overdraft fees, NSF fees, and other bank-imposed charges.

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(amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, monthly_average: SKIP, category_details: SKIP, transactions_count: SKIP, monthly_summaries: SKIP, days_since_last_occurrence: SKIP, percentage_of_income: SKIP, additional_properties: nil) ⇒ BankPenaltiesIndicators

Returns a new instance of BankPenaltiesIndicators.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 111

def initialize(amount: SKIP, iso_currency_code: SKIP,
               unofficial_currency_code: SKIP, monthly_average: SKIP,
               category_details: SKIP, transactions_count: SKIP,
               monthly_summaries: SKIP, days_since_last_occurrence: SKIP,
               percentage_of_income: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount = amount unless amount == SKIP
  @iso_currency_code = iso_currency_code unless iso_currency_code == SKIP
  @unofficial_currency_code = unofficial_currency_code unless unofficial_currency_code == SKIP
  @monthly_average = monthly_average unless monthly_average == SKIP
  @category_details = category_details unless category_details == SKIP
  @transactions_count = transactions_count unless transactions_count == SKIP
  @monthly_summaries = monthly_summaries unless monthly_summaries == SKIP
  unless days_since_last_occurrence == SKIP
    @days_since_last_occurrence =
      days_since_last_occurrence
  end
  @percentage_of_income = percentage_of_income unless percentage_of_income == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

The total value of outflow transactions categorized as ‘BANK_PENALTIES`, across all the accounts in the report within the requested time window.

Returns:

  • (Float)


16
17
18
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 16

def amount
  @amount
end

#category_detailsArray[CategoryExpenses]

Detailed categories view of all the transactions that fall into the ‘BANK_PENALTIES` credit category within the given time window, across all the accounts in the report.

Returns:



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

def category_details
  @category_details
end

#days_since_last_occurrenceInteger

The number of days since the last transaction that falls into the ‘BANK_PENALTIES` credit category, across all the accounts in the report.

Returns:

  • (Integer)


56
57
58
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 56

def days_since_last_occurrence
  @days_since_last_occurrence
end

#iso_currency_codeString

The ISO-4217 currency code of the amount. Always ‘null` if `unofficial_currency_code` is non-`null`.

Returns:

  • (String)


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

def iso_currency_code
  @iso_currency_code
end

#monthly_averageMonthlyAverage

The monthly average amount calculated by dividing the total by the number of calendar months in the time period.

Returns:



34
35
36
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 34

def monthly_average
  @monthly_average
end

#monthly_summariesArray[MonthlySummary]

The monthly summaries of the transactions that fall into the ‘BANK_PENALTIES` credit category within the given time window, across all the accounts in the report.

Returns:



51
52
53
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 51

def monthly_summaries
  @monthly_summaries
end

#percentage_of_incomeFloat

The percentage of the user’s monthly inflows that was spent on transactions that fall into the ‘BANK_PENALTIES` credit category within the given time window, across all the accounts in the report. For example, a value of 100 represents that 100% of the inflows were spent on transactions that fall into the `BANK_PENALTIES` credit category. If there’s no available income for the given time period, this field value will be ‘-1`.

Returns:

  • (Float)


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

def percentage_of_income
  @percentage_of_income
end

#transactions_countInteger

The total number of transactions that fall into the ‘BANK_PENALTIES` credit category, across all the accounts in the report.

Returns:

  • (Integer)


45
46
47
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 45

def transactions_count
  @transactions_count
end

#unofficial_currency_codeString

The unofficial currency code associated with the amount. Always ‘null` if `iso_currency_code` is non-`null`. See the [currency code schema](plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `unofficial_currency_code`s.

Returns:

  • (String)


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

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 135

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['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
  monthly_average = MonthlyAverage.from_hash(hash['monthly_average']) if
    hash['monthly_average']
  # Parameter is an array, so we need to iterate through it
  category_details = nil
  unless hash['category_details'].nil?
    category_details = []
    hash['category_details'].each do |structure|
      category_details << (CategoryExpenses.from_hash(structure) if structure)
    end
  end

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

  monthly_summaries = SKIP unless hash.key?('monthly_summaries')
  days_since_last_occurrence =
    hash.key?('days_since_last_occurrence') ? hash['days_since_last_occurrence'] : SKIP
  percentage_of_income =
    hash.key?('percentage_of_income') ? hash['percentage_of_income'] : 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.
  BankPenaltiesIndicators.new(amount: amount,
                              iso_currency_code: iso_currency_code,
                              unofficial_currency_code: unofficial_currency_code,
                              monthly_average: monthly_average,
                              category_details: category_details,
                              transactions_count: transactions_count,
                              monthly_summaries: monthly_summaries,
                              days_since_last_occurrence: days_since_last_occurrence,
                              percentage_of_income: percentage_of_income,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 69

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['monthly_average'] = 'monthly_average'
  @_hash['category_details'] = 'category_details'
  @_hash['transactions_count'] = 'transactions_count'
  @_hash['monthly_summaries'] = 'monthly_summaries'
  @_hash['days_since_last_occurrence'] = 'days_since_last_occurrence'
  @_hash['percentage_of_income'] = 'percentage_of_income'
  @_hash
end

.nullablesObject

An array for nullable fields



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 99

def self.nullables
  %w[
    amount
    iso_currency_code
    unofficial_currency_code
    monthly_average
    transactions_count
    days_since_last_occurrence
    percentage_of_income
  ]
end

.optionalsObject

An array for optional fields



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 84

def self.optionals
  %w[
    amount
    iso_currency_code
    unofficial_currency_code
    monthly_average
    category_details
    transactions_count
    monthly_summaries
    days_since_last_occurrence
    percentage_of_income
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



205
206
207
208
209
210
211
212
213
214
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 205

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, iso_currency_code:"\
  " #{@iso_currency_code.inspect}, unofficial_currency_code:"\
  " #{@unofficial_currency_code.inspect}, monthly_average: #{@monthly_average.inspect},"\
  " category_details: #{@category_details.inspect}, transactions_count:"\
  " #{@transactions_count.inspect}, monthly_summaries: #{@monthly_summaries.inspect},"\
  " days_since_last_occurrence: #{@days_since_last_occurrence.inspect}, percentage_of_income:"\
  " #{@percentage_of_income.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



194
195
196
197
198
199
200
201
202
# File 'lib/the_plaid_api/models/bank_penalties_indicators.rb', line 194

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, iso_currency_code: #{@iso_currency_code},"\
  " unofficial_currency_code: #{@unofficial_currency_code}, monthly_average:"\
  " #{@monthly_average}, category_details: #{@category_details}, transactions_count:"\
  " #{@transactions_count}, monthly_summaries: #{@monthly_summaries},"\
  " days_since_last_occurrence: #{@days_since_last_occurrence}, percentage_of_income:"\
  " #{@percentage_of_income}, additional_properties: #{@additional_properties}>"
end