Class: ThePlaidApi::GamblingIndicators

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

Overview

Insights into gambling-related transactions, including frequency, amounts, and top merchants.

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(amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, monthly_average: SKIP, top_merchants: SKIP, transactions_count: SKIP, monthly_summaries: SKIP, days_since_last_occurrence: SKIP, percentage_of_income: SKIP, additional_properties: nil) ⇒ GamblingIndicators

Returns a new instance of GamblingIndicators.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 112

def initialize(amount: SKIP, iso_currency_code: SKIP,
               unofficial_currency_code: SKIP, monthly_average: SKIP,
               top_merchants: SKIP, transactions_count: SKIP,
               monthly_summaries: SKIP, days_since_last_occurrence: SKIP,
               percentage_of_income: 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
  @top_merchants = top_merchants unless top_merchants == SKIP
  @transactions_count = transactions_count unless transactions_count == SKIP
  @monthly_summaries = monthly_summaries unless monthly_summaries == SKIP
  unless days_since_last_occurrence == SKIP
    @days_since_last_occurrence =
      days_since_last_occurrence
  end
  @percentage_of_income = percentage_of_income unless percentage_of_income == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

The total value of transactions that fall into the ‘GAMBLING` credit category, across all the accounts in the report.

Returns:

  • (Float)


16
17
18
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 16

def amount
  @amount
end

#days_since_last_occurrenceInteger

The number of days since the last transaction that falls into the ‘GAMBLING` category, across all the accounts in the report.

Returns:

  • (Integer)


57
58
59
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 57

def days_since_last_occurrence
  @days_since_last_occurrence
end

#iso_currency_codeString

The ISO-4217 currency code of the amount. Always ‘null` if `unofficial_currency_code` is non-`null`.

Returns:

  • (String)


21
22
23
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 21

def iso_currency_code
  @iso_currency_code
end

#monthly_averageMonthlyAverage

The monthly average amount calculated by dividing the total by the number of calendar months in the time period.

Returns:



34
35
36
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 34

def monthly_average
  @monthly_average
end

#monthly_summariesArray[MonthlySummary]

The monthly summaries of the transactions that fall into the ‘GAMBLING` category within the given time window, across all the accounts in the report.

Returns:



52
53
54
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 52

def monthly_summaries
  @monthly_summaries
end

#percentage_of_incomeFloat

The percentage of the user’s monthly inflows that was spent on transactions that fall into the ‘GAMBLING` category within the given time window, across all the accounts in the report. For example, a value of 100 indicates that 100% of the inflows were spent on transactions that fall into the `GAMBLING` credit category. If there’s no available income for the given time period, this field value will be ‘-1`

Returns:

  • (Float)


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

def percentage_of_income
  @percentage_of_income
end

#top_merchantsArray[String]

Up to 3 top merchants that the user had the most transactions for in the given time window, in descending order of total spend. If the user has not spent money on any merchants in the given time window, this list will be empty.

Returns:

  • (Array[String])


41
42
43
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 41

def top_merchants
  @top_merchants
end

#transactions_countInteger

The total number of transactions that fall into the ‘GAMBLING` credit category, across all the accounts in the report.

Returns:

  • (Integer)


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

def transactions_count
  @transactions_count
end

#unofficial_currency_codeString

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.

Returns:

  • (String)


29
30
31
# File 'lib/the_plaid_api/models/gambling_indicators.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.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 136

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']
  top_merchants = hash.key?('top_merchants') ? hash['top_merchants'] : SKIP
  transactions_count =
    hash.key?('transactions_count') ? hash['transactions_count'] : SKIP
  # Parameter is an array, so we need to iterate through it
  monthly_summaries = nil
  unless hash['monthly_summaries'].nil?
    monthly_summaries = []
    hash['monthly_summaries'].each do |structure|
      monthly_summaries << (MonthlySummary.from_hash(structure) if structure)
    end
  end

  monthly_summaries = SKIP unless hash.key?('monthly_summaries')
  days_since_last_occurrence =
    hash.key?('days_since_last_occurrence') ? hash['days_since_last_occurrence'] : SKIP
  percentage_of_income =
    hash.key?('percentage_of_income') ? hash['percentage_of_income'] : SKIP

  # 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.
  GamblingIndicators.new(amount: amount,
                         iso_currency_code: iso_currency_code,
                         unofficial_currency_code: unofficial_currency_code,
                         monthly_average: monthly_average,
                         top_merchants: top_merchants,
                         transactions_count: transactions_count,
                         monthly_summaries: monthly_summaries,
                         days_since_last_occurrence: days_since_last_occurrence,
                         percentage_of_income: percentage_of_income,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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['top_merchants'] = 'top_merchants'
  @_hash['transactions_count'] = 'transactions_count'
  @_hash['monthly_summaries'] = 'monthly_summaries'
  @_hash['days_since_last_occurrence'] = 'days_since_last_occurrence'
  @_hash['percentage_of_income'] = 'percentage_of_income'
  @_hash
end

.nullablesObject

An array for nullable fields



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 100

def self.nullables
  %w[
    amount
    iso_currency_code
    unofficial_currency_code
    monthly_average
    transactions_count
    days_since_last_occurrence
    percentage_of_income
  ]
end

.optionalsObject

An array for optional fields



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 85

def self.optionals
  %w[
    amount
    iso_currency_code
    unofficial_currency_code
    monthly_average
    top_merchants
    transactions_count
    monthly_summaries
    days_since_last_occurrence
    percentage_of_income
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



197
198
199
200
201
202
203
204
205
206
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 197

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},"\
  " top_merchants: #{@top_merchants.inspect}, transactions_count:"\
  " #{@transactions_count.inspect}, monthly_summaries: #{@monthly_summaries.inspect},"\
  " days_since_last_occurrence: #{@days_since_last_occurrence.inspect}, percentage_of_income:"\
  " #{@percentage_of_income.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



186
187
188
189
190
191
192
193
194
# File 'lib/the_plaid_api/models/gambling_indicators.rb', line 186

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}, top_merchants: #{@top_merchants}, transactions_count:"\
  " #{@transactions_count}, monthly_summaries: #{@monthly_summaries},"\
  " days_since_last_occurrence: #{@days_since_last_occurrence}, percentage_of_income:"\
  " #{@percentage_of_income}, additional_properties: #{@additional_properties}>"
end