Class: ThePlaidApi::BaseReportAccountInsights

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

Overview

Calculated insights derived from transaction-level data. This field has been deprecated in favor of [Base Report attributes aggregated across accounts](plaid.com/docs/api/products/check/#cra-check_report-base_r eport-get-response-report-attributes) and will be removed in a future release.

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(oldest_transaction_date: SKIP, most_recent_transaction_date: SKIP, days_available: SKIP, average_days_between_transactions: SKIP, longest_gaps_between_transactions: SKIP, number_of_inflows: SKIP, average_inflow_amounts: SKIP, number_of_outflows: SKIP, average_outflow_amounts: SKIP, number_of_days_no_transactions: SKIP, additional_properties: nil) ⇒ BaseReportAccountInsights

Returns a new instance of BaseReportAccountInsights.



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
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 106

def initialize(oldest_transaction_date: SKIP,
               most_recent_transaction_date: SKIP, days_available: SKIP,
               average_days_between_transactions: SKIP,
               longest_gaps_between_transactions: SKIP,
               number_of_inflows: SKIP, average_inflow_amounts: SKIP,
               number_of_outflows: SKIP, average_outflow_amounts: SKIP,
               number_of_days_no_transactions: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @oldest_transaction_date = oldest_transaction_date unless oldest_transaction_date == SKIP
  unless most_recent_transaction_date == SKIP
    @most_recent_transaction_date =
      most_recent_transaction_date
  end
  @days_available = days_available unless days_available == SKIP
  unless average_days_between_transactions == SKIP
    @average_days_between_transactions =
      average_days_between_transactions
  end
  unless longest_gaps_between_transactions == SKIP
    @longest_gaps_between_transactions =
      longest_gaps_between_transactions
  end
  @number_of_inflows = number_of_inflows unless number_of_inflows == SKIP
  @average_inflow_amounts = average_inflow_amounts unless average_inflow_amounts == SKIP
  @number_of_outflows = number_of_outflows unless number_of_outflows == SKIP
  @average_outflow_amounts = average_outflow_amounts unless average_outflow_amounts == SKIP
  unless number_of_days_no_transactions == SKIP
    @number_of_days_no_transactions =
      number_of_days_no_transactions
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#average_days_between_transactionsFloat

Average number of days between sequential transactions

Returns:

  • (Float)


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

def average_days_between_transactions
  @average_days_between_transactions
end

#average_inflow_amountsArray[BaseReportAverageFlowInsights]

Average amount of debit transactions into the account in a time period. This array will be empty for non-depository accounts. This field only takes into account USD transactions from the account.

Returns:



46
47
48
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 46

def average_inflow_amounts
  @average_inflow_amounts
end

#average_outflow_amountsArray[BaseReportAverageFlowInsights]

Average amount of transactions out of the account in a time period. This array will be empty for non-depository accounts. This field only takes into account USD transactions from the account.

Returns:



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

def average_outflow_amounts
  @average_outflow_amounts
end

#days_availableInteger

Number of days days available for the account.

Returns:

  • (Integer)


26
27
28
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 26

def days_available
  @days_available
end

#longest_gaps_between_transactionsArray[BaseReportLongestGapInsights]

Longest gap between sequential transactions in a time period. This array can include multiple time periods.

Returns:



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

def longest_gaps_between_transactions
  @longest_gaps_between_transactions
end

#most_recent_transaction_dateDate

Date of the most recent transaction for the account.

Returns:

  • (Date)


22
23
24
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 22

def most_recent_transaction_date
  @most_recent_transaction_date
end

#number_of_days_no_transactionsInteger

Number of days with no transactions

Returns:

  • (Integer)


61
62
63
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 61

def number_of_days_no_transactions
  @number_of_days_no_transactions
end

#number_of_inflowsArray[BaseReportNumberFlowInsights]

The number of debits into the account. This array will be empty for non-depository accounts.

Returns:



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

def number_of_inflows
  @number_of_inflows
end

#number_of_outflowsArray[BaseReportNumberFlowInsights]

The number of outflows from the account. This array will be empty for non-depository accounts.

Returns:



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

def number_of_outflows
  @number_of_outflows
end

#oldest_transaction_dateDate

Date of the earliest transaction for the account.

Returns:

  • (Date)


18
19
20
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 18

def oldest_transaction_date
  @oldest_transaction_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
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
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 143

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  oldest_transaction_date =
    hash.key?('oldest_transaction_date') ? hash['oldest_transaction_date'] : SKIP
  most_recent_transaction_date =
    hash.key?('most_recent_transaction_date') ? hash['most_recent_transaction_date'] : SKIP
  days_available =
    hash.key?('days_available') ? hash['days_available'] : SKIP
  average_days_between_transactions =
    hash.key?('average_days_between_transactions') ? hash['average_days_between_transactions'] : SKIP
  # Parameter is an array, so we need to iterate through it
  longest_gaps_between_transactions = nil
  unless hash['longest_gaps_between_transactions'].nil?
    longest_gaps_between_transactions = []
    hash['longest_gaps_between_transactions'].each do |structure|
      longest_gaps_between_transactions << (BaseReportLongestGapInsights.from_hash(structure) if structure)
    end
  end

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

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

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

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

  average_outflow_amounts = SKIP unless hash.key?('average_outflow_amounts')
  number_of_days_no_transactions =
    hash.key?('number_of_days_no_transactions') ? hash['number_of_days_no_transactions'] : 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.
  BaseReportAccountInsights.new(oldest_transaction_date: oldest_transaction_date,
                                most_recent_transaction_date: most_recent_transaction_date,
                                days_available: days_available,
                                average_days_between_transactions: average_days_between_transactions,
                                longest_gaps_between_transactions: longest_gaps_between_transactions,
                                number_of_inflows: number_of_inflows,
                                average_inflow_amounts: average_inflow_amounts,
                                number_of_outflows: number_of_outflows,
                                average_outflow_amounts: average_outflow_amounts,
                                number_of_days_no_transactions: number_of_days_no_transactions,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 64

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['oldest_transaction_date'] = 'oldest_transaction_date'
  @_hash['most_recent_transaction_date'] = 'most_recent_transaction_date'
  @_hash['days_available'] = 'days_available'
  @_hash['average_days_between_transactions'] =
    'average_days_between_transactions'
  @_hash['longest_gaps_between_transactions'] =
    'longest_gaps_between_transactions'
  @_hash['number_of_inflows'] = 'number_of_inflows'
  @_hash['average_inflow_amounts'] = 'average_inflow_amounts'
  @_hash['number_of_outflows'] = 'number_of_outflows'
  @_hash['average_outflow_amounts'] = 'average_outflow_amounts'
  @_hash['number_of_days_no_transactions'] =
    'number_of_days_no_transactions'
  @_hash
end

.nullablesObject

An array for nullable fields



99
100
101
102
103
104
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 99

def self.nullables
  %w[
    oldest_transaction_date
    most_recent_transaction_date
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    oldest_transaction_date
    most_recent_transaction_date
    days_available
    average_days_between_transactions
    longest_gaps_between_transactions
    number_of_inflows
    average_inflow_amounts
    number_of_outflows
    average_outflow_amounts
    number_of_days_no_transactions
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 244

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} oldest_transaction_date: #{@oldest_transaction_date.inspect},"\
  " most_recent_transaction_date: #{@most_recent_transaction_date.inspect}, days_available:"\
  " #{@days_available.inspect}, average_days_between_transactions:"\
  " #{@average_days_between_transactions.inspect}, longest_gaps_between_transactions:"\
  " #{@longest_gaps_between_transactions.inspect}, number_of_inflows:"\
  " #{@number_of_inflows.inspect}, average_inflow_amounts: #{@average_inflow_amounts.inspect},"\
  " number_of_outflows: #{@number_of_outflows.inspect}, average_outflow_amounts:"\
  " #{@average_outflow_amounts.inspect}, number_of_days_no_transactions:"\
  " #{@number_of_days_no_transactions.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/the_plaid_api/models/base_report_account_insights.rb', line 230

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} oldest_transaction_date: #{@oldest_transaction_date},"\
  " most_recent_transaction_date: #{@most_recent_transaction_date}, days_available:"\
  " #{@days_available}, average_days_between_transactions:"\
  " #{@average_days_between_transactions}, longest_gaps_between_transactions:"\
  " #{@longest_gaps_between_transactions}, number_of_inflows: #{@number_of_inflows},"\
  " average_inflow_amounts: #{@average_inflow_amounts}, number_of_outflows:"\
  " #{@number_of_outflows}, average_outflow_amounts: #{@average_outflow_amounts},"\
  " number_of_days_no_transactions: #{@number_of_days_no_transactions}, additional_properties:"\
  " #{@additional_properties}>"
end