class Commercelayer::Client

Constants

MAX_RETRIES

Public Class Methods

new(options={}) click to toggle source
# File lib/commercelayer/client.rb, line 8
def initialize(options={})
  @client_id = options[:client_id]
  @client_secret = options[:client_secret]
  @scope = options[:scope]
  @site = options[:site]
  Resource.site = "#{options[:site]}/api/"
end

Public Instance Methods

authorize!() click to toggle source
# File lib/commercelayer/client.rb, line 16
def authorize!
  Resource.authorize_with = get_access_token
end

Private Instance Methods

get_access_token(options={}) click to toggle source
# File lib/commercelayer/client.rb, line 21
def get_access_token(options={})
  oauth2_client = OAuth2::Client.new(@client_id, @client_secret, site: @site)
  access_token = oauth2_client.client_credentials.get_token(scope: @scope)
  access_token.token
end