Class: FdxV660Api::EmployeeEntity

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

Overview

Represents an employee

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(name:, emails: SKIP, addresses: SKIP, telephones: SKIP, date_of_birth: SKIP, tax_id: SKIP, tax_id_country: SKIP, government_id: SKIP, employee_id: SKIP, additional_properties: nil) ⇒ EmployeeEntity

Returns a new instance of EmployeeEntity.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 85

def initialize(name:, emails: SKIP, addresses: SKIP, telephones: SKIP,
               date_of_birth: SKIP, tax_id: SKIP, tax_id_country: SKIP,
               government_id: SKIP, employee_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @emails = emails unless emails == SKIP
  @addresses = addresses unless addresses == SKIP
  @telephones = telephones unless telephones == SKIP
  @date_of_birth = date_of_birth unless date_of_birth == SKIP
  @tax_id = tax_id unless tax_id == SKIP
  @tax_id_country = tax_id_country unless tax_id_country == SKIP
  @government_id = government_id unless government_id == SKIP
  @employee_id = employee_id unless employee_id == SKIP
  @name = name
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressesArray[DeliveryAddress]

Array of the contact physical addresses

Returns:



18
19
20
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 18

def addresses
  @addresses
end

#date_of_birthDate

The person's date of birth

Returns:

  • (Date)


26
27
28
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 26

def date_of_birth
  @date_of_birth
end

#emailsArray[String]

Array of the contact email addresses

Returns:

  • (Array[String])


14
15
16
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 14

def emails
  @emails
end

#employee_idString

Provider's long-term persistent id for the employee

Returns:

  • (String)


45
46
47
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 45

def employee_id
  @employee_id
end

#government_idString

A federal (such as passport) or state (such as driver's license) issued identifier

Returns:

  • (String)


41
42
43
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 41

def government_id
  @government_id
end

#nameIndividualName2

Employee's full name

Returns:



49
50
51
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 49

def name
  @name
end

#tax_idString

Country specific Tax Id associated with this customer. Masked as last four, e.g. xxx-xx-0123, or passed in encrypted payload. (SIN or NAS in Canada, SSN or TIN in US, etc.)

Returns:

  • (String)


32
33
34
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 32

def tax_id
  @tax_id
end

#tax_id_countryIso3166CountryCode2

Country originating the Customer's taxId element

Returns:



36
37
38
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 36

def tax_id_country
  @tax_id_country
end

#telephonesArray[TelephoneNumberPlusExtension]

Array of the contact telephone numbers, with extension if any

Returns:



22
23
24
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 22

def telephones
  @telephones
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 105

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = IndividualName2.from_hash(hash['name']) if hash['name']
  emails = hash.key?('emails') ? hash['emails'] : SKIP
  # Parameter is an array, so we need to iterate through it
  addresses = nil
  unless hash['addresses'].nil?
    addresses = []
    hash['addresses'].each do |structure|
      addresses << (DeliveryAddress.from_hash(structure) if structure)
    end
  end

  addresses = SKIP unless hash.key?('addresses')
  # Parameter is an array, so we need to iterate through it
  telephones = nil
  unless hash['telephones'].nil?
    telephones = []
    hash['telephones'].each do |structure|
      telephones << (TelephoneNumberPlusExtension.from_hash(structure) if structure)
    end
  end

  telephones = SKIP unless hash.key?('telephones')
  date_of_birth = hash.key?('dateOfBirth') ? hash['dateOfBirth'] : SKIP
  tax_id = hash.key?('taxId') ? hash['taxId'] : SKIP
  tax_id_country = hash.key?('taxIdCountry') ? hash['taxIdCountry'] : SKIP
  government_id = hash.key?('governmentId') ? hash['governmentId'] : SKIP
  employee_id = hash.key?('employeeId') ? hash['employeeId'] : 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.
  EmployeeEntity.new(name: name,
                     emails: emails,
                     addresses: addresses,
                     telephones: telephones,
                     date_of_birth: date_of_birth,
                     tax_id: tax_id,
                     tax_id_country: tax_id_country,
                     government_id: government_id,
                     employee_id: employee_id,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 52

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['emails'] = 'emails'
  @_hash['addresses'] = 'addresses'
  @_hash['telephones'] = 'telephones'
  @_hash['date_of_birth'] = 'dateOfBirth'
  @_hash['tax_id'] = 'taxId'
  @_hash['tax_id_country'] = 'taxIdCountry'
  @_hash['government_id'] = 'governmentId'
  @_hash['employee_id'] = 'employeeId'
  @_hash['name'] = 'name'
  @_hash
end

.nullablesObject

An array for nullable fields



81
82
83
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 81

def self.nullables
  []
end

.optionalsObject

An array for optional fields



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 67

def self.optionals
  %w[
    emails
    addresses
    telephones
    date_of_birth
    tax_id
    tax_id_country
    government_id
    employee_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



167
168
169
170
171
172
173
174
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 167

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} emails: #{@emails.inspect}, addresses: #{@addresses.inspect}, telephones:"\
  " #{@telephones.inspect}, date_of_birth: #{@date_of_birth.inspect}, tax_id:"\
  " #{@tax_id.inspect}, tax_id_country: #{@tax_id_country.inspect}, government_id:"\
  " #{@government_id.inspect}, employee_id: #{@employee_id.inspect}, name: #{@name.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



158
159
160
161
162
163
164
# File 'lib/fdx_v660_api/models/employee_entity.rb', line 158

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} emails: #{@emails}, addresses: #{@addresses}, telephones: #{@telephones},"\
  " date_of_birth: #{@date_of_birth}, tax_id: #{@tax_id}, tax_id_country: #{@tax_id_country},"\
  " government_id: #{@government_id}, employee_id: #{@employee_id}, name: #{@name},"\
  " additional_properties: #{@additional_properties}>"
end