Class: OmniAuth::Strategies::ParallelMarkets
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::ParallelMarkets
- Defined in:
- lib/omniauth/strategies/parallelmarkets.rb
Instance Method Summary collapse
- #accreditations ⇒ Object
- #authorize_params ⇒ Object
-
#authorize_scopes ⇒ Object
if given ?scope query parameter, use that.
-
#callback_url ⇒ Object
this is dumb, but github.com/omniauth/omniauth-oauth2/issues/93 is still open.
- #profile ⇒ Object
- #raw_accreditations ⇒ Object
- #raw_info ⇒ Object
- #scope?(single_scope) ⇒ Boolean
- #to_contact_details(contact) ⇒ Object
- #user_profile ⇒ Object
Instance Method Details
#accreditations ⇒ Object
73 74 75 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 73 def accreditations @accreditations ||= raw_accreditations.fetch('accreditations', []) end |
#authorize_params ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 35 def super.tap do |params| [:authorize_options].each do |k| params[k] = request.params[k.to_s] if request.params[k.to_s] end end end |
#authorize_scopes ⇒ Object
if given ?scope query parameter, use that. otherwise, use server-side provider configuration
53 54 55 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 53 def @authorize_scopes ||= (env['omniauth.params']['scope'] || ['scope']).split(' ') end |
#callback_url ⇒ Object
this is dumb, but github.com/omniauth/omniauth-oauth2/issues/93 is still open
44 45 46 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 44 def callback_url [:redirect_uri] || (full_host + script_name + callback_path) end |
#profile ⇒ Object
61 62 63 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 61 def profile @profile ||= raw_info.fetch('profile', {}) end |
#raw_accreditations ⇒ Object
69 70 71 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 69 def raw_accreditations @raw_accreditations ||= scope?(:accreditation_status) ? access_token.get('/v1/accreditations').parsed : {} end |
#raw_info ⇒ Object
57 58 59 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 57 def raw_info @raw_info ||= scope?(:profile) ? access_token.get('/v1/me').parsed : {} end |
#scope?(single_scope) ⇒ Boolean
48 49 50 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 48 def scope?(single_scope) .include?(single_scope.to_s) end |
#to_contact_details(contact) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 77 def to_contact_details(contact) (contact.nil? || contact.empty?) ? {} : { name: contact['name'] || "#{contact['first_name']} #{contact['last_name']}", first_name: contact['first_name'], last_name: contact['last_name'], email: contact['email'] } end |
#user_profile ⇒ Object
65 66 67 |
# File 'lib/omniauth/strategies/parallelmarkets.rb', line 65 def user_profile @user_profile ||= raw_info.fetch('user_profile', {}) end |