class Yelp::Fusion::Client
Constants
- API_HOST
Attributes
configuration[RW]
Public Class Methods
new(option = nil)
click to toggle source
Creates an instance of the fusion client @param options [String, nil] a consumer key @return [Client] a new client initialized with the keys
# File lib/yelp/fusion/client.rb, line 48 def initialize(option = nil) @configuration = nil define_request_methods return if option.nil? @configuration = Configuration.new(option) end
Public Instance Methods
check_api_keys()
click to toggle source
Checks that all the keys needed were given @return [@configuration] a frozen configuration
# File lib/yelp/fusion/client.rb, line 69 def check_api_keys if @configuration.nil? || @configuration.api_key.nil? || defined?(@configuration.api_key).nil? @configuration = nil raise Error::MissingAPIKeys else # Freeze the configuration so it cannot be modified once the gem is # configured. @configuration.freeze end end
configure() { |configuration| ... }
click to toggle source
Creates a configuration with API keys @return [@configuration] a frozen configuration
# File lib/yelp/fusion/client.rb, line 59 def configure raise Error::AlreadyConfigured unless @configuration.nil? @configuration = Configuration.new yield(@configuration) check_api_keys end
connection()
click to toggle source
API connection
# File lib/yelp/fusion/client.rb, line 84 def connection return @connection if instance_variable_defined?(:@connection) check_api_keys @connection = Faraday.new(API_HOST) do |conn| conn.request :oauth2, @configuration.api_key, token_type: :bearer # Using default http library conn.adapter :net_http end end