Class: ThePlaidApi::IncomeInsightsFilter

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

Overview

Filters the returned income streams based on the specified income categories. If no filters are requested, streams from the following default set of categories are returned: - ‘EARNED_INCOME.*` (`EARNED_INCOME.SALARY`, `EARNED_INCOME.GIG_ECONOMY`, `EARNED_INCOME.SELF_EMPLOYED`) - `BENEFITS.DISABILITY` - `RETIREMENT.*` (`RETIREMENT.GOVERNMENT_DERIVED`, `RETIREMENT.PRIVATE_RETIREMENT`, `RETIREMENT.PLAN_DISTRIBUTION`) The final list of income categories is generated by adding the `included_categories`, then removing the `excluded_categories`. Priority is given to `excluded_categories` in the case of collisions. Filter patterns supported:

  • ‘*`: All categories - `PRIMARY.*`: All categories within the specified

primary category - ‘PRIMARY.SECONDARY`: A specific income category For a list of income categories, see the [Income V2 Category Taxonomy](plaid.com/documents/income-v2-category-taxonomy.csv).

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(included_categories:, excluded_categories: SKIP, additional_properties: nil) ⇒ IncomeInsightsFilter

Returns a new instance of IncomeInsightsFilter.



52
53
54
55
56
57
58
59
60
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 52

def initialize(included_categories:, excluded_categories: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @included_categories = included_categories
  @excluded_categories = excluded_categories unless excluded_categories == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#excluded_categoriesArray[String]

Excludes income streams matching the specified categories.

Returns:

  • (Array[String])


30
31
32
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 30

def excluded_categories
  @excluded_categories
end

#included_categoriesArray[String]

Includes income streams matching the specified categories.

Returns:

  • (Array[String])


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

def included_categories
  @included_categories
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  included_categories =
    hash.key?('included_categories') ? hash['included_categories'] : nil
  excluded_categories =
    hash.key?('excluded_categories') ? hash['excluded_categories'] : 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.
  IncomeInsightsFilter.new(included_categories: included_categories,
                           excluded_categories: excluded_categories,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['included_categories'] = 'included_categories'
  @_hash['excluded_categories'] = 'excluded_categories'
  @_hash
end

.nullablesObject

An array for nullable fields



48
49
50
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 48

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
44
45
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 41

def self.optionals
  %w[
    excluded_categories
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



93
94
95
96
97
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 93

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

#to_sObject

Provides a human-readable string representation of the object.



86
87
88
89
90
# File 'lib/the_plaid_api/models/income_insights_filter.rb', line 86

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