Class: ThePlaidApi::NetPay

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

Overview

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

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(current_amount: SKIP, description: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, ytd_amount: SKIP, total: SKIP, additional_properties: nil) ⇒ NetPay

Returns a new instance of NetPay.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/the_plaid_api/models/net_pay.rb', line 79

def initialize(current_amount: SKIP, description: SKIP,
               iso_currency_code: SKIP, unofficial_currency_code: SKIP,
               ytd_amount: SKIP, total: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @current_amount = current_amount unless current_amount == SKIP
  @description = description unless description == SKIP
  @iso_currency_code = iso_currency_code unless iso_currency_code == SKIP
  @unofficial_currency_code = unofficial_currency_code unless unofficial_currency_code == SKIP
  @ytd_amount = ytd_amount unless ytd_amount == SKIP
  @total = total unless total == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#current_amountFloat

Raw amount of the net pay for the pay period

Returns:

  • (Float)


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

def current_amount
  @current_amount
end

#descriptionString

Description of the net pay

Returns:

  • (String)


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

def description
  @description
end

#iso_currency_codeString

The ISO-4217 currency code of the net pay. Always ‘null` if `unofficial_currency_code` is non-null.

Returns:

  • (String)


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

def iso_currency_code
  @iso_currency_code
end

#totalTotal

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

Returns:



42
43
44
# File 'lib/the_plaid_api/models/net_pay.rb', line 42

def total
  @total
end

#unofficial_currency_codeString

The unofficial currency code associated with the net pay. Always ‘null` if `iso_currency_code` is non-`null`. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries. See the [currency code schema](plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `iso_currency_code`s.

Returns:

  • (String)


33
34
35
# File 'lib/the_plaid_api/models/net_pay.rb', line 33

def unofficial_currency_code
  @unofficial_currency_code
end

#ytd_amountFloat

The year-to-date amount of the net pay

Returns:

  • (Float)


37
38
39
# File 'lib/the_plaid_api/models/net_pay.rb', line 37

def ytd_amount
  @ytd_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
123
124
# File 'lib/the_plaid_api/models/net_pay.rb', line 95

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  current_amount =
    hash.key?('current_amount') ? hash['current_amount'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : SKIP
  unofficial_currency_code =
    hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : SKIP
  ytd_amount = hash.key?('ytd_amount') ? hash['ytd_amount'] : SKIP
  total = Total.from_hash(hash['total']) if hash['total']

  # 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.
  NetPay.new(current_amount: current_amount,
             description: description,
             iso_currency_code: iso_currency_code,
             unofficial_currency_code: unofficial_currency_code,
             ytd_amount: ytd_amount,
             total: total,
             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['current_amount'] = 'current_amount'
  @_hash['description'] = 'description'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['ytd_amount'] = 'ytd_amount'
  @_hash['total'] = 'total'
  @_hash
end

.nullablesObject

An array for nullable fields



69
70
71
72
73
74
75
76
77
# File 'lib/the_plaid_api/models/net_pay.rb', line 69

def self.nullables
  %w[
    current_amount
    description
    iso_currency_code
    unofficial_currency_code
    ytd_amount
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    current_amount
    description
    iso_currency_code
    unofficial_currency_code
    ytd_amount
    total
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



136
137
138
139
140
141
142
143
# File 'lib/the_plaid_api/models/net_pay.rb', line 136

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} current_amount: #{@current_amount.inspect}, description:"\
  " #{@description.inspect}, iso_currency_code: #{@iso_currency_code.inspect},"\
  " unofficial_currency_code: #{@unofficial_currency_code.inspect}, ytd_amount:"\
  " #{@ytd_amount.inspect}, total: #{@total.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



127
128
129
130
131
132
133
# File 'lib/the_plaid_api/models/net_pay.rb', line 127

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} current_amount: #{@current_amount}, description: #{@description},"\
  " iso_currency_code: #{@iso_currency_code}, unofficial_currency_code:"\
  " #{@unofficial_currency_code}, ytd_amount: #{@ytd_amount}, total: #{@total},"\
  " additional_properties: #{@additional_properties}>"
end