Class: Plaid::EarningsTotal

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/plaid/models/earnings_total.rb

Overview

An object representing both the current pay period and year to date amount for an earning 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, current_hours: SKIP, current_rate: SKIP, additional_properties: nil) ⇒ EarningsTotal

Returns a new instance of EarningsTotal.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/plaid/models/earnings_total.rb', line 70

def initialize(canonical_description: SKIP, description: SKIP,
               current_pay: SKIP, ytd_pay: SKIP, current_hours: SKIP,
               current_rate: 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
  @current_hours = current_hours unless current_hours == SKIP
  @current_rate = current_rate unless current_rate == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#canonical_descriptionCanonicalDescription

Commonly used term to describe the line item.



15
16
17
# File 'lib/plaid/models/earnings_total.rb', line 15

def canonical_description
  @canonical_description
end

#current_hoursString

An object representing a monetary amount.

Returns:

  • (String)


31
32
33
# File 'lib/plaid/models/earnings_total.rb', line 31

def current_hours
  @current_hours
end

#current_payPay

An object representing a monetary amount.

Returns:



23
24
25
# File 'lib/plaid/models/earnings_total.rb', line 23

def current_pay
  @current_pay
end

#current_rateString

An object representing a monetary amount.

Returns:

  • (String)


35
36
37
# File 'lib/plaid/models/earnings_total.rb', line 35

def current_rate
  @current_rate
end

#descriptionString

Text of the line item as printed on the paystub.

Returns:

  • (String)


19
20
21
# File 'lib/plaid/models/earnings_total.rb', line 19

def description
  @description
end

#ytd_payPay

An object representing a monetary amount.

Returns:



27
28
29
# File 'lib/plaid/models/earnings_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.



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
# File 'lib/plaid/models/earnings_total.rb', line 86

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']
  current_hours = hash.key?('current_hours') ? hash['current_hours'] : SKIP
  current_rate = hash.key?('current_rate') ? hash['current_rate'] : 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.
  EarningsTotal.new(canonical_description: canonical_description,
                    description: description,
                    current_pay: current_pay,
                    ytd_pay: ytd_pay,
                    current_hours: current_hours,
                    current_rate: current_rate,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/plaid/models/earnings_total.rb', line 38

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['current_hours'] = 'current_hours'
  @_hash['current_rate'] = 'current_rate'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
65
66
67
68
# File 'lib/plaid/models/earnings_total.rb', line 62

def self.nullables
  %w[
    description
    current_hours
    current_rate
  ]
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
59
# File 'lib/plaid/models/earnings_total.rb', line 50

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



125
126
127
128
129
130
131
# File 'lib/plaid/models/earnings_total.rb', line 125

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}, current_hours: #{@current_hours.inspect}, current_rate:"\
  " #{@current_rate.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
121
122
# File 'lib/plaid/models/earnings_total.rb', line 116

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}, current_hours:"\
  " #{@current_hours}, current_rate: #{@current_rate}, additional_properties:"\
  " #{@additional_properties}>"
end