Class: OmniAuth::Strategies::Intuit

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

Constant Summary collapse

USER_INFO_ENDPOINT =
"/v1/openid_connect/userinfo"
BASE_SCOPES =
"openid email profile"
VALID_SCOPES =
%w[openid profile email phone addess com.intuit.quickbooks.accounting com.intuit.quickbooks.payment].freeze
USER_BASE_URLS =
{ 
  production: "https://accounts.platform.intuit.com",
  sandbox: "https://sandbox-accounts.platform.intuit.com",
}

Instance Method Summary collapse

Instance Method Details

#prune!(hash) ⇒ Object



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

def prune!(hash)
  hash.delete_if do |_, value|
    prune!(value) if value.is_a?(Hash)
    value.nil? || (value.respond_to?(:empty?) && value.empty?)
  end
end

#raw_infoObject



40
41
42
# File 'lib/omniauth/strategies/intuit.rb', line 40

def raw_info
  @raw_info ||= access_token.get(user_endpoint_url(options.mode)).parsed
end

#user_endpoint_url(mode) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/omniauth/strategies/intuit.rb', line 44

def user_endpoint_url(mode)
   = nil
  if valid_mode && options.mode == :production
     = USER_BASE_URLS[:production] + USER_INFO_ENDPOINT
  else
     = USER_BASE_URLS[:sandbox] + USER_INFO_ENDPOINT
  end
  
end

#valid_modeObject



36
37
38
# File 'lib/omniauth/strategies/intuit.rb', line 36

def valid_mode
  USER_BASE_URLS.has_key? options.mode
end

#verified_emailObject



54
55
56
# File 'lib/omniauth/strategies/intuit.rb', line 54

def verified_email
  raw_info["emailVerified"] ? raw_info["email"] : nil
end