Class: ThePlaidApi::ExpenditureSummary
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ThePlaidApi::ExpenditureSummary
- Defined in:
- lib/the_plaid_api/models/expenditure_summary.rb
Overview
Summary statistics for a specific expenditure category, including total amount, monthly average, and percentage of income.
Instance Attribute Summary collapse
-
#amount ⇒ Float
The total value of all the aggregated transactions in this expenditure category.
-
#iso_currency_code ⇒ String
The ISO-4217 currency code of the amount.
-
#monthly_average ⇒ MonthlyAverage
The monthly average amount calculated by dividing the total by the number of calendar months in the time period.
-
#percentage_of_income ⇒ Float
The percentage of the total inflows that was spent in this expenses group, within the given time window across all the accounts in the report.
-
#top_categories ⇒ Array[CategoryExpenses]
The primary credit categories of the expenses within the given time window, across all the accounts in the report.
-
#transactions_count ⇒ Integer
The total number of outflow transactions in this expenses group, within the given time window across all the accounts in the report.
-
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the amount.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, monthly_average: SKIP, transactions_count: SKIP, percentage_of_income: SKIP, top_categories: SKIP, additional_properties: nil) ⇒ ExpenditureSummary
constructor
A new instance of ExpenditureSummary.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, monthly_average: SKIP, transactions_count: SKIP, percentage_of_income: SKIP, top_categories: SKIP, additional_properties: nil) ⇒ ExpenditureSummary
Returns a new instance of ExpenditureSummary.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 97 def initialize(amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, monthly_average: SKIP, transactions_count: SKIP, percentage_of_income: SKIP, top_categories: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @amount = amount unless amount == SKIP @iso_currency_code = iso_currency_code unless iso_currency_code == SKIP @unofficial_currency_code = unofficial_currency_code unless unofficial_currency_code == SKIP @monthly_average = monthly_average unless monthly_average == SKIP @transactions_count = transactions_count unless transactions_count == SKIP @percentage_of_income = percentage_of_income unless percentage_of_income == SKIP @top_categories = top_categories unless top_categories == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Float
The total value of all the aggregated transactions in this expenditure category.
16 17 18 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 16 def amount @amount end |
#iso_currency_code ⇒ String
The ISO-4217 currency code of the amount. Always ‘null` if `unofficial_currency_code` is non-`null`.
21 22 23 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 21 def iso_currency_code @iso_currency_code end |
#monthly_average ⇒ MonthlyAverage
The monthly average amount calculated by dividing the total by the number of calendar months in the time period.
34 35 36 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 34 def monthly_average @monthly_average end |
#percentage_of_income ⇒ Float
The percentage of the total inflows that was spent in this expenses group, within the given time window across all the accounts in the report. For example, a value of 100 represents that 100% of the inflows were spent on transactions that fall into this expenditure group. If there’s no available income for the giving time period, this field value will be ‘-1`.
48 49 50 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 48 def percentage_of_income @percentage_of_income end |
#top_categories ⇒ Array[CategoryExpenses]
The primary credit categories of the expenses within the given time window, across all the accounts in the report. The categories are sorted in descending order by the total value spent. See the [category taxonomy](plaid.com/documents/credit-category-taxonomy.csv) for a full listing of category IDs.
57 58 59 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 57 def top_categories @top_categories end |
#transactions_count ⇒ Integer
The total number of outflow transactions in this expenses group, within the given time window across all the accounts in the report.
39 40 41 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 39 def transactions_count @transactions_count end |
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the amount. Always ‘null` if `iso_currency_code` is non-`null`. See the [currency code schema](plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `unofficial_currency_code`s.
29 30 31 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 29 def unofficial_currency_code @unofficial_currency_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 115 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : SKIP iso_currency_code = hash.key?('iso_currency_code') ? hash['iso_currency_code'] : SKIP unofficial_currency_code = hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : SKIP monthly_average = MonthlyAverage.from_hash(hash['monthly_average']) if hash['monthly_average'] transactions_count = hash.key?('transactions_count') ? hash['transactions_count'] : SKIP percentage_of_income = hash.key?('percentage_of_income') ? hash['percentage_of_income'] : SKIP # Parameter is an array, so we need to iterate through it top_categories = nil unless hash['top_categories'].nil? top_categories = [] hash['top_categories'].each do |structure| top_categories << (CategoryExpenses.from_hash(structure) if structure) end end top_categories = SKIP unless hash.key?('top_categories') # 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. ExpenditureSummary.new(amount: amount, iso_currency_code: iso_currency_code, unofficial_currency_code: unofficial_currency_code, monthly_average: monthly_average, transactions_count: transactions_count, percentage_of_income: percentage_of_income, top_categories: top_categories, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 60 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['iso_currency_code'] = 'iso_currency_code' @_hash['unofficial_currency_code'] = 'unofficial_currency_code' @_hash['monthly_average'] = 'monthly_average' @_hash['transactions_count'] = 'transactions_count' @_hash['percentage_of_income'] = 'percentage_of_income' @_hash['top_categories'] = 'top_categories' @_hash end |
.nullables ⇒ Object
An array for nullable fields
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 86 def self.nullables %w[ amount iso_currency_code unofficial_currency_code monthly_average transactions_count percentage_of_income ] end |
.optionals ⇒ Object
An array for optional fields
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 73 def self.optionals %w[ amount iso_currency_code unofficial_currency_code monthly_average transactions_count percentage_of_income top_categories ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
170 171 172 173 174 175 176 177 178 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 170 def inspect class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount.inspect}, iso_currency_code:"\ " #{@iso_currency_code.inspect}, unofficial_currency_code:"\ " #{@unofficial_currency_code.inspect}, monthly_average: #{@monthly_average.inspect},"\ " transactions_count: #{@transactions_count.inspect}, percentage_of_income:"\ " #{@percentage_of_income.inspect}, top_categories: #{@top_categories.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
160 161 162 163 164 165 166 167 |
# File 'lib/the_plaid_api/models/expenditure_summary.rb', line 160 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, iso_currency_code: #{@iso_currency_code},"\ " unofficial_currency_code: #{@unofficial_currency_code}, monthly_average:"\ " #{@monthly_average}, transactions_count: #{@transactions_count}, percentage_of_income:"\ " #{@percentage_of_income}, top_categories: #{@top_categories}, additional_properties:"\ " #{@additional_properties}>" end |