Class: ThePlaidApi::CraIncomeMetrics

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

Overview

Modeled income metrics for a given income stream or user summary.

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(current:, projected:, iso_currency_code:, unofficial_currency_code:, additional_properties: nil) ⇒ CraIncomeMetrics

Returns a new instance of CraIncomeMetrics.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/the_plaid_api/models/cra_income_metrics.rb', line 59

def initialize(current:, projected:, iso_currency_code:,
               unofficial_currency_code:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @current = current
  @projected = projected
  @iso_currency_code = iso_currency_code
  @unofficial_currency_code = unofficial_currency_code
  @additional_properties = additional_properties
end

Instance Attribute Details

#currentCraCurrentModeledIncome

Modeled estimate of current income based on recently observed income transactions.



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

def current
  @current
end

#iso_currency_codeString

The ISO 4217 currency code of the amount or balance.

Returns:

  • (String)


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

def iso_currency_code
  @iso_currency_code
end

#projectedCraProjectedModeledIncome

Forward-looking modeled estimate of income based on recent income transactions and trends in active streams.



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

def projected
  @projected
end

#unofficial_currency_codeString

The unofficial currency code associated with the amount or balance. Always ‘null` if `iso_currency_code` is non-null. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries.

Returns:

  • (String)


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

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  current = CraCurrentModeledIncome.from_hash(hash['current']) if hash['current']
  projected = CraProjectedModeledIncome.from_hash(hash['projected']) if hash['projected']
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil
  unofficial_currency_code =
    hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : nil

  # 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.
  CraIncomeMetrics.new(current: current,
                       projected: projected,
                       iso_currency_code: iso_currency_code,
                       unofficial_currency_code: unofficial_currency_code,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['current'] = 'current'
  @_hash['projected'] = 'projected'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
53
54
55
56
57
# File 'lib/the_plaid_api/models/cra_income_metrics.rb', line 50

def self.nullables
  %w[
    current
    projected
    iso_currency_code
    unofficial_currency_code
  ]
end

.optionalsObject

An array for optional fields



45
46
47
# File 'lib/the_plaid_api/models/cra_income_metrics.rb', line 45

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



107
108
109
110
111
112
# File 'lib/the_plaid_api/models/cra_income_metrics.rb', line 107

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} current: #{@current.inspect}, projected: #{@projected.inspect},"\
  " iso_currency_code: #{@iso_currency_code.inspect}, unofficial_currency_code:"\
  " #{@unofficial_currency_code.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} current: #{@current}, projected: #{@projected}, iso_currency_code:"\
  " #{@iso_currency_code}, unofficial_currency_code: #{@unofficial_currency_code},"\
  " additional_properties: #{@additional_properties}>"
end