Class: ThePlaidApi::RecurringInsightsStream

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

Overview

Insights object for recurring transactions streams.

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(stream_id:, merchant_name:, average_days_apart:, is_active:, description: SKIP, oldest_transaction_date: SKIP, newest_transaction_date: SKIP, frequency: SKIP, transaction_count: SKIP, transaction_ids: SKIP, average_amount: SKIP, newest_transaction_amount: SKIP, status: SKIP, personal_finance_category_primary: SKIP, personal_finance_category_detailed: SKIP, additional_properties: nil) ⇒ RecurringInsightsStream

Returns a new instance of RecurringInsightsStream.



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

def initialize(stream_id:, merchant_name:, average_days_apart:, is_active:,
               description: SKIP, oldest_transaction_date: SKIP,
               newest_transaction_date: SKIP, frequency: SKIP,
               transaction_count: SKIP, transaction_ids: SKIP,
               average_amount: SKIP, newest_transaction_amount: SKIP,
               status: SKIP, personal_finance_category_primary: SKIP,
               personal_finance_category_detailed: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @stream_id = stream_id
  @description = description unless description == SKIP
  @merchant_name = merchant_name
  @oldest_transaction_date = oldest_transaction_date unless oldest_transaction_date == SKIP
  @newest_transaction_date = newest_transaction_date unless newest_transaction_date == SKIP
  @average_days_apart = average_days_apart
  @frequency = frequency unless frequency == SKIP
  @transaction_count = transaction_count unless transaction_count == SKIP
  @transaction_ids = transaction_ids unless transaction_ids == SKIP
  @average_amount = average_amount unless average_amount == SKIP
  unless newest_transaction_amount == SKIP
    @newest_transaction_amount =
      newest_transaction_amount
  end
  @is_active = is_active
  @status = status unless status == SKIP
  unless personal_finance_category_primary == SKIP
    @personal_finance_category_primary =
      personal_finance_category_primary
  end
  unless personal_finance_category_detailed == SKIP
    @personal_finance_category_detailed =
      personal_finance_category_detailed
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#average_amountTransactionStreamAmount

Object with data pertaining to an amount on the transaction stream.



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

def average_amount
  @average_amount
end

#average_days_apartFloat

The average number of days between each of the recurring transactions.

Returns:

  • (Float)


36
37
38
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 36

def average_days_apart
  @average_days_apart
end

#descriptionString

The client-provided raw description of the most recent transaction in the stream.

Returns:

  • (String)


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

def description
  @description
end

#frequencyRecurringTransactionFrequency

Describes the frequency of the transaction stream. ‘WEEKLY`: Assigned to a transaction stream that occurs approximately every week. `BIWEEKLY`: Assigned to a transaction stream that occurs approximately every 2 weeks. `SEMI_MONTHLY`: Assigned to a transaction stream that occurs approximately twice per month. This frequency is typically seen for inflow transaction streams. `MONTHLY`: Assigned to a transaction stream that occurs approximately every month. `ANNUALLY`: Assigned to a transaction stream that occurs approximately every year. `UNKNOWN`: Assigned to a transaction stream that does not fit any of the pre-defined frequencies.



53
54
55
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 53

def frequency
  @frequency
end

#is_activeTrueClass | FalseClass

Indicates whether the transaction stream is still live.

Returns:

  • (TrueClass | FalseClass)


74
75
76
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 74

def is_active
  @is_active
end

#merchant_nameString

The merchant or primary counterparty associated with the transaction stream.

Returns:

  • (String)


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

def merchant_name
  @merchant_name
end

#newest_transaction_amountTransactionStreamAmount

Object with data pertaining to an amount on the transaction stream.



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

def newest_transaction_amount
  @newest_transaction_amount
end

#newest_transaction_dateDate

The posted date of the latest transaction in the stream.

Returns:

  • (Date)


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

def newest_transaction_date
  @newest_transaction_date
end

#oldest_transaction_dateDate

The posted date of the earliest transaction in the stream.

Returns:

  • (Date)


28
29
30
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 28

def oldest_transaction_date
  @oldest_transaction_date
end

#personal_finance_category_detailedString

The detailed category associated with the transaction stream.

Returns:

  • (String)


97
98
99
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 97

def personal_finance_category_detailed
  @personal_finance_category_detailed
end

#personal_finance_category_primaryString

The primary category associated with the transaction stream.

Returns:

  • (String)


93
94
95
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 93

def personal_finance_category_primary
  @personal_finance_category_primary
end

#statusTransactionStreamStatus

The current status of the transaction stream. ‘MATURE`: A `MATURE` recurring stream should have at least 3 transactions and happen on a regular cadence (For Annual recurring stream, we will mark it `MATURE` after 2 instances). `EARLY_DETECTION`: When a recurring transaction first appears in the transaction history and before it fulfills the requirement of a mature stream, the status will be `EARLY_DETECTION`. `TOMBSTONED`: A stream that was previously in the `EARLY_DETECTION` status will move to the `TOMBSTONED` status when no further transactions were found at the next expected date. `UNKNOWN`: A stream is assigned an `UNKNOWN` status when none of the other statuses are applicable.



89
90
91
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 89

def status
  @status
end

#stream_idString

A unique id for the stream.

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 14

def stream_id
  @stream_id
end

#transaction_countInteger

The number of transactions in this stream.

Returns:

  • (Integer)


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

def transaction_count
  @transaction_count
end

#transaction_idsArray[String]

An array of Plaid transaction IDs belonging to the stream, sorted by posted date.

Returns:

  • (Array[String])


62
63
64
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 62

def transaction_ids
  @transaction_ids
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
228
229
230
231
232
233
234
235
236
237
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 183

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  stream_id = hash.key?('stream_id') ? hash['stream_id'] : nil
  merchant_name = hash.key?('merchant_name') ? hash['merchant_name'] : nil
  average_days_apart =
    hash.key?('average_days_apart') ? hash['average_days_apart'] : nil
  is_active = hash.key?('is_active') ? hash['is_active'] : nil
  description = hash.key?('description') ? hash['description'] : SKIP
  oldest_transaction_date =
    hash.key?('oldest_transaction_date') ? hash['oldest_transaction_date'] : SKIP
  newest_transaction_date =
    hash.key?('newest_transaction_date') ? hash['newest_transaction_date'] : SKIP
  frequency = hash.key?('frequency') ? hash['frequency'] : SKIP
  transaction_count =
    hash.key?('transaction_count') ? hash['transaction_count'] : SKIP
  transaction_ids =
    hash.key?('transaction_ids') ? hash['transaction_ids'] : SKIP
  average_amount = TransactionStreamAmount.from_hash(hash['average_amount']) if
    hash['average_amount']
  if hash['newest_transaction_amount']
    newest_transaction_amount = TransactionStreamAmount.from_hash(hash['newest_transaction_amount'])
  end
  status = hash.key?('status') ? hash['status'] : SKIP
  personal_finance_category_primary =
    hash.key?('personal_finance_category_primary') ? hash['personal_finance_category_primary'] : SKIP
  personal_finance_category_detailed =
    hash.key?('personal_finance_category_detailed') ? hash['personal_finance_category_detailed'] : 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.
  RecurringInsightsStream.new(stream_id: stream_id,
                              merchant_name: merchant_name,
                              average_days_apart: average_days_apart,
                              is_active: is_active,
                              description: description,
                              oldest_transaction_date: oldest_transaction_date,
                              newest_transaction_date: newest_transaction_date,
                              frequency: frequency,
                              transaction_count: transaction_count,
                              transaction_ids: transaction_ids,
                              average_amount: average_amount,
                              newest_transaction_amount: newest_transaction_amount,
                              status: status,
                              personal_finance_category_primary: personal_finance_category_primary,
                              personal_finance_category_detailed: personal_finance_category_detailed,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 100

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['stream_id'] = 'stream_id'
  @_hash['description'] = 'description'
  @_hash['merchant_name'] = 'merchant_name'
  @_hash['oldest_transaction_date'] = 'oldest_transaction_date'
  @_hash['newest_transaction_date'] = 'newest_transaction_date'
  @_hash['average_days_apart'] = 'average_days_apart'
  @_hash['frequency'] = 'frequency'
  @_hash['transaction_count'] = 'transaction_count'
  @_hash['transaction_ids'] = 'transaction_ids'
  @_hash['average_amount'] = 'average_amount'
  @_hash['newest_transaction_amount'] = 'newest_transaction_amount'
  @_hash['is_active'] = 'is_active'
  @_hash['status'] = 'status'
  @_hash['personal_finance_category_primary'] =
    'personal_finance_category_primary'
  @_hash['personal_finance_category_detailed'] =
    'personal_finance_category_detailed'
  @_hash
end

.nullablesObject

An array for nullable fields



140
141
142
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 140

def self.nullables
  []
end

.optionalsObject

An array for optional fields



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 123

def self.optionals
  %w[
    description
    oldest_transaction_date
    newest_transaction_date
    frequency
    transaction_count
    transaction_ids
    average_amount
    newest_transaction_amount
    status
    personal_finance_category_primary
    personal_finance_category_detailed
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 254

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} stream_id: #{@stream_id.inspect}, description: #{@description.inspect},"\
  " merchant_name: #{@merchant_name.inspect}, oldest_transaction_date:"\
  " #{@oldest_transaction_date.inspect}, newest_transaction_date:"\
  " #{@newest_transaction_date.inspect}, average_days_apart: #{@average_days_apart.inspect},"\
  " frequency: #{@frequency.inspect}, transaction_count: #{@transaction_count.inspect},"\
  " transaction_ids: #{@transaction_ids.inspect}, average_amount: #{@average_amount.inspect},"\
  " newest_transaction_amount: #{@newest_transaction_amount.inspect}, is_active:"\
  " #{@is_active.inspect}, status: #{@status.inspect}, personal_finance_category_primary:"\
  " #{@personal_finance_category_primary.inspect}, personal_finance_category_detailed:"\
  " #{@personal_finance_category_detailed.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/the_plaid_api/models/recurring_insights_stream.rb', line 240

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} stream_id: #{@stream_id}, description: #{@description}, merchant_name:"\
  " #{@merchant_name}, oldest_transaction_date: #{@oldest_transaction_date},"\
  " newest_transaction_date: #{@newest_transaction_date}, average_days_apart:"\
  " #{@average_days_apart}, frequency: #{@frequency}, transaction_count:"\
  " #{@transaction_count}, transaction_ids: #{@transaction_ids}, average_amount:"\
  " #{@average_amount}, newest_transaction_amount: #{@newest_transaction_amount}, is_active:"\
  " #{@is_active}, status: #{@status}, personal_finance_category_primary:"\
  " #{@personal_finance_category_primary}, personal_finance_category_detailed:"\
  " #{@personal_finance_category_detailed}, additional_properties: #{@additional_properties}>"
end