Class: OmniAuth::Strategies::Etsy

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

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject



37
38
39
40
# File 'lib/omniauth/strategies/etsy.rb', line 37

def callback_phase
  prep_sandbox
  super
end

#prep_sandboxObject



42
43
44
45
46
# File 'lib/omniauth/strategies/etsy.rb', line 42

def prep_sandbox
  if options.sandbox
    options.client_options.merge!(:site => "http://sandbox.openapi.etsy.com/v2")
  end
end

#profile_infoObject



48
49
50
51
# File 'lib/omniauth/strategies/etsy.rb', line 48

def profile_info
  @profile_info ||= user_hash['Profile']
  @profile_info.each { |k,v| @profile_info[k] = '' if v == nil }
end

#raw_infoObject



53
54
55
# File 'lib/omniauth/strategies/etsy.rb', line 53

def raw_info
  @data ||= user_hash
end

#request_phaseObject



29
30
31
32
33
34
35
# File 'lib/omniauth/strategies/etsy.rb', line 29

def request_phase
  if options.scope
    options.request_params.merge!(:scope => options.scope.gsub(',', ' '))
  end
  prep_sandbox
  super
end

#user_hashObject



57
58
59
60
61
62
63
# File 'lib/omniauth/strategies/etsy.rb', line 57

def user_hash
  @user_hash ||= MultiJson.decode(@access_token.get('/users/__SELF__?includes=Profile').body)['results'][0]
rescue ::Errno::ETIMEDOUT
  raise ::Timeout::Error
rescue ::OAuth::Error => e
  raise e.response.inspect
end