Class: ThePlaidApi::CreditPayStub

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

Overview

An object representing an end user’s pay stub.

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(deductions:, document_id:, document_metadata:, earnings:, employee:, employer:, net_pay:, pay_period_details:, additional_properties: nil) ⇒ CreditPayStub

Returns a new instance of CreditPayStub.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/the_plaid_api/models/credit_pay_stub.rb', line 72

def initialize(deductions:, document_id:, document_metadata:, earnings:,
               employee:, employer:, net_pay:, pay_period_details:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @deductions = deductions
  @document_id = document_id
  @document_metadata = 
  @earnings = earnings
  @employee = employee
  @employer = employer
  @net_pay = net_pay
  @pay_period_details = pay_period_details
  @additional_properties = additional_properties
end

Instance Attribute Details

#deductionsCreditPayStubDeductions

An object with the deduction information found on a pay stub.



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

def deductions
  @deductions
end

#document_idString

An identifier of the document referenced by the document metadata.

Returns:

  • (String)


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

def document_id
  @document_id
end

#document_metadataCreditDocumentMetadata

Object representing metadata pertaining to the document.



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

def 
  @document_metadata
end

#earningsCreditPayStubEarnings

An object representing both a breakdown of earnings on a pay stub and the total earnings.



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

def earnings
  @earnings
end

#employeeCreditPayStubEmployee

Data about the employee.



31
32
33
# File 'lib/the_plaid_api/models/credit_pay_stub.rb', line 31

def employee
  @employee
end

#employerCreditPayStubEmployer

Information about the employer on the pay stub.



35
36
37
# File 'lib/the_plaid_api/models/credit_pay_stub.rb', line 35

def employer
  @employer
end

#net_payCreditPayStubNetPay

An object representing information about the net pay amount on the pay stub.

Returns:



40
41
42
# File 'lib/the_plaid_api/models/credit_pay_stub.rb', line 40

def net_pay
  @net_pay
end

#pay_period_detailsPayStubPayPeriodDetails

Details about the pay period.



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

def pay_period_details
  @pay_period_details
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
120
121
122
# File 'lib/the_plaid_api/models/credit_pay_stub.rb', line 90

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  deductions = CreditPayStubDeductions.from_hash(hash['deductions']) if hash['deductions']
  document_id = hash.key?('document_id') ? hash['document_id'] : nil
   = CreditDocumentMetadata.from_hash(hash['document_metadata']) if
    hash['document_metadata']
  earnings = CreditPayStubEarnings.from_hash(hash['earnings']) if hash['earnings']
  employee = CreditPayStubEmployee.from_hash(hash['employee']) if hash['employee']
  employer = CreditPayStubEmployer.from_hash(hash['employer']) if hash['employer']
  net_pay = CreditPayStubNetPay.from_hash(hash['net_pay']) if hash['net_pay']
  pay_period_details = PayStubPayPeriodDetails.from_hash(hash['pay_period_details']) if
    hash['pay_period_details']

  # 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.
  CreditPayStub.new(deductions: deductions,
                    document_id: document_id,
                    document_metadata: ,
                    earnings: earnings,
                    employee: employee,
                    employer: employer,
                    net_pay: net_pay,
                    pay_period_details: pay_period_details,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['deductions'] = 'deductions'
  @_hash['document_id'] = 'document_id'
  @_hash['document_metadata'] = 'document_metadata'
  @_hash['earnings'] = 'earnings'
  @_hash['employee'] = 'employee'
  @_hash['employer'] = 'employer'
  @_hash['net_pay'] = 'net_pay'
  @_hash['pay_period_details'] = 'pay_period_details'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    document_id
  ]
end

.optionalsObject

An array for optional fields



61
62
63
# File 'lib/the_plaid_api/models/credit_pay_stub.rb', line 61

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} deductions: #{@deductions.inspect}, document_id: #{@document_id.inspect},"\
  " document_metadata: #{@document_metadata.inspect}, earnings: #{@earnings.inspect},"\
  " employee: #{@employee.inspect}, employer: #{@employer.inspect}, net_pay:"\
  " #{@net_pay.inspect}, pay_period_details: #{@pay_period_details.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} deductions: #{@deductions}, document_id: #{@document_id},"\
  " document_metadata: #{@document_metadata}, earnings: #{@earnings}, employee: #{@employee},"\
  " employer: #{@employer}, net_pay: #{@net_pay}, pay_period_details: #{@pay_period_details},"\
  " additional_properties: #{@additional_properties}>"
end