Class: Onfido::UsDrivingLicenceShared

Inherits:
Object
  • Object
show all
Defined in:
lib/onfido/models/us_driving_licence_shared.rb

Overview

An object that contains all accepted fields for the Driver’s License Data Verification report.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UsDrivingLicenceShared

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 160

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::UsDrivingLicenceShared` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::UsDrivingLicenceShared`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id_number')
    self.id_number = attributes[:'id_number']
  else
    self.id_number = nil
  end

  if attributes.key?(:'issue_state')
    self.issue_state = attributes[:'issue_state']
  else
    self.issue_state = nil
  end

  if attributes.key?(:'address_line_1')
    self.address_line_1 = attributes[:'address_line_1']
  end

  if attributes.key?(:'address_line_2')
    self.address_line_2 = attributes[:'address_line_2']
  end

  if attributes.key?(:'city')
    self.city = attributes[:'city']
  end

  if attributes.key?(:'date_of_birth')
    self.date_of_birth = attributes[:'date_of_birth']
  end

  if attributes.key?(:'document_category')
    self.document_category = attributes[:'document_category']
  end

  if attributes.key?(:'expiration_date')
    self.expiration_date = attributes[:'expiration_date']
  end

  if attributes.key?(:'eye_color_code')
    self.eye_color_code = attributes[:'eye_color_code']
  end

  if attributes.key?(:'first_name')
    self.first_name = attributes[:'first_name']
  end

  if attributes.key?(:'gender')
    self.gender = attributes[:'gender']
  end

  if attributes.key?(:'issue_date')
    self.issue_date = attributes[:'issue_date']
  end

  if attributes.key?(:'last_name')
    self.last_name = attributes[:'last_name']
  end

  if attributes.key?(:'middle_name')
    self.middle_name = attributes[:'middle_name']
  end

  if attributes.key?(:'name_suffix')
    self.name_suffix = attributes[:'name_suffix']
  end

  if attributes.key?(:'postal_code')
    self.postal_code = attributes[:'postal_code']
  end

  if attributes.key?(:'state')
    self.state = attributes[:'state']
  end

  if attributes.key?(:'weight_measure')
    self.weight_measure = attributes[:'weight_measure']
  end
end

Instance Attribute Details

#address_line_1Object

Line 1 of the address



26
27
28
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 26

def address_line_1
  @address_line_1
end

#address_line_2Object

Line 2 of the address



29
30
31
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 29

def address_line_2
  @address_line_2
end

#cityObject

The city of the owner’s address



32
33
34
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 32

def city
  @city
end

#date_of_birthObject

Date of birth in yyyy-mm-dd format



35
36
37
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 35

def date_of_birth
  @date_of_birth
end

#document_categoryObject

Document category.



38
39
40
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 38

def document_category
  @document_category
end

#expiration_dateObject

Expiration date of the driving licence in yyyy-mm-dd format



41
42
43
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 41

def expiration_date
  @expiration_date
end

#eye_color_codeObject

Eye color code.



44
45
46
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 44

def eye_color_code
  @eye_color_code
end

#first_nameObject

The owner’s first name



47
48
49
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 47

def first_name
  @first_name
end

#genderObject

Returns the value of attribute gender.



49
50
51
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 49

def gender
  @gender
end

#id_numberObject

Driving licence ID number



20
21
22
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 20

def id_number
  @id_number
end

#issue_dateObject

Issue date in yyyy-mm-dd format



52
53
54
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 52

def issue_date
  @issue_date
end

#issue_stateObject

Two letter code of issuing state (state-issued driving licenses only)



23
24
25
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 23

def issue_state
  @issue_state
end

#last_nameObject

The owner’s surname



55
56
57
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 55

def last_name
  @last_name
end

#middle_nameObject

The owner’s middle name



58
59
60
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 58

def middle_name
  @middle_name
end

#name_suffixObject

The owner’s name suffix



61
62
63
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 61

def name_suffix
  @name_suffix
end

#postal_codeObject

The postcode or ZIP of the owner’s address



64
65
66
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 64

def postal_code
  @postal_code
end

#stateObject

2-characters state code



67
68
69
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 67

def state
  @state
end

#weight_measureObject

Weight in pounds



70
71
72
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 70

def weight_measure
  @weight_measure
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 428

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Onfido.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



119
120
121
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 119

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



124
125
126
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 124

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 95

def self.attribute_map
  {
    :'id_number' => :'id_number',
    :'issue_state' => :'issue_state',
    :'address_line_1' => :'address_line_1',
    :'address_line_2' => :'address_line_2',
    :'city' => :'city',
    :'date_of_birth' => :'date_of_birth',
    :'document_category' => :'document_category',
    :'expiration_date' => :'expiration_date',
    :'eye_color_code' => :'eye_color_code',
    :'first_name' => :'first_name',
    :'gender' => :'gender',
    :'issue_date' => :'issue_date',
    :'last_name' => :'last_name',
    :'middle_name' => :'middle_name',
    :'name_suffix' => :'name_suffix',
    :'postal_code' => :'postal_code',
    :'state' => :'state',
    :'weight_measure' => :'weight_measure'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 404

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



153
154
155
156
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 153

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 129

def self.openapi_types
  {
    :'id_number' => :'String',
    :'issue_state' => :'String',
    :'address_line_1' => :'String',
    :'address_line_2' => :'String',
    :'city' => :'String',
    :'date_of_birth' => :'Date',
    :'document_category' => :'String',
    :'expiration_date' => :'Date',
    :'eye_color_code' => :'String',
    :'first_name' => :'String',
    :'gender' => :'String',
    :'issue_date' => :'Date',
    :'last_name' => :'String',
    :'middle_name' => :'String',
    :'name_suffix' => :'String',
    :'postal_code' => :'String',
    :'state' => :'String',
    :'weight_measure' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 366

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id_number == o.id_number &&
      issue_state == o.issue_state &&
      address_line_1 == o.address_line_1 &&
      address_line_2 == o.address_line_2 &&
      city == o.city &&
      date_of_birth == o.date_of_birth &&
      document_category == o.document_category &&
      expiration_date == o.expiration_date &&
      eye_color_code == o.eye_color_code &&
      first_name == o.first_name &&
      gender == o.gender &&
      issue_date == o.issue_date &&
      last_name == o.last_name &&
      middle_name == o.middle_name &&
      name_suffix == o.name_suffix &&
      postal_code == o.postal_code &&
      state == o.state &&
      weight_measure == o.weight_measure
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 499

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


391
392
393
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 391

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



397
398
399
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 397

def hash
  [id_number, issue_state, address_line_1, address_line_2, city, date_of_birth, document_category, expiration_date, eye_color_code, first_name, gender, issue_date, last_name, middle_name, name_suffix, postal_code, state, weight_measure].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 253

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id_number.nil?
    invalid_properties.push('invalid value for "id_number", id_number cannot be nil.')
  end

  if @issue_state.nil?
    invalid_properties.push('invalid value for "issue_state", issue_state cannot be nil.')
  end

  pattern = Regexp.new(/^[A-Z]{2}$/)
  if @issue_state !~ pattern
    invalid_properties.push("invalid value for \"issue_state\", must conform to the pattern #{pattern}.")
  end

  pattern = Regexp.new(/^[A-Z]{2}$/)
  if !@state.nil? && @state !~ pattern
    invalid_properties.push("invalid value for \"state\", must conform to the pattern #{pattern}.")
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



475
476
477
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 475

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 481

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



469
470
471
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 469

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/onfido/models/us_driving_licence_shared.rb', line 279

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id_number.nil?
  return false if @issue_state.nil?
  return false if @issue_state !~ Regexp.new(/^[A-Z]{2}$/)
  document_category_validator = EnumAttributeValidator.new('String', ["driver license", "driver permit", "id card", "unknown_default_open_api"])
  return false unless document_category_validator.valid?(@document_category)
  eye_color_code_validator = EnumAttributeValidator.new('String', ["BLK", "BLU", "BRO", "DIC", "GRY", "GRN", "HAZ", "MAR", "PNK", "unknown_default_open_api"])
  return false unless eye_color_code_validator.valid?(@eye_color_code)
  gender_validator = EnumAttributeValidator.new('String', ["Male", "Female", "unknown_default_open_api"])
  return false unless gender_validator.valid?(@gender)
  return false if !@state.nil? && @state !~ Regexp.new(/^[A-Z]{2}$/)
  true
end