Class: ThePlaidApi::DetectedAccount

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

Overview

A possible account detected to be associated with a transaction user.

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(account_type:, account_subtype:, transaction_count:, total_outflows:, total_inflows:, oldest_transaction_date: SKIP, newest_transaction_date: SKIP, newest_transaction_amount: SKIP, additional_properties: nil) ⇒ DetectedAccount

Returns a new instance of DetectedAccount.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/the_plaid_api/models/detected_account.rb', line 82

def initialize(account_type:, account_subtype:, transaction_count:,
               total_outflows:, total_inflows:,
               oldest_transaction_date: SKIP, newest_transaction_date: SKIP,
               newest_transaction_amount: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_type = 
  @account_subtype = 
  @transaction_count = transaction_count
  @oldest_transaction_date = oldest_transaction_date unless oldest_transaction_date == SKIP
  @newest_transaction_date = newest_transaction_date unless newest_transaction_date == SKIP
  unless newest_transaction_amount == SKIP
    @newest_transaction_amount =
      newest_transaction_amount
  end
  @total_outflows = total_outflows
  @total_inflows = total_inflows
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_subtypeString

The detected subtype of the account, based on the transactions to/from the institution.

Returns:

  • (String)


19
20
21
# File 'lib/the_plaid_api/models/detected_account.rb', line 19

def 
  @account_subtype
end

#account_typeString

The detected account type (depository, credit, loan, investment etc.).

Returns:

  • (String)


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

def 
  @account_type
end

#newest_transaction_amountFloat

Amount of the most recent transaction associated with this detected account type at this financial institution.

Returns:

  • (Float)


39
40
41
# File 'lib/the_plaid_api/models/detected_account.rb', line 39

def newest_transaction_amount
  @newest_transaction_amount
end

#newest_transaction_dateDate

The date of the newest transaction associated with this detected account type at this financial institution.

Returns:

  • (Date)


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

def newest_transaction_date
  @newest_transaction_date
end

#oldest_transaction_dateDate

The date of the oldest transaction associated with this detected account type at this financial institution.

Returns:

  • (Date)


29
30
31
# File 'lib/the_plaid_api/models/detected_account.rb', line 29

def oldest_transaction_date
  @oldest_transaction_date
end

#total_inflowsFloat

Sum of inflow amounts associated with this detected account type at this financial institution.

Returns:

  • (Float)


49
50
51
# File 'lib/the_plaid_api/models/detected_account.rb', line 49

def total_inflows
  @total_inflows
end

#total_outflowsFloat

Sum of outflow amounts associated with this detected account type at this financial institution.

Returns:

  • (Float)


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

def total_outflows
  @total_outflows
end

#transaction_countInteger

The number of transactions associated with this detected account type at this financial institution.

Returns:

  • (Integer)


24
25
26
# File 'lib/the_plaid_api/models/detected_account.rb', line 24

def transaction_count
  @transaction_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
131
132
133
134
135
136
137
138
139
140
# File 'lib/the_plaid_api/models/detected_account.rb', line 104

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('account_type') ? hash['account_type'] : nil
   =
    hash.key?('account_subtype') ? hash['account_subtype'] : nil
  transaction_count =
    hash.key?('transaction_count') ? hash['transaction_count'] : nil
  total_outflows =
    hash.key?('total_outflows') ? hash['total_outflows'] : nil
  total_inflows = hash.key?('total_inflows') ? hash['total_inflows'] : nil
  oldest_transaction_date =
    hash.key?('oldest_transaction_date') ? hash['oldest_transaction_date'] : SKIP
  newest_transaction_date =
    hash.key?('newest_transaction_date') ? hash['newest_transaction_date'] : SKIP
  newest_transaction_amount =
    hash.key?('newest_transaction_amount') ? hash['newest_transaction_amount'] : 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.
  DetectedAccount.new(account_type: ,
                      account_subtype: ,
                      transaction_count: transaction_count,
                      total_outflows: total_outflows,
                      total_inflows: total_inflows,
                      oldest_transaction_date: oldest_transaction_date,
                      newest_transaction_date: newest_transaction_date,
                      newest_transaction_amount: newest_transaction_amount,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_type'] = 'account_type'
  @_hash['account_subtype'] = 'account_subtype'
  @_hash['transaction_count'] = 'transaction_count'
  @_hash['oldest_transaction_date'] = 'oldest_transaction_date'
  @_hash['newest_transaction_date'] = 'newest_transaction_date'
  @_hash['newest_transaction_amount'] = 'newest_transaction_amount'
  @_hash['total_outflows'] = 'total_outflows'
  @_hash['total_inflows'] = 'total_inflows'
  @_hash
end

.nullablesObject

An array for nullable fields



75
76
77
78
79
80
# File 'lib/the_plaid_api/models/detected_account.rb', line 75

def self.nullables
  %w[
    account_type
    account_subtype
  ]
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
72
# File 'lib/the_plaid_api/models/detected_account.rb', line 66

def self.optionals
  %w[
    oldest_transaction_date
    newest_transaction_date
    newest_transaction_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



154
155
156
157
158
159
160
161
162
163
# File 'lib/the_plaid_api/models/detected_account.rb', line 154

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_type: #{@account_type.inspect}, account_subtype:"\
  " #{@account_subtype.inspect}, transaction_count: #{@transaction_count.inspect},"\
  " oldest_transaction_date: #{@oldest_transaction_date.inspect}, newest_transaction_date:"\
  " #{@newest_transaction_date.inspect}, newest_transaction_amount:"\
  " #{@newest_transaction_amount.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.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_type: #{@account_type}, account_subtype: #{@account_subtype},"\
  " transaction_count: #{@transaction_count}, oldest_transaction_date:"\
  " #{@oldest_transaction_date}, newest_transaction_date: #{@newest_transaction_date},"\
  " newest_transaction_amount: #{@newest_transaction_amount}, total_outflows:"\
  " #{@total_outflows}, total_inflows: #{@total_inflows}, additional_properties:"\
  " #{@additional_properties}>"
end