class OmniAuth::Strategies::ParallelMarkets

Public Instance Methods

accreditations() click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 75
def accreditations
  @accreditations ||= raw_accreditations.fetch('accreditations', [])
end
authorize_params() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/parallelmarkets.rb, line 37
def authorize_params
  super.tap do |params|
    options[:authorize_options].each do |k|
      params[k] = request.params[k.to_s] if request.params[k.to_s]
    end
  end
end
authorize_scopes() click to toggle source

if given ?scope query parameter, use that. otherwise, use server-side provider configuration

# File lib/omniauth/strategies/parallelmarkets.rb, line 55
def authorize_scopes
  @authorize_scopes ||= (env['omniauth.params']['scope'] || authorize_params['scope']).split(' ')
end
callback_url() click to toggle source

this is dumb, but github.com/omniauth/omniauth-oauth2/issues/93 is still open

# File lib/omniauth/strategies/parallelmarkets.rb, line 46
def callback_url
  options[:redirect_uri] || (full_host + script_name + callback_path)
end
identity_details() click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 83
def identity_details
  @identity_details ||= raw_identity['identity_details']
end
profile() click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 63
def profile
  @profile ||= raw_info.fetch('profile', {})
end
raw_accreditations() click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 71
def raw_accreditations
  @raw_accreditations ||= scope?(:accreditation_status) ? access_token.get('/v1/accreditations').parsed : {}
end
raw_identity() click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 79
def raw_identity
  @raw_identity ||= scope?(:identity) ? access_token.get('/v1/identity').parsed : {}
end
raw_info() click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 59
def raw_info
  @raw_info ||= scope?(:profile) ? access_token.get('/v1/me').parsed : {}
end
scope?(single_scope) click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 50
def scope?(single_scope)
  authorize_scopes.include?(single_scope.to_s)
end
to_contact_details(contact) click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 87
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() click to toggle source
# File lib/omniauth/strategies/parallelmarkets.rb, line 67
def user_profile
  @user_profile ||= raw_info.fetch('user_profile', {})
end