class Idnow::IdentificationData

Attributes

birthname[RW]

rubocop:disable Naming/MethodName

birthplace[RW]

rubocop:disable Naming/MethodName

city[RW]

rubocop:disable Naming/MethodName

country[R]

rubocop:enable Naming/MethodName

custom1[RW]

rubocop:disable Naming/MethodName

custom2[RW]

rubocop:disable Naming/MethodName

custom3[RW]

rubocop:disable Naming/MethodName

custom4[RW]

rubocop:disable Naming/MethodName

custom5[RW]

rubocop:disable Naming/MethodName

email[RW]

rubocop:disable Naming/MethodName

firstname[RW]

rubocop:disable Naming/MethodName

gender[R]

rubocop:enable Naming/MethodName

lastname[RW]

rubocop:disable Naming/MethodName

mobilephone[RW]

rubocop:disable Naming/MethodName

nationality[RW]

rubocop:disable Naming/MethodName

preferredLang[RW]

rubocop:disable Naming/MethodName

street[RW]

rubocop:disable Naming/MethodName

streetnumber[RW]

rubocop:disable Naming/MethodName

title[RW]

rubocop:disable Naming/MethodName

trackingid[RW]

rubocop:disable Naming/MethodName

zipcode[RW]

rubocop:disable Naming/MethodName

Public Class Methods

new(params = {}) click to toggle source
# File lib/idnow/models/identification_data.rb, line 21
def initialize(params = {})
  params.each_key do |key|
    raise ArgumentError, "Attribute #{key} is not supported!" unless respond_to?(key.to_sym)

    send("#{key}=", params[key])
  end
end

Public Instance Methods

birthday() click to toggle source

Getter / Setter ############

# File lib/idnow/models/identification_data.rb, line 39
def birthday
  @birthday&.strftime('%Y-%m-%d')
end
birthday=(birthday) click to toggle source
# File lib/idnow/models/identification_data.rb, line 43
def birthday=(birthday)
  @birthday = if birthday.instance_of?(Date) || birthday.instance_of?(DateTime)
                birthday
              else
                Date.parse(birthday)
              end
end
country=(country) click to toggle source
# File lib/idnow/models/identification_data.rb, line 51
def country=(country)
  raise ArgumentError, 'Country must be ISO 3166 two letter country code' unless country.instance_of?(String) && country.size == 2

  @country = country.upcase
end
gender=(gender) click to toggle source
# File lib/idnow/models/identification_data.rb, line 57
def gender=(gender)
  if %w[M MALE].include?(gender.to_s.strip.upcase)
    @gender = Gender::MALE
  elsif %w[F FEMALE].include?(gender.to_s.strip.upcase)
    @gender = Gender::FEMALE
  else
    raise ArgumentError, 'Provide valid value for gender: MALE or FEMALE'
  end
end
to_json(*_args) click to toggle source
# File lib/idnow/models/identification_data.rb, line 29
def to_json(*_args)
  result = {}
  instance_variables.each do |attribute|
    result[attribute.to_s.delete('@')] = instance_variable_get(attribute)
  end
  result.to_json
end