Class: ThePlaidApi::NegativeBalanceInsights

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

Overview

Insights into negative balance occurrences, including frequency, duration, and minimum balance details.

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(days_since_last_occurrence: SKIP, days_with_negative_balance: SKIP, minimum_balance: SKIP, occurrences: SKIP, additional_properties: nil) ⇒ NegativeBalanceInsights

Returns a new instance of NegativeBalanceInsights.



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

def initialize(days_since_last_occurrence: SKIP,
               days_with_negative_balance: SKIP, minimum_balance: SKIP,
               occurrences: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  unless days_since_last_occurrence == SKIP
    @days_since_last_occurrence =
      days_since_last_occurrence
  end
  unless days_with_negative_balance == SKIP
    @days_with_negative_balance =
      days_with_negative_balance
  end
  @minimum_balance = minimum_balance unless minimum_balance == SKIP
  @occurrences = occurrences unless occurrences == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#days_since_last_occurrenceInteger

The number of days since the last transaction that caused any account in the report to have a negative balance. This value is inclusive of the date of the last negative balance, meaning that if the last negative balance occurred today, this value will be ‘0`.

Returns:

  • (Integer)


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

def days_since_last_occurrence
  @days_since_last_occurrence
end

#days_with_negative_balanceInteger

The number of aggregated days that the accounts in the report has had a negative balance within the given time window.

Returns:

  • (Integer)


23
24
25
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 23

def days_with_negative_balance
  @days_with_negative_balance
end

#minimum_balanceAmountWithCurrency

A monetary amount with its associated currency information, supporting both official and unofficial currency codes.

Returns:



28
29
30
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 28

def minimum_balance
  @minimum_balance
end

#occurrencesArray[NegativeBalanceOccurrence]

The summary of the negative balance occurrences for this account. If the user has not had a negative balance in the account in the given time window, this list will be empty.

Returns:



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

def occurrences
  @occurrences
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  days_since_last_occurrence =
    hash.key?('days_since_last_occurrence') ? hash['days_since_last_occurrence'] : SKIP
  days_with_negative_balance =
    hash.key?('days_with_negative_balance') ? hash['days_with_negative_balance'] : SKIP
  minimum_balance = AmountWithCurrency.from_hash(hash['minimum_balance']) if
    hash['minimum_balance']
  # Parameter is an array, so we need to iterate through it
  occurrences = nil
  unless hash['occurrences'].nil?
    occurrences = []
    hash['occurrences'].each do |structure|
      occurrences << (NegativeBalanceOccurrence.from_hash(structure) if structure)
    end
  end

  occurrences = SKIP unless hash.key?('occurrences')

  # 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.
  NegativeBalanceInsights.new(days_since_last_occurrence: days_since_last_occurrence,
                              days_with_negative_balance: days_with_negative_balance,
                              minimum_balance: minimum_balance,
                              occurrences: occurrences,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['days_since_last_occurrence'] = 'days_since_last_occurrence'
  @_hash['days_with_negative_balance'] = 'days_with_negative_balance'
  @_hash['minimum_balance'] = 'minimum_balance'
  @_hash['occurrences'] = 'occurrences'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
60
61
62
63
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 57

def self.nullables
  %w[
    days_since_last_occurrence
    days_with_negative_balance
    minimum_balance
  ]
end

.optionalsObject

An array for optional fields



47
48
49
50
51
52
53
54
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 47

def self.optionals
  %w[
    days_since_last_occurrence
    days_with_negative_balance
    minimum_balance
    occurrences
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



131
132
133
134
135
136
137
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 131

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

#to_sObject

Provides a human-readable string representation of the object.



122
123
124
125
126
127
128
# File 'lib/the_plaid_api/models/negative_balance_insights.rb', line 122

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