lib/gowalla/client.rb in gowalla-0.4.2 vs lib/gowalla/client.rb in gowalla-0.5.1

- old
+ new

@@ -34,21 +34,27 @@ # Raw HTTP connection, either Faraday::Connection # # @return [Faraday::Connection] def connection - url = @access_token ? "https://api.gowalla.com" : "http://api.gowalla.com" params = {} params[:access_token] = @access_token if @access_token - @connection ||= Faraday::Connection.new(:url => url, :params => params, :headers => default_headers) do |builder| + @connection ||= Faraday::Connection.new(:url => api_url, :params => params, :headers => default_headers) do |builder| builder.adapter Faraday.default_adapter builder.use Faraday::Response::ParseJson builder.use Faraday::Response::Mashify end end + # Provides the URL for accessing the API + # + # @return [String] + def api_url + authentication_credentials_provided? ? "https://api.gowalla.com" : "http://api.gowalla.com" + end + # Provides raw access to the OAuth2 Client # # @return [OAuth2::Client] def oauth_client if @oauth_client @@ -87,9 +93,13 @@ :user_agent => 'Ruby gem', 'X-Gowalla-API-Key' => api_key } end + # @private + def authentication_credentials_provided? + @api_key || @api_secret || @username || @access_token + end end end