Class: FdxV660Api::CustomerEntity1

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

Overview

Current customer as a JSON response if not encrypted, or as the JSON payload which is encrypted for an application/jwt response

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, customer_id: SKIP, type: SKIP, name: SKIP, business_customer: SKIP, customer_start_date: SKIP, last_activity_date: SKIP, accounts: SKIP, additional_properties: nil) ⇒ CustomerEntity1

Returns a new instance of CustomerEntity1.



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
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 118

def initialize(emails: SKIP, addresses: SKIP, telephones: SKIP,
               date_of_birth: SKIP, tax_id: SKIP, tax_id_country: SKIP,
               government_id: SKIP, customer_id: SKIP, type: SKIP,
               name: SKIP, business_customer: SKIP,
               customer_start_date: SKIP, last_activity_date: SKIP,
               accounts: 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
  @customer_id = customer_id unless customer_id == SKIP
  @type = type unless type == SKIP
  @name = name unless name == SKIP
  @business_customer = business_customer unless business_customer == SKIP
  @customer_start_date = customer_start_date unless customer_start_date == SKIP
  @last_activity_date = last_activity_date unless last_activity_date == SKIP
  @accounts = accounts unless accounts == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#accountsArray[CustomerToAccountRelationshipEntity]

List of accounts related to this customer



71
72
73
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 71

def accounts
  @accounts
end

#addressesArray[DeliveryAddress]

Array of the contact physical addresses

Returns:



19
20
21
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 19

def addresses
  @addresses
end

#business_customerBusinessCustomerEntity2

The business customer information, only used if 'type' is 'BUSINESS'.



59
60
61
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 59

def business_customer
  @business_customer
end

#customer_idString

Long-term persistent identity of the customer. This identity must be unique to the owning institution

Returns:

  • (String)


47
48
49
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 47

def customer_id
  @customer_id
end

#customer_start_dateDate

The customer's start date at the financial institution

Returns:

  • (Date)


63
64
65
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 63

def customer_start_date
  @customer_start_date
end

#date_of_birthDate

The person's date of birth

Returns:

  • (Date)


27
28
29
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 27

def date_of_birth
  @date_of_birth
end

#emailsArray[String]

Array of the contact email addresses

Returns:

  • (Array[String])


15
16
17
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 15

def emails
  @emails
end

#government_idString

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

Returns:

  • (String)


42
43
44
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 42

def government_id
  @government_id
end

#last_activity_dateDate

The customer's date of last account activity at the financial institution

Returns:

  • (Date)


67
68
69
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 67

def last_activity_date
  @last_activity_date
end

#nameCustomerNameEntity3

The customer's name

Returns:



55
56
57
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 55

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)


33
34
35
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 33

def tax_id
  @tax_id
end

#tax_id_countryIso3166CountryCode2

Country originating the Customer's taxId element

Returns:



37
38
39
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 37

def tax_id_country
  @tax_id_country
end

#telephonesArray[TelephoneNumberPlusExtension]

Array of the contact telephone numbers, with extension if any

Returns:



23
24
25
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 23

def telephones
  @telephones
end

#typeBusinessOrConsumerType3

Type of entity. One of BUSINESS or CONSUMER



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

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 145

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
  customer_id = hash.key?('customerId') ? hash['customerId'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  name = CustomerNameEntity3.from_hash(hash['name']) if hash['name']
  business_customer = BusinessCustomerEntity2.from_hash(hash['businessCustomer']) if
    hash['businessCustomer']
  customer_start_date =
    hash.key?('customerStartDate') ? hash['customerStartDate'] : SKIP
  last_activity_date =
    hash.key?('lastActivityDate') ? hash['lastActivityDate'] : SKIP
  # Parameter is an array, so we need to iterate through it
  accounts = nil
  unless hash['accounts'].nil?
    accounts = []
    hash['accounts'].each do |structure|
      accounts << (CustomerToAccountRelationshipEntity.from_hash(structure) if structure)
    end
  end

  accounts = SKIP unless hash.key?('accounts')

  # 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.
  CustomerEntity1.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,
                      customer_id: customer_id,
                      type: type,
                      name: name,
                      business_customer: business_customer,
                      customer_start_date: customer_start_date,
                      last_activity_date: last_activity_date,
                      accounts: accounts,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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['customer_id'] = 'customerId'
  @_hash['type'] = 'type'
  @_hash['name'] = 'name'
  @_hash['business_customer'] = 'businessCustomer'
  @_hash['customer_start_date'] = 'customerStartDate'
  @_hash['last_activity_date'] = 'lastActivityDate'
  @_hash['accounts'] = 'accounts'
  @_hash
end

.nullablesObject

An array for nullable fields



114
115
116
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 114

def self.nullables
  []
end

.optionalsObject

An array for optional fields



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 94

def self.optionals
  %w[
    emails
    addresses
    telephones
    date_of_birth
    tax_id
    tax_id_country
    government_id
    customer_id
    type
    name
    business_customer
    customer_start_date
    last_activity_date
    accounts
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



231
232
233
234
235
236
237
238
239
240
241
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 231

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}, customer_id: #{@customer_id.inspect}, type: #{@type.inspect},"\
  " name: #{@name.inspect}, business_customer: #{@business_customer.inspect},"\
  " customer_start_date: #{@customer_start_date.inspect}, last_activity_date:"\
  " #{@last_activity_date.inspect}, accounts: #{@accounts.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



220
221
222
223
224
225
226
227
228
# File 'lib/fdx_v660_api/models/customer_entity1.rb', line 220

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}, customer_id: #{@customer_id}, type: #{@type}, name:"\
  " #{@name}, business_customer: #{@business_customer}, customer_start_date:"\
  " #{@customer_start_date}, last_activity_date: #{@last_activity_date}, accounts:"\
  " #{@accounts}, additional_properties: #{@additional_properties}>"
end