Class: ThePlaidApi::InflowModel

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

Overview

The ‘inflow_model` allows you to model a test account that receives regular income or make regular payments on a loan. Any transactions generated by the `inflow_model` will appear in addition to randomly generated test data or transactions specified by `override_accounts`.

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(type:, income_amount:, payment_day_of_month:, transaction_name:, statement_day_of_month:, additional_properties: nil) ⇒ InflowModel

Returns a new instance of InflowModel.



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/the_plaid_api/models/inflow_model.rb', line 76

def initialize(type:, income_amount:, payment_day_of_month:,
               transaction_name:, statement_day_of_month:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @type = type
  @income_amount = income_amount
  @payment_day_of_month = payment_day_of_month
  @transaction_name = transaction_name
  @statement_day_of_month = statement_day_of_month
  @additional_properties = additional_properties
end

Instance Attribute Details

#income_amountFloat

Amount of income per month. This value is required if ‘type` is `monthly-income`.

Returns:

  • (Float)


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

def income_amount
  @income_amount
end

#payment_day_of_monthFloat

Number between 1 and 28, or ‘last` meaning the last day of the month. The day of the month on which the income transaction will appear. The name of the income transaction. This field is required if `type` is `monthly-income`, `monthly-balance-payment` or `monthly-interest-only-payment`.

Returns:

  • (Float)


40
41
42
# File 'lib/the_plaid_api/models/inflow_model.rb', line 40

def payment_day_of_month
  @payment_day_of_month
end

#statement_day_of_monthString

Number between 1 and 28, or ‘last` meaning the last day of the month. The day of the month on which the balance is calculated for the next payment. The name of the income transaction. This field is required if `type` is `monthly-balance-payment` or `monthly-interest-only-payment`.

Returns:

  • (String)


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

def statement_day_of_month
  @statement_day_of_month
end

#transaction_nameString

The name of the income transaction. This field is required if ‘type` is `monthly-income`, `monthly-balance-payment` or `monthly-interest-only-payment`.

Returns:

  • (String)


46
47
48
# File 'lib/the_plaid_api/models/inflow_model.rb', line 46

def transaction_name
  @transaction_name
end

#typeString

Inflow model. One of the following: ‘none`: No income `monthly-income`: Income occurs once per month `monthly-balance-payment`: Pays off the balance on a liability account at the given statement day of month. `monthly-interest-only-payment`: Makes an interest-only payment on a liability account at the given statement day of month. Note that account types supported by Liabilities will accrue interest in the Sandbox. The types impacted are account type `credit` with subtype `credit` or `paypal`, and account type `loan` with subtype `student` or `mortgage`.

Returns:

  • (String)


27
28
29
# File 'lib/the_plaid_api/models/inflow_model.rb', line 27

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/the_plaid_api/models/inflow_model.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : nil
  income_amount = hash.key?('income_amount') ? hash['income_amount'] : nil
  payment_day_of_month =
    hash.key?('payment_day_of_month') ? hash['payment_day_of_month'] : nil
  transaction_name =
    hash.key?('transaction_name') ? hash['transaction_name'] : nil
  statement_day_of_month =
    hash.key?('statement_day_of_month') ? hash['statement_day_of_month'] : 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.
  InflowModel.new(type: type,
                  income_amount: income_amount,
                  payment_day_of_month: payment_day_of_month,
                  transaction_name: transaction_name,
                  statement_day_of_month: statement_day_of_month,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['income_amount'] = 'income_amount'
  @_hash['payment_day_of_month'] = 'payment_day_of_month'
  @_hash['transaction_name'] = 'transaction_name'
  @_hash['statement_day_of_month'] = 'statement_day_of_month'
  @_hash
end

.nullablesObject

An array for nullable fields



72
73
74
# File 'lib/the_plaid_api/models/inflow_model.rb', line 72

def self.nullables
  []
end

.optionalsObject

An array for optional fields



67
68
69
# File 'lib/the_plaid_api/models/inflow_model.rb', line 67

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



129
130
131
132
133
134
135
# File 'lib/the_plaid_api/models/inflow_model.rb', line 129

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type.inspect}, income_amount: #{@income_amount.inspect},"\
  " payment_day_of_month: #{@payment_day_of_month.inspect}, transaction_name:"\
  " #{@transaction_name.inspect}, statement_day_of_month: #{@statement_day_of_month.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



121
122
123
124
125
126
# File 'lib/the_plaid_api/models/inflow_model.rb', line 121

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type}, income_amount: #{@income_amount}, payment_day_of_month:"\
  " #{@payment_day_of_month}, transaction_name: #{@transaction_name}, statement_day_of_month:"\
  " #{@statement_day_of_month}, additional_properties: #{@additional_properties}>"
end