class OmniAuth::EbayOauth::UserInfo

Maps user information from Auth'n'auth eBay API to OmniAuth Auth Hash Schema version 1.0 github.com/omniauth/omniauth/wiki/Auth-Hash-Schema

Constants

MAPPING

Public Class Methods

new(body) click to toggle source
# File lib/omniauth/ebay-oauth/user_info.rb, line 16
def initialize(body)
  @body = body
end

Public Instance Methods

extra() click to toggle source
# File lib/omniauth/ebay-oauth/user_info.rb, line 34
def extra
  { raw_info: @body.dig('GetUserResponse', 'User') }
end
info() click to toggle source
# File lib/omniauth/ebay-oauth/user_info.rb, line 24
def info
  {
    name: field(:name, required: true),
    email: field(:email),
    nickname: field(:nickname),
    first_name: field(:name).split.first,
    last_name: field(:name).split.last
  }
end
uid() click to toggle source
# File lib/omniauth/ebay-oauth/user_info.rb, line 20
def uid
  field(:uid, required: true)
end

Private Instance Methods

field(name, required: false) click to toggle source
# File lib/omniauth/ebay-oauth/user_info.rb, line 40
def field(name, required: false)
  @body.dig(*MAPPING.fetch(name)).tap do |value|
    if value.nil? && required
      raise UnsupportedSchemaError, "Can't find field #{name}"
    end
  end
end