Class: ThePlaidApi::Total

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

Overview

An object representing both the current pay period and year to date amount for a category.

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(canonical_description: SKIP, description: SKIP, current_pay: SKIP, ytd_pay: SKIP, additional_properties: nil) ⇒ Total

Returns a new instance of Total.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/the_plaid_api/models/total.rb', line 57

def initialize(canonical_description: SKIP, description: SKIP,
               current_pay: SKIP, ytd_pay: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @canonical_description = canonical_description unless canonical_description == SKIP
  @description = description unless description == SKIP
  @current_pay = current_pay unless current_pay == SKIP
  @ytd_pay = ytd_pay unless ytd_pay == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#canonical_descriptionTotalCanonicalDescription

Commonly used term to describe the line item.



15
16
17
# File 'lib/the_plaid_api/models/total.rb', line 15

def canonical_description
  @canonical_description
end

#current_payPay

An object representing a monetary amount.

Returns:



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

def current_pay
  @current_pay
end

#descriptionString

Text of the line item as printed on the paystub.

Returns:

  • (String)


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

def description
  @description
end

#ytd_payPay

An object representing a monetary amount.

Returns:



27
28
29
# File 'lib/the_plaid_api/models/total.rb', line 27

def ytd_pay
  @ytd_pay
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/the_plaid_api/models/total.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  canonical_description =
    hash.key?('canonical_description') ? hash['canonical_description'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  current_pay = Pay.from_hash(hash['current_pay']) if hash['current_pay']
  ytd_pay = Pay.from_hash(hash['ytd_pay']) if hash['ytd_pay']

  # 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.
  Total.new(canonical_description: canonical_description,
            description: description,
            current_pay: current_pay,
            ytd_pay: ytd_pay,
            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/the_plaid_api/models/total.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['canonical_description'] = 'canonical_description'
  @_hash['description'] = 'description'
  @_hash['current_pay'] = 'current_pay'
  @_hash['ytd_pay'] = 'ytd_pay'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
53
54
55
# File 'lib/the_plaid_api/models/total.rb', line 50

def self.nullables
  %w[
    canonical_description
    description
  ]
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/the_plaid_api/models/total.rb', line 40

def self.optionals
  %w[
    canonical_description
    description
    current_pay
    ytd_pay
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



104
105
106
107
108
109
# File 'lib/the_plaid_api/models/total.rb', line 104

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

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
101
# File 'lib/the_plaid_api/models/total.rb', line 96

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