Class: FdxV660Api::PayAmount

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/pay_amount.rb

Overview

The payment amount and year-to-date amount, with optional name and/or currency, for this named pay element, earning or deduction. (Inherits properties amount and currency from MonetaryAmount)

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(amount:, currency: SKIP, name: SKIP, year_to_date: SKIP, additional_properties: nil) ⇒ PayAmount

Returns a new instance of PayAmount.



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 55

def initialize(amount:, currency: SKIP, name: SKIP, year_to_date: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount = amount
  @currency = currency unless currency == SKIP
  @name = name unless name == SKIP
  @year_to_date = year_to_date unless year_to_date == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

The monetary amount

Returns:

  • (Float)


16
17
18
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 16

def amount
  @amount
end

#currencyIso4217CurrencyCode7

Currency code of the monetary amount



20
21
22
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 20

def currency
  @currency
end

#nameString

Name of this pay element, earning or deduction, if needed

Returns:

  • (String)


24
25
26
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 24

def name
  @name
end

#year_to_dateFloat

Year-to-date currency amount for this pay element, earning or deduction, if relevant

Returns:

  • (Float)


29
30
31
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 29

def year_to_date
  @year_to_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  year_to_date = hash.key?('yearToDate') ? hash['yearToDate'] : 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.
  PayAmount.new(amount: amount,
                currency: currency,
                name: name,
                year_to_date: year_to_date,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
38
39
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['name'] = 'name'
  @_hash['year_to_date'] = 'yearToDate'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



42
43
44
45
46
47
48
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 42

def self.optionals
  %w[
    currency
    name
    year_to_date
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



100
101
102
103
104
105
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 100

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, currency: #{@currency.inspect}, name:"\
  " #{@name.inspect}, year_to_date: #{@year_to_date.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



93
94
95
96
97
# File 'lib/fdx_v660_api/models/pay_amount.rb', line 93

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, currency: #{@currency}, name: #{@name}, year_to_date:"\
  " #{@year_to_date}, additional_properties: #{@additional_properties}>"
end