Class: FdxV660Api::PersonEntity

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

Overview

Represents a person

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

Returns a new instance of PersonEntity.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fdx_v660_api/models/person_entity.rb', line 74

def initialize(emails: SKIP, addresses: SKIP, telephones: SKIP,
               date_of_birth: SKIP, tax_id: SKIP, tax_id_country: SKIP,
               government_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
  @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/person_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/person_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/person_entity.rb', line 14

def emails
  @emails
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/person_entity.rb', line 41

def government_id
  @government_id
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/person_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/person_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/person_entity.rb', line 22

def telephones
  @telephones
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/fdx_v660_api/models/person_entity.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  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

  # 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.
  PersonEntity.new(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,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/fdx_v660_api/models/person_entity.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



148
149
150
151
152
153
154
# File 'lib/fdx_v660_api/models/person_entity.rb', line 148

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

#to_sObject

Provides a human-readable string representation of the object.



140
141
142
143
144
145
# File 'lib/fdx_v660_api/models/person_entity.rb', line 140

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