Class: ThePlaidApi::IncomeInsights

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

Overview

Comprehensive income analysis including total income, income excluding transfers, and inbound transfer amounts.

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(total_income: SKIP, income_excluding_transfers: SKIP, transfers_in: SKIP, additional_properties: nil) ⇒ IncomeInsights

Returns a new instance of IncomeInsights.



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

def initialize(total_income: SKIP, income_excluding_transfers: SKIP,
               transfers_in: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_income = total_income unless total_income == SKIP
  unless income_excluding_transfers == SKIP
    @income_excluding_transfers =
      income_excluding_transfers
  end
  @transfers_in = transfers_in unless transfers_in == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#income_excluding_transfersAmountWithCurrencyWithMonthlyAverage

Income excluding account transfer transactions for the period, including a monthly average.



20
21
22
# File 'lib/the_plaid_api/models/income_insights.rb', line 20

def income_excluding_transfers
  @income_excluding_transfers
end

#total_incomeAmountWithCurrency

The total amount of all income transactions in the given time period.

Returns:



15
16
17
# File 'lib/the_plaid_api/models/income_insights.rb', line 15

def total_income
  @total_income
end

#transfers_inAmountWithCurrencyWithMonthlyAverage

Sum of inbound transfer transactions for the period, including a monthly average.



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

def transfers_in
  @transfers_in
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/the_plaid_api/models/income_insights.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_income = AmountWithCurrency.from_hash(hash['total_income']) if hash['total_income']
  if hash['income_excluding_transfers']
    income_excluding_transfers = AmountWithCurrencyWithMonthlyAverage.from_hash(hash['income_excluding_transfers'])
  end
  transfers_in = AmountWithCurrencyWithMonthlyAverage.from_hash(hash['transfers_in']) if
    hash['transfers_in']

  # 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.
  IncomeInsights.new(total_income: total_income,
                     income_excluding_transfers: income_excluding_transfers,
                     transfers_in: transfers_in,
                     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/income_insights.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_income'] = 'total_income'
  @_hash['income_excluding_transfers'] = 'income_excluding_transfers'
  @_hash['transfers_in'] = 'transfers_in'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    total_income
    income_excluding_transfers
    transfers_in
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    total_income
    income_excluding_transfers
    transfers_in
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



103
104
105
106
107
108
# File 'lib/the_plaid_api/models/income_insights.rb', line 103

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

#to_sObject

Provides a human-readable string representation of the object.



95
96
97
98
99
100
# File 'lib/the_plaid_api/models/income_insights.rb', line 95

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