Class: OmniAuth::Strategies::Delivery

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/delivery.rb

Constant Summary collapse

DEFAULT_SCOPE =
"global"
PRODUCTION_USER_SITE =
'https://laundryapi.delivery.com'
PRODUCTION_API_SITE =
'https://api.delivery.com'
DEVELOPMENT_USER_SITE =
'http://laundryqa.delivery.com'
DEVELOPMENT_API_SITE =
'http://sandbox.delivery.com'
@@mode =
:production

Instance Method Summary collapse

Instance Method Details

#auth_hashObject



45
46
47
48
# File 'lib/omniauth/strategies/delivery.rb', line 45

def auth_hash
  OmniAuth::Utils.deep_merge(super, client_params.merge({
    :grant_type => 'authorization_code'}))
end

#callback_phaseObject



50
51
52
53
# File 'lib/omniauth/strategies/delivery.rb', line 50

def callback_phase
  options.client_options.site = @@mode == :development ? DEVELOPMENT_API_SITE : PRODUCTION_API_SITE
  super
end

#raw_infoObject



55
56
57
58
59
60
# File 'lib/omniauth/strategies/delivery.rb', line 55

def raw_info
  access_token.options[:mode] = :query
  access_token.options[:param_name] = :token
  user_site = @@mode == :development ? DEVELOPMENT_USER_SITE : PRODUCTION_USER_SITE
  @raw_info ||= access_token.post(user_site + '/api/v1/customer/auth').parsed
end

#request_phaseObject



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

def request_phase
  @@mode = :development if authorize_params.include?(:development)
  options[:authorize_options].delete(:development)
  options.client_options.site = @@mode == :development ? DEVELOPMENT_API_SITE : PRODUCTION_API_SITE
  options[:authorize_params] = client_params.merge(options[:authorize_params])
  super
end