lib/foursquare2/client.rb in foursquare2-1.8.2 vs lib/foursquare2/client.rb in foursquare2-1.9.0
- old
+ new
@@ -21,11 +21,11 @@
include Pages
include Campaigns
include Lists
include Events
- attr_reader :client_id, :client_secret, :oauth_token, :api_version
+ attr_reader :client_id, :client_secret, :oauth_token, :api_version, :locale
#Initialize the client class that will be used for all foursquare API requests. Note that either a valid user oauth token OR a valid client_id + secret is required.
#
#Certain requests will require an oauth token. See http://developer.foursquare.com/docs/index_docs.html for the full list.
#
@@ -36,16 +36,17 @@
# @option options String :api_version A date formatted as YYYYMMDD indicating the API version you intend to use
# @option options Array :connection_middleware A collection of different middleware to be applied when the connection is created
# @option options Hash :ssl Additional SSL options (like the path to certificate file)
def initialize(options={})
- @client_id = options[:client_id]
- @client_secret = options[:client_secret]
+ @client_id = options[:client_id] || Foursquare2.client_id
+ @client_secret = options[:client_secret] || Foursquare2.client_secret
@oauth_token = options[:oauth_token]
- @api_version = options[:api_version]
- @ssl = options[:ssl].nil? ? Hash.new : options[:ssl]
- @connection_middleware = options.fetch(:connection_middleware, [])
+ @api_version = options[:api_version] || Foursquare2.api_version
+ @locale = options[:locale] || Foursquare2.locale
+ @ssl = options[:ssl] || Foursquare2.ssl || Hash.new
+ @connection_middleware = options[:connection_middleware] || Foursquare2.connection_middleware || []
@connection_middleware += DEFAULT_CONNECTION_MIDDLEWARE
end
def ssl
@ssl
@@ -57,9 +58,10 @@
params = {}
params[:client_id] = @client_id if @client_id
params[:client_secret] = @client_secret if @client_secret
params[:oauth_token] = @oauth_token if @oauth_token
params[:v] = @api_version if @api_version
+ params[:locale] = @locale if @locale
@connection ||= Faraday::Connection.new(:url => api_url, :ssl => @ssl, :params => params, :headers => default_headers) do |builder|
@connection_middleware.each do |middleware|
builder.use *middleware
end
builder.adapter Faraday.default_adapter