Class: ThePlaidApi::MerchantInsights

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

Overview

Insights into a user’s 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(name:, website:, transaction_count:, personal_finance_category_primary:, personal_finance_category_detailed:, total_outflows:, total_inflows:, entity_id: SKIP, additional_properties: nil) ⇒ MerchantInsights

Returns a new instance of MerchantInsights.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 77

def initialize(name:, website:, transaction_count:,
               personal_finance_category_primary:,
               personal_finance_category_detailed:, total_outflows:,
               total_inflows:, entity_id: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name
  @entity_id = entity_id unless entity_id == SKIP
  @website = website
  @transaction_count = transaction_count
  @personal_finance_category_primary = personal_finance_category_primary
  @personal_finance_category_detailed = personal_finance_category_detailed
  @total_outflows = total_outflows
  @total_inflows = total_inflows
  @additional_properties = additional_properties
end

Instance Attribute Details

#entity_idString

A unique, stable, Plaid-generated id that maps to the merchant.

Returns:

  • (String)


18
19
20
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 18

def entity_id
  @entity_id
end

#nameString

The counterparty name.

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 14

def name
  @name
end

#personal_finance_category_detailedString

The detailed personal finance category associated with this merchant.

Returns:

  • (String)


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

def personal_finance_category_detailed
  @personal_finance_category_detailed
end

#personal_finance_category_primaryString

The primary personal finance category associated with this merchant.

Returns:

  • (String)


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

def personal_finance_category_primary
  @personal_finance_category_primary
end

#total_inflowsFloat

Sum of inflow amounts.

Returns:

  • (Float)


42
43
44
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 42

def total_inflows
  @total_inflows
end

#total_outflowsFloat

Sum of outflow amounts.

Returns:

  • (Float)


38
39
40
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 38

def total_outflows
  @total_outflows
end

#transaction_countInteger

The number of transactions associated with merchant of this type.

Returns:

  • (Integer)


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

def transaction_count
  @transaction_count
end

#websiteString

The website associated with the merchant.

Returns:

  • (String)


22
23
24
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 22

def website
  @website
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
125
126
127
128
129
130
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 96

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  website = hash.key?('website') ? hash['website'] : nil
  transaction_count =
    hash.key?('transaction_count') ? hash['transaction_count'] : nil
  personal_finance_category_primary =
    hash.key?('personal_finance_category_primary') ? hash['personal_finance_category_primary'] : nil
  personal_finance_category_detailed =
    hash.key?('personal_finance_category_detailed') ? hash['personal_finance_category_detailed'] : nil
  total_outflows =
    hash.key?('total_outflows') ? hash['total_outflows'] : nil
  total_inflows = hash.key?('total_inflows') ? hash['total_inflows'] : nil
  entity_id = hash.key?('entity_id') ? hash['entity_id'] : 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.
  MerchantInsights.new(name: name,
                       website: website,
                       transaction_count: transaction_count,
                       personal_finance_category_primary: personal_finance_category_primary,
                       personal_finance_category_detailed: personal_finance_category_detailed,
                       total_outflows: total_outflows,
                       total_inflows: total_inflows,
                       entity_id: entity_id,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['entity_id'] = 'entity_id'
  @_hash['website'] = 'website'
  @_hash['transaction_count'] = 'transaction_count'
  @_hash['personal_finance_category_primary'] =
    'personal_finance_category_primary'
  @_hash['personal_finance_category_detailed'] =
    'personal_finance_category_detailed'
  @_hash['total_outflows'] = 'total_outflows'
  @_hash['total_inflows'] = 'total_inflows'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
71
72
73
74
75
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 68

def self.nullables
  %w[
    entity_id
    website
    personal_finance_category_primary
    personal_finance_category_detailed
  ]
end

.optionalsObject

An array for optional fields



61
62
63
64
65
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 61

def self.optionals
  %w[
    entity_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



143
144
145
146
147
148
149
150
151
# File 'lib/the_plaid_api/models/merchant_insights.rb', line 143

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name.inspect}, entity_id: #{@entity_id.inspect}, website:"\
  " #{@website.inspect}, transaction_count: #{@transaction_count.inspect},"\
  " personal_finance_category_primary: #{@personal_finance_category_primary.inspect},"\
  " personal_finance_category_detailed: #{@personal_finance_category_detailed.inspect},"\
  " total_outflows: #{@total_outflows.inspect}, total_inflows: #{@total_inflows.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name}, entity_id: #{@entity_id}, website: #{@website},"\
  " transaction_count: #{@transaction_count}, personal_finance_category_primary:"\
  " #{@personal_finance_category_primary}, personal_finance_category_detailed:"\
  " #{@personal_finance_category_detailed}, total_outflows: #{@total_outflows}, total_inflows:"\
  " #{@total_inflows}, additional_properties: #{@additional_properties}>"
end