Class: ThePlaidApi::BaseReportAttributes

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

Overview

Calculated attributes derived from transaction-level data.

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(is_primary_account: SKIP, primary_account_score: SKIP, nsf_overdraft_transactions_count: SKIP, nsf_overdraft_transactions_count_30d: SKIP, nsf_overdraft_transactions_count_60d: SKIP, nsf_overdraft_transactions_count_90d: SKIP, total_inflow_amount: SKIP, total_inflow_amount_30d: SKIP, total_inflow_amount_60d: SKIP, total_inflow_amount_90d: SKIP, total_outflow_amount: SKIP, total_outflow_amount_30d: SKIP, total_outflow_amount_60d: SKIP, total_outflow_amount_90d: SKIP, additional_properties: nil) ⇒ BaseReportAttributes

Returns a new instance of BaseReportAttributes.



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

def initialize(is_primary_account: SKIP, primary_account_score: SKIP,
               nsf_overdraft_transactions_count: SKIP,
               nsf_overdraft_transactions_count_30d: SKIP,
               nsf_overdraft_transactions_count_60d: SKIP,
               nsf_overdraft_transactions_count_90d: SKIP,
               total_inflow_amount: SKIP, total_inflow_amount_30d: SKIP,
               total_inflow_amount_60d: SKIP, total_inflow_amount_90d: SKIP,
               total_outflow_amount: SKIP, total_outflow_amount_30d: SKIP,
               total_outflow_amount_60d: SKIP,
               total_outflow_amount_90d: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @is_primary_account =  unless  == SKIP
  @primary_account_score =  unless  == SKIP
  unless nsf_overdraft_transactions_count == SKIP
    @nsf_overdraft_transactions_count =
      nsf_overdraft_transactions_count
  end
  unless nsf_overdraft_transactions_count_30d == SKIP
    @nsf_overdraft_transactions_count_30d =
      nsf_overdraft_transactions_count_30d
  end
  unless nsf_overdraft_transactions_count_60d == SKIP
    @nsf_overdraft_transactions_count_60d =
      nsf_overdraft_transactions_count_60d
  end
  unless nsf_overdraft_transactions_count_90d == SKIP
    @nsf_overdraft_transactions_count_90d =
      nsf_overdraft_transactions_count_90d
  end
  @total_inflow_amount = total_inflow_amount unless total_inflow_amount == SKIP
  @total_inflow_amount_30d = total_inflow_amount_30d unless total_inflow_amount_30d == SKIP
  @total_inflow_amount_60d = total_inflow_amount_60d unless total_inflow_amount_60d == SKIP
  @total_inflow_amount_90d = total_inflow_amount_90d unless total_inflow_amount_90d == SKIP
  @total_outflow_amount = total_outflow_amount unless total_outflow_amount == SKIP
  @total_outflow_amount_30d = total_outflow_amount_30d unless total_outflow_amount_30d == SKIP
  @total_outflow_amount_60d = total_outflow_amount_60d unless total_outflow_amount_60d == SKIP
  @total_outflow_amount_90d = total_outflow_amount_90d unless total_outflow_amount_90d == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#is_primary_accountTrueClass | FalseClass

Prediction indicator of whether the account is a primary account. Only one account per account type across the items connected will have a value of true.

Returns:

  • (TrueClass | FalseClass)


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

def 
  @is_primary_account
end

#nsf_overdraft_transactions_countInteger

The number of net NSF fee transactions for a given account within the report time range (not counting any fees that were reversed within the time range).

Returns:

  • (Integer)


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

def nsf_overdraft_transactions_count
  @nsf_overdraft_transactions_count
end

#nsf_overdraft_transactions_count_30dInteger

The number of net NSF fee transactions within the last 30 days for a given account (not counting any fees that were reversed within the time range).

Returns:

  • (Integer)


32
33
34
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 32

def nsf_overdraft_transactions_count_30d
  @nsf_overdraft_transactions_count_30d
end

#nsf_overdraft_transactions_count_60dInteger

The number of net NSF fee transactions within the last 60 days for a given account (not counting any fees that were reversed within the time range).

Returns:

  • (Integer)


37
38
39
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 37

def nsf_overdraft_transactions_count_60d
  @nsf_overdraft_transactions_count_60d
end

#nsf_overdraft_transactions_count_90dInteger

The number of net NSF fee transactions within the last 90 days for a given account (not counting any fees that were reversed within the time range).

Returns:

  • (Integer)


42
43
44
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 42

def nsf_overdraft_transactions_count_90d
  @nsf_overdraft_transactions_count_90d
end

#primary_account_scoreFloat

Value ranging from 0-1. The higher the score, the more confident we are of the account being the primary account.

Returns:

  • (Float)


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

def 
  @primary_account_score
end

#total_inflow_amountTotalInflowAmount

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

Returns:



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

def total_inflow_amount
  @total_inflow_amount
end

#total_inflow_amount_30dTotalInflowAmount30D

Total amount of debit transactions into the account in the last 30 days. This field will be empty for non-depository accounts. This field only takes into account USD transactions from the account.



54
55
56
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 54

def total_inflow_amount_30d
  @total_inflow_amount_30d
end

#total_inflow_amount_60dTotalInflowAmount60D

Total amount of debit transactions into the account in the last 60 days. This field will be empty for non-depository accounts. This field only takes into account USD transactions from the account.



60
61
62
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 60

def total_inflow_amount_60d
  @total_inflow_amount_60d
end

#total_inflow_amount_90dTotalInflowAmount90D

Total amount of debit transactions into the account in the last 90 days. This field will be empty for non-depository accounts. This field only takes into account USD transactions from the account.



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

def total_inflow_amount_90d
  @total_inflow_amount_90d
end

#total_outflow_amountTotalOutflowAmount

Total amount of credit transactions into the account in the time period of the report. This field will be empty for non-depository accounts. This field only takes into account USD transactions from the account.

Returns:



72
73
74
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 72

def total_outflow_amount
  @total_outflow_amount
end

#total_outflow_amount_30dTotalOutflowAmount30D

Total amount of credit transactions into the account in the last 30 days. This field will be empty for non-depository accounts. This field only takes into account USD transactions from the account.



78
79
80
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 78

def total_outflow_amount_30d
  @total_outflow_amount_30d
end

#total_outflow_amount_60dTotalOutflowAmount60D

Total amount of credit transactions into the account in the last 60 days. This field will be empty for non-depository accounts. This field only takes into account USD transactions from the account.



84
85
86
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 84

def total_outflow_amount_60d
  @total_outflow_amount_60d
end

#total_outflow_amount_90dTotalOutflowAmount90D

Total amount of credit transactions into the account in the last 90 days. This field will be empty for non-depository accounts. This field only takes into account USD transactions from the account.



90
91
92
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 90

def total_outflow_amount_90d
  @total_outflow_amount_90d
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 195

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   =
    hash.key?('is_primary_account') ? hash['is_primary_account'] : SKIP
   =
    hash.key?('primary_account_score') ? hash['primary_account_score'] : SKIP
  nsf_overdraft_transactions_count =
    hash.key?('nsf_overdraft_transactions_count') ? hash['nsf_overdraft_transactions_count'] : SKIP
  nsf_overdraft_transactions_count_30d =
    hash.key?('nsf_overdraft_transactions_count_30d') ? hash['nsf_overdraft_transactions_count_30d'] : SKIP
  nsf_overdraft_transactions_count_60d =
    hash.key?('nsf_overdraft_transactions_count_60d') ? hash['nsf_overdraft_transactions_count_60d'] : SKIP
  nsf_overdraft_transactions_count_90d =
    hash.key?('nsf_overdraft_transactions_count_90d') ? hash['nsf_overdraft_transactions_count_90d'] : SKIP
  total_inflow_amount = TotalInflowAmount.from_hash(hash['total_inflow_amount']) if
    hash['total_inflow_amount']
  total_inflow_amount_30d = TotalInflowAmount30D.from_hash(hash['total_inflow_amount_30d']) if
    hash['total_inflow_amount_30d']
  total_inflow_amount_60d = TotalInflowAmount60D.from_hash(hash['total_inflow_amount_60d']) if
    hash['total_inflow_amount_60d']
  total_inflow_amount_90d = TotalInflowAmount90D.from_hash(hash['total_inflow_amount_90d']) if
    hash['total_inflow_amount_90d']
  total_outflow_amount = TotalOutflowAmount.from_hash(hash['total_outflow_amount']) if
    hash['total_outflow_amount']
  if hash['total_outflow_amount_30d']
    total_outflow_amount_30d = TotalOutflowAmount30D.from_hash(hash['total_outflow_amount_30d'])
  end
  if hash['total_outflow_amount_60d']
    total_outflow_amount_60d = TotalOutflowAmount60D.from_hash(hash['total_outflow_amount_60d'])
  end
  if hash['total_outflow_amount_90d']
    total_outflow_amount_90d = TotalOutflowAmount90D.from_hash(hash['total_outflow_amount_90d'])
  end

  # 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.
  BaseReportAttributes.new(is_primary_account: ,
                           primary_account_score: ,
                           nsf_overdraft_transactions_count: nsf_overdraft_transactions_count,
                           nsf_overdraft_transactions_count_30d: nsf_overdraft_transactions_count_30d,
                           nsf_overdraft_transactions_count_60d: nsf_overdraft_transactions_count_60d,
                           nsf_overdraft_transactions_count_90d: nsf_overdraft_transactions_count_90d,
                           total_inflow_amount: total_inflow_amount,
                           total_inflow_amount_30d: total_inflow_amount_30d,
                           total_inflow_amount_60d: total_inflow_amount_60d,
                           total_inflow_amount_90d: total_inflow_amount_90d,
                           total_outflow_amount: total_outflow_amount,
                           total_outflow_amount_30d: total_outflow_amount_30d,
                           total_outflow_amount_60d: total_outflow_amount_60d,
                           total_outflow_amount_90d: total_outflow_amount_90d,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 93

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['is_primary_account'] = 'is_primary_account'
  @_hash['primary_account_score'] = 'primary_account_score'
  @_hash['nsf_overdraft_transactions_count'] =
    'nsf_overdraft_transactions_count'
  @_hash['nsf_overdraft_transactions_count_30d'] =
    'nsf_overdraft_transactions_count_30d'
  @_hash['nsf_overdraft_transactions_count_60d'] =
    'nsf_overdraft_transactions_count_60d'
  @_hash['nsf_overdraft_transactions_count_90d'] =
    'nsf_overdraft_transactions_count_90d'
  @_hash['total_inflow_amount'] = 'total_inflow_amount'
  @_hash['total_inflow_amount_30d'] = 'total_inflow_amount_30d'
  @_hash['total_inflow_amount_60d'] = 'total_inflow_amount_60d'
  @_hash['total_inflow_amount_90d'] = 'total_inflow_amount_90d'
  @_hash['total_outflow_amount'] = 'total_outflow_amount'
  @_hash['total_outflow_amount_30d'] = 'total_outflow_amount_30d'
  @_hash['total_outflow_amount_60d'] = 'total_outflow_amount_60d'
  @_hash['total_outflow_amount_90d'] = 'total_outflow_amount_90d'
  @_hash
end

.nullablesObject

An array for nullable fields



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 137

def self.nullables
  %w[
    is_primary_account
    primary_account_score
    total_inflow_amount
    total_inflow_amount_30d
    total_inflow_amount_60d
    total_inflow_amount_90d
    total_outflow_amount
    total_outflow_amount_30d
    total_outflow_amount_60d
    total_outflow_amount_90d
  ]
end

.optionalsObject

An array for optional fields



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 117

def self.optionals
  %w[
    is_primary_account
    primary_account_score
    nsf_overdraft_transactions_count
    nsf_overdraft_transactions_count_30d
    nsf_overdraft_transactions_count_60d
    nsf_overdraft_transactions_count_90d
    total_inflow_amount
    total_inflow_amount_30d
    total_inflow_amount_60d
    total_inflow_amount_90d
    total_outflow_amount
    total_outflow_amount_30d
    total_outflow_amount_60d
    total_outflow_amount_90d
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 274

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} is_primary_account: #{@is_primary_account.inspect}, primary_account_score:"\
  " #{@primary_account_score.inspect}, nsf_overdraft_transactions_count:"\
  " #{@nsf_overdraft_transactions_count.inspect}, nsf_overdraft_transactions_count_30d:"\
  " #{@nsf_overdraft_transactions_count_30d.inspect}, nsf_overdraft_transactions_count_60d:"\
  " #{@nsf_overdraft_transactions_count_60d.inspect}, nsf_overdraft_transactions_count_90d:"\
  " #{@nsf_overdraft_transactions_count_90d.inspect}, total_inflow_amount:"\
  " #{@total_inflow_amount.inspect}, total_inflow_amount_30d:"\
  " #{@total_inflow_amount_30d.inspect}, total_inflow_amount_60d:"\
  " #{@total_inflow_amount_60d.inspect}, total_inflow_amount_90d:"\
  " #{@total_inflow_amount_90d.inspect}, total_outflow_amount:"\
  " #{@total_outflow_amount.inspect}, total_outflow_amount_30d:"\
  " #{@total_outflow_amount_30d.inspect}, total_outflow_amount_60d:"\
  " #{@total_outflow_amount_60d.inspect}, total_outflow_amount_90d:"\
  " #{@total_outflow_amount_90d.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/the_plaid_api/models/base_report_attributes.rb', line 257

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} is_primary_account: #{@is_primary_account}, primary_account_score:"\
  " #{@primary_account_score}, nsf_overdraft_transactions_count:"\
  " #{@nsf_overdraft_transactions_count}, nsf_overdraft_transactions_count_30d:"\
  " #{@nsf_overdraft_transactions_count_30d}, nsf_overdraft_transactions_count_60d:"\
  " #{@nsf_overdraft_transactions_count_60d}, nsf_overdraft_transactions_count_90d:"\
  " #{@nsf_overdraft_transactions_count_90d}, total_inflow_amount: #{@total_inflow_amount},"\
  " total_inflow_amount_30d: #{@total_inflow_amount_30d}, total_inflow_amount_60d:"\
  " #{@total_inflow_amount_60d}, total_inflow_amount_90d: #{@total_inflow_amount_90d},"\
  " total_outflow_amount: #{@total_outflow_amount}, total_outflow_amount_30d:"\
  " #{@total_outflow_amount_30d}, total_outflow_amount_60d: #{@total_outflow_amount_60d},"\
  " total_outflow_amount_90d: #{@total_outflow_amount_90d}, additional_properties:"\
  " #{@additional_properties}>"
end