class Gecko::Client
The Gecko::Client
class
Attributes
access_token[RW]
Access the OAuth AccessToken for this client
@return [OAuth2::AccessToken]
@api public
oauth_client[R]
Return OAuth client
@return [OAuth2::Client]
@api private
Public Class Methods
default_headers()
click to toggle source
# File lib/gecko/client.rb, line 116 def self.default_headers { 'User-Agent' => ["Gecko/#{Gecko::VERSION}", "OAuth2/#{OAuth2::Version}", "Faraday/#{Faraday::VERSION}", "Ruby/#{RUBY_VERSION}"].join(' ') } end
new(client_id, client_secret, options = {})
click to toggle source
Initialize a new Gecko
client object with an instantiated OAuth2::Client
@param [String] client_id @param [String] client_secret @param [#to_hash] extra options hash to pass to the OAuth2::Client
@return [undefined]
@api private
# File lib/gecko/client.rb, line 63 def initialize(client_id, client_secret, options = {}) setup_oauth_client(client_id, client_secret, options) end
Public Instance Methods
adapter_for(klass_name)
click to toggle source
Fetch the adapter for a specified Gecko::Record
class
@param [String] klass_name Gecko::Record
subclass name
@return [Gecko::Record::BaseAdapter]
@api private
# File lib/gecko/client.rb, line 112 def adapter_for(klass_name) public_send(klass_name.to_sym) end
Private Instance Methods
setup_oauth_client(client_id, client_secret, options)
click to toggle source
# File lib/gecko/client.rb, line 127 def setup_oauth_client(client_id, client_secret, options) defaults = { site: 'https://api.tradegecko.com', authorize_url: 'https://commerce.intuit.com/oauth/authorize', connection_opts: { headers: self.class.default_headers } } @oauth_client = OAuth2::Client.new(client_id, client_secret, defaults.merge(options)) end