Class: Idnow::IdentificationData

Inherits:
Object
  • Object
show all
Defined in:
lib/idnow/models/identification_data.rb

Defined Under Namespace

Modules: Gender

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ IdentificationData

Returns a new instance of IdentificationData.



21
22
23
24
25
26
27
# 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

Instance Attribute Details

#birthnameObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def birthname
  @birthname
end

#birthplaceObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def birthplace
  @birthplace
end

#cityObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def city
  @city
end

#countryObject

rubocop:enable Naming/MethodName



19
20
21
# File 'lib/idnow/models/identification_data.rb', line 19

def country
  @country
end

#custom1Object

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def custom1
  @custom1
end

#custom2Object

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def custom2
  @custom2
end

#custom3Object

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def custom3
  @custom3
end

#custom4Object

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def custom4
  @custom4
end

#custom5Object

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def custom5
  @custom5
end

#emailObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def email
  @email
end

#firstnameObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def firstname
  @firstname
end

#genderObject

rubocop:enable Naming/MethodName



19
20
21
# File 'lib/idnow/models/identification_data.rb', line 19

def gender
  @gender
end

#lastnameObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def lastname
  @lastname
end

#mobilephoneObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def mobilephone
  @mobilephone
end

#nationalityObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def nationality
  @nationality
end

#preferredLangObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def preferredLang
  @preferredLang
end

#streetObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def street
  @street
end

#streetnumberObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def streetnumber
  @streetnumber
end

#titleObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def title
  @title
end

#trackingidObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def trackingid
  @trackingid
end

#zipcodeObject

rubocop:disable Naming/MethodName



13
14
15
# File 'lib/idnow/models/identification_data.rb', line 13

def zipcode
  @zipcode
end

Instance Method Details

#birthdayObject

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



39
40
41
# File 'lib/idnow/models/identification_data.rb', line 39

def birthday
  @birthday&.strftime('%Y-%m-%d')
end

#birthday=(birthday) ⇒ Object



43
44
45
46
47
48
49
# 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

#to_json(*_args) ⇒ Object



29
30
31
32
33
34
35
# 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