Class: ThePlaidApi::OutlierTransactionsInsights

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

Overview

Insights into unusually large transactions that exceed typical spending patterns for the account.

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(transactions_count: SKIP, total_amount: SKIP, top_categories: SKIP, additional_properties: nil) ⇒ OutlierTransactionsInsights

Returns a new instance of OutlierTransactionsInsights.



53
54
55
56
57
58
59
60
61
62
# File 'lib/the_plaid_api/models/outlier_transactions_insights.rb', line 53

def initialize(transactions_count: SKIP, total_amount: SKIP,
               top_categories: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @transactions_count = transactions_count unless transactions_count == SKIP
  @total_amount = total_amount unless total_amount == SKIP
  @top_categories = top_categories unless top_categories == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#top_categoriesArray[CategoryExpenses]

Up to 3 top categories of expenses in this group.

Returns:



25
26
27
# File 'lib/the_plaid_api/models/outlier_transactions_insights.rb', line 25

def top_categories
  @top_categories
end

#total_amountAmountWithCurrency

A monetary amount with its associated currency information, supporting both official and unofficial currency codes.

Returns:



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

def total_amount
  @total_amount
end

#transactions_countInteger

The total number of transactions whose value is above the threshold of normal amounts for a given account.

Returns:

  • (Integer)


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

def transactions_count
  @transactions_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/the_plaid_api/models/outlier_transactions_insights.rb', line 65

def self.from_hash(hash)
  return nil unless hash

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

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

  # 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.
  OutlierTransactionsInsights.new(transactions_count: transactions_count,
                                  total_amount: total_amount,
                                  top_categories: top_categories,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/the_plaid_api/models/outlier_transactions_insights.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transactions_count'] = 'transactions_count'
  @_hash['total_amount'] = 'total_amount'
  @_hash['top_categories'] = 'top_categories'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
49
50
51
# File 'lib/the_plaid_api/models/outlier_transactions_insights.rb', line 46

def self.nullables
  %w[
    transactions_count
    total_amount
  ]
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
43
# File 'lib/the_plaid_api/models/outlier_transactions_insights.rb', line 37

def self.optionals
  %w[
    transactions_count
    total_amount
    top_categories
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transactions_count: #{@transactions_count.inspect}, total_amount:"\
  " #{@total_amount.inspect}, top_categories: #{@top_categories.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



98
99
100
101
102
# File 'lib/the_plaid_api/models/outlier_transactions_insights.rb', line 98

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} transactions_count: #{@transactions_count}, total_amount: #{@total_amount},"\
  " top_categories: #{@top_categories}, additional_properties: #{@additional_properties}>"
end