Class: ThePlaidApi::CategoryInsightDetails

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

Overview

Insights object for categories.

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(name:, transaction_count:, total_outflows:, total_inflows:, top_counterparties: SKIP, additional_properties: nil) ⇒ CategoryInsightDetails

Returns a new instance of CategoryInsightDetails.



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/the_plaid_api/models/category_insight_details.rb', line 56

def initialize(name:, transaction_count:, total_outflows:, total_inflows:,
               top_counterparties: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name
  @transaction_count = transaction_count
  @total_outflows = total_outflows
  @total_inflows = total_inflows
  @top_counterparties = top_counterparties unless top_counterparties == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#nameString

Category name.

Returns:

  • (String)


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

def name
  @name
end

#top_counterpartiesArray[String]

The most common counterparties associated with this category sorted by outflow.

Returns:

  • (Array[String])


31
32
33
# File 'lib/the_plaid_api/models/category_insight_details.rb', line 31

def top_counterparties
  @top_counterparties
end

#total_inflowsFloat

Sum of inflow amounts.

Returns:

  • (Float)


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

def total_inflows
  @total_inflows
end

#total_outflowsFloat

Sum of outflow amounts.

Returns:

  • (Float)


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

def total_outflows
  @total_outflows
end

#transaction_countInteger

The number of transactions associated with this category.

Returns:

  • (Integer)


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

def transaction_count
  @transaction_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
96
97
# File 'lib/the_plaid_api/models/category_insight_details.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  transaction_count =
    hash.key?('transaction_count') ? hash['transaction_count'] : nil
  total_outflows =
    hash.key?('total_outflows') ? hash['total_outflows'] : nil
  total_inflows = hash.key?('total_inflows') ? hash['total_inflows'] : nil
  top_counterparties =
    hash.key?('top_counterparties') ? hash['top_counterparties'] : 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.
  CategoryInsightDetails.new(name: name,
                             transaction_count: transaction_count,
                             total_outflows: total_outflows,
                             total_inflows: total_inflows,
                             top_counterparties: top_counterparties,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/the_plaid_api/models/category_insight_details.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['transaction_count'] = 'transaction_count'
  @_hash['total_outflows'] = 'total_outflows'
  @_hash['total_inflows'] = 'total_inflows'
  @_hash['top_counterparties'] = 'top_counterparties'
  @_hash
end

.nullablesObject

An array for nullable fields



52
53
54
# File 'lib/the_plaid_api/models/category_insight_details.rb', line 52

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
# File 'lib/the_plaid_api/models/category_insight_details.rb', line 45

def self.optionals
  %w[
    top_counterparties
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



108
109
110
111
112
113
114
# File 'lib/the_plaid_api/models/category_insight_details.rb', line 108

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name.inspect}, transaction_count: #{@transaction_count.inspect},"\
  " total_outflows: #{@total_outflows.inspect}, total_inflows: #{@total_inflows.inspect},"\
  " top_counterparties: #{@top_counterparties.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name}, transaction_count: #{@transaction_count}, total_outflows:"\
  " #{@total_outflows}, total_inflows: #{@total_inflows}, top_counterparties:"\
  " #{@top_counterparties}, additional_properties: #{@additional_properties}>"
end