lib/ebay/oauth/client_credentials_grant.rb in ebay-ruby-0.3.0 vs lib/ebay/oauth/client_credentials_grant.rb in ebay-ruby-0.3.1
- old
+ new
@@ -1,22 +1,19 @@
# frozen_string_literal: true
-require 'http'
-
require 'ebay/config'
-require 'ebay/sandboxable'
+require 'ebay/requestable'
module Ebay
module Oauth
# Mints an access token to use in API requests
#
# @see https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html
class ClientCredentialsGrant
- include Sandboxable
+ include Requestable
- SANDBOX_ENDPOINT = 'https://api.sandbox.ebay.com/identity/v1/oauth2/token'
- PRODUCTION_ENDPOINT = 'https://api.ebay.com/identity/v1/oauth2/token'
+ self.endpoint = 'https://api.ebay.com/identity/v1/oauth2/token'
# @return [String]
attr_reader :app_id
# @return [String]
@@ -39,17 +36,13 @@
# Requests a client credentials grant
#
# @return [HTTP::Response]
def request
HTTP.basic_auth(user: app_id, pass: cert_id)
- .post(url, form: payload)
+ .post(endpoint, form: payload)
end
private
-
- def url
- sandbox? ? SANDBOX_ENDPOINT : PRODUCTION_ENDPOINT
- end
def payload
{ grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope' }
end