module JustimmoClient::V1::JustimmoRequest
@api private
Public Instance Methods
get(path, params = {})
click to toggle source
# File lib/justimmo_client/api/v1/requests/justimmo_request.rb, line 12 def get(path, params = {}) request(path, params) end
request(path, params = {})
click to toggle source
# File lib/justimmo_client/api/v1/requests/justimmo_request.rb, line 16 def request(path, params = {}) uri = "#{JustimmoClient::Config.url}/#{path}" options = { params: params, Authorization: "Basic #{JustimmoClient::Config.credentials}" } Retriable.retriable do with_request_error_handler do log.debug("Requesting #{uri} with params #{options[:params]}") RestClient.proxy = JustimmoClient::Config.proxy log.debug("Using proxy: #{RestClient.proxy}") if RestClient.proxy response = RestClient.get(uri, options) response.body end end end
with_request_error_handler() { || ... }
click to toggle source
# File lib/justimmo_client/api/v1/requests/justimmo_request.rb, line 35 def with_request_error_handler yield rescue RestClient::Unauthorized log.error("Authentication failed, check your configuration.") raise JustimmoClient::AuthenticationFailed rescue RestClient::Exception, SocketError, Errno::ECONNREFUSED => e raise JustimmoClient::RetrievalFailed, e end