Class: MyinfoRuby::Client
- Inherits:
-
Object
- Object
- MyinfoRuby::Client
- Includes:
- Security
- Defined in:
- lib/myinfo_ruby/client.rb
Instance Method Summary collapse
- #fetch_personal ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
Methods included from Security
#create_token_request, #decrypt_JWE_response, #get_personal_data, #verify_JWS
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/myinfo_ruby/client.rb', line 7 def initialize config # Token api url @token_url = config[:token_url] # Personal api url @personal_url = config[:personal_url] # authorization code @code = config[:code] @private_key = config[:private_key] @client_id = config[:client_id] @client_secret = config[:client_secret] # Attributes to be fetched from MyInfo @attributes = config[:attributes] @redirect_uri = config[:redirect_url] @auth_level = config[:auth_level] end |
Instance Method Details
#fetch_personal ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/myinfo_ruby/client.rb', line 23 def fetch_personal # ********* Access Token ********* token_response = create_token_request(@token_url, @code, @redirect_url, @client_id, @client_secret, @auth_level, @private_key) # ********* Verify JWS ********* decoded_jws = verify_JWS(token_response, @private_key) # ********* Personal Data *********' personal_response = get_personal_data(@personal_url, decoded_jws['sub'], token_response, @client_id, @attributes, @auth_level, @private_key) if personal_response.code == 200 personal_data = decrypt_JWE_response(personal_response, @private_key) personal_data['uinfin'] = decoded_jws['sub'] personal_data else puts "#{personal_response.code} : Error occoured while Fetching data" personal_response end end |