Class: Idnow::UserData

Inherits:
Object
  • Object
show all
Includes:
Jsonable
Defined in:
lib/idnow/models/user_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Jsonable

#to_h, #to_json

Constructor Details

#initialize(data) ⇒ UserData

Returns a new instance of UserData.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/idnow/models/user_data.rb', line 10

def initialize(data)
  @birthday     = dig_value('birthday', data)
  @birthname    = dig_value('birthname', data)
  @birthplace   = dig_value('birthplace', data)
  @city         = dig_value('address', 'city', data)
  @country      = dig_value('address', 'country', data)
  @firstname    = dig_value('firstname', data)
  @gender       = dig_value('gender', data)
  @lastname     = dig_value('lastname', data)
  @nationality  = dig_value('nationality', data)
  @street       = dig_value('address', 'street', data)
  @streetnumber = dig_value('address', 'streetnumber', data)
  @title        = dig_value('title', data)
  @zipcode      = dig_value('address', 'zipcode', data)
  @raw_data     = data
end

Instance Attribute Details

#birthdayObject

Returns the value of attribute birthday.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def birthday
  @birthday
end

#birthnameObject

Returns the value of attribute birthname.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def birthname
  @birthname
end

#birthplaceObject

Returns the value of attribute birthplace.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def birthplace
  @birthplace
end

#cityObject

Returns the value of attribute city.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def city
  @city
end

#countryObject

Returns the value of attribute country.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def country
  @country
end

#firstnameObject

Returns the value of attribute firstname.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def firstname
  @firstname
end

#genderObject

Returns the value of attribute gender.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def gender
  @gender
end

#lastnameObject

Returns the value of attribute lastname.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def lastname
  @lastname
end

#nationalityObject

Returns the value of attribute nationality.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def nationality
  @nationality
end

#streetObject

Returns the value of attribute street.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def street
  @street
end

#streetnumberObject

Returns the value of attribute streetnumber.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def streetnumber
  @streetnumber
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def title
  @title
end

#zipcodeObject

Returns the value of attribute zipcode.



7
8
9
# File 'lib/idnow/models/user_data.rb', line 7

def zipcode
  @zipcode
end

Instance Method Details

#addressObject



27
28
29
# File 'lib/idnow/models/user_data.rb', line 27

def address
  "#{street} #{streetnumber}, #{zipcode} #{city}, #{country}"
end

#address_changed?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/idnow/models/user_data.rb', line 31

def address_changed?
  @raw_data['address'].values.any? { |field| field['status'] == 'CHANGE' }
end