lib/spark_api/request.rb in spark_api-1.3.16 vs lib/spark_api/request.rb in spark_api-1.3.17
- old
+ new
@@ -1,5 +1,6 @@
+require 'json'
require 'cgi'
module SparkApi
# HTTP request wrapper. Performs all the api session mumbo jumbo so that the models don't have to.
module Request
@@ -68,30 +69,30 @@
start_time = Time.now
if [:get, :delete, :head].include?(method.to_sym)
response = authenticator.request(method, request_path, nil, request_opts)
else
post_data = process_request_body(body)
- SparkApi.logger.debug("#{method.to_s.upcase} Data: #{post_data}")
+ SparkApi.logger.debug { "#{method.to_s.upcase} Data: #{post_data}" }
response = authenticator.request(method, request_path, post_data, request_opts)
end
request_time = Time.now - start_time
- SparkApi.logger.debug("[#{(request_time * 1000).to_i}ms] Api: #{method.to_s.upcase} #{request_path}")
+ SparkApi.logger.debug { "[#{(request_time * 1000).to_i}ms] Api: #{method.to_s.upcase} #{request_path}" }
rescue PermissionDenied => e
if(ResponseCodes::SESSION_TOKEN_EXPIRED == e.code)
unless (attempts +=1) > 1
- SparkApi.logger.debug("Retrying authentication")
+ SparkApi.logger.debug { "Retrying authentication" }
authenticate
retry
end
end
# No luck authenticating... KABOOM!
- SparkApi.logger.error("Authentication failed or server is sending us expired tokens, nothing we can do here.")
+ SparkApi.logger.error { "Authentication failed or server is sending us expired tokens, nothing we can do here." }
raise
end
response.body
rescue Faraday::Error::ConnectionFailed => e
if self.ssl_verify && e.message =~ /certificate verify failed/
- SparkApi.logger.error(SparkApi::Errors.ssl_verification_error)
+ SparkApi.logger.error { SparkApi::Errors.ssl_verification_error }
end
raise e
end
def process_request_body(body)