class Idnow::UserData
Attributes
birthday[RW]
birthname[RW]
birthplace[RW]
city[RW]
country[RW]
firstname[RW]
gender[RW]
lastname[RW]
nationality[RW]
street[RW]
streetnumber[RW]
title[RW]
zipcode[RW]
Public Class Methods
new(data)
click to toggle source
# 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
Public Instance Methods
address()
click to toggle source
# File lib/idnow/models/user_data.rb, line 27 def address "#{street} #{streetnumber}, #{zipcode} #{city}, #{country}" end
address_changed?()
click to toggle source
# File lib/idnow/models/user_data.rb, line 31 def address_changed? @raw_data['address'].values.any? { |field| field['status'] == 'CHANGE' } end
Private Instance Methods
dig_value(*keys, data)
click to toggle source
# File lib/idnow/models/user_data.rb, line 37 def dig_value(*keys, data) # TODO: use ruby 2.3 and dig result = data keys.each do |key| result = result.fetch(key, {}) end result['value'] end