Class: ThePlaidApi::CraBankIncomeHistoricalSummary

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

Overview

The end user’s monthly summary for the income source(s).

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_amounts: SKIP, start_date: SKIP, end_date: SKIP, transactions: SKIP, additional_properties: nil) ⇒ CraBankIncomeHistoricalSummary

Returns a new instance of CraBankIncomeHistoricalSummary.



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 71

def initialize(total_amounts: SKIP, start_date: SKIP, end_date: SKIP,
               transactions: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_amounts = total_amounts unless total_amounts == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @transactions = transactions unless transactions == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#end_dateDate

The end date of the period included in this monthly summary. This date will be the last day of the month, unless the month being covered is a partial month because it is the last month included in the summary and the date range being requested does not end with the last day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


35
36
37
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 35

def end_date
  @end_date
end

#start_dateDate

The start date of the period covered in this monthly summary. This date will be the first day of the month, unless the month being covered is a partial month because it is the first month included in the summary and the date range being requested does not begin with the first day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


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

def start_date
  @start_date
end

#total_amountsArray[CreditAmountWithCurrency]

Total amount of earnings for the income source(s) of the user for the month in the summary. This can contain multiple amounts, with each amount denominated in one unique currency.

Returns:



17
18
19
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 17

def total_amounts
  @total_amounts
end

#transactionsArray[CraBankIncomeTransaction]

The end date of the period included in this monthly summary. This date will be the last day of the month, unless the month being covered is a partial month because it is the last month included in the summary and the date range being requested does not end with the last day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:



44
45
46
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 44

def transactions
  @transactions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



84
85
86
87
88
89
90
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
119
120
121
122
123
124
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 84

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  total_amounts = nil
  unless hash['total_amounts'].nil?
    total_amounts = []
    hash['total_amounts'].each do |structure|
      total_amounts << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  total_amounts = SKIP unless hash.key?('total_amounts')
  start_date = hash.key?('start_date') ? hash['start_date'] : SKIP
  end_date = hash.key?('end_date') ? hash['end_date'] : SKIP
  # Parameter is an array, so we need to iterate through it
  transactions = nil
  unless hash['transactions'].nil?
    transactions = []
    hash['transactions'].each do |structure|
      transactions << (CraBankIncomeTransaction.from_hash(structure) if structure)
    end
  end

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

  # 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.
  CraBankIncomeHistoricalSummary.new(total_amounts: total_amounts,
                                     start_date: start_date,
                                     end_date: end_date,
                                     transactions: transactions,
                                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amounts'] = 'total_amounts'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['transactions'] = 'transactions'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    total_amounts
    start_date
    end_date
    transactions
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



135
136
137
138
139
140
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 135

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amounts: #{@total_amounts.inspect}, start_date:"\
  " #{@start_date.inspect}, end_date: #{@end_date.inspect}, transactions:"\
  " #{@transactions.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



127
128
129
130
131
132
# File 'lib/the_plaid_api/models/cra_bank_income_historical_summary.rb', line 127

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amounts: #{@total_amounts}, start_date: #{@start_date}, end_date:"\
  " #{@end_date}, transactions: #{@transactions}, additional_properties:"\
  " #{@additional_properties}>"
end