Class: OmniAuth::Strategies::MiiCard

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/miicard.rb

Instance Method Summary collapse

Instance Method Details

#raw_infoObject



39
40
41
42
43
# File 'lib/omniauth/strategies/miicard.rb', line 39

def raw_info
	@raw_info ||= (MultiJson.decode(access_token.post('/api/v1/Claims.svc/json/GetClaims').body)['Data']) if access_token
rescue ::Errno::ETIMEDOUT
	raise ::Timeout::Error
end

#user_infoObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/omniauth/strategies/miicard.rb', line 45

def 
	@user_info ||= raw_info.nil? ? {} :
		{
			:name			=> raw_info['FirstName'] + " " + raw_info['LastName'],
			:name_public	=> raw_info['FirstName'] + " " + raw_info['LastName'],
			:first_name		=> raw_info['FirstName'],
			:last_name		=> raw_info['LastName'],
			:phone			=> (raw_info['PhoneNumbers'].nil? || raw_info['PhoneNumbers'].empty?) ? nil : '+' + raw_info['PhoneNumbers'][0]['CountryCode'] + raw_info['PhoneNumbers'][0]['NationalNumber'],
			:email			=> (raw_info['EmailAddresses'].nil? || raw_info['EmailAddresses'].empty?) ? nil : raw_info['EmailAddresses'][0]['Address'],
			:urls			=> !raw_info['HasPublicProfile'] ? nil : { "Identity assured by miiCard" => raw_info['ProfileUrl'] }
		}
end