lib/homeflow/api/request.rb in homeflow_api-0.17.8 vs lib/homeflow/api/request.rb in homeflow_api-0.17.9
- old
+ new
@@ -12,11 +12,11 @@
@request_specification = request_specification
end
def perform
begin
- response = perform_request
+ response = body_of_request(perform_request)
rescue Errno::ECONNREFUSED => e
raise Homeflow::API::Exceptions::APIConnectionError, "Connection error. Homeflow might be down?"
end
response
end
@@ -38,18 +38,26 @@
log_line << "@request_specification:\n#{@request_specification.to_json}\n"
Homeflow::API.configuration.logger.info(log_line.join("\n"))
end
if request_specification.is_a? Query
- return (self.class.get(url, :query => query_params)).body
+ return (self.class.get(url, :query => query_params))
elsif request_specification.is_a? ResourceIdentifier
- return (self.class.get(url, :query => query_params)).body
+ return (self.class.get(url, :query => query_params))
elsif request_specification.is_a? Delete
- return (self.class.delete(url, :query => query_params)).body
+ return (self.class.delete(url, :query => query_params))
elsif request_specification.is_a? Put
- return (self.class.put(url, :query => query_params, :body => post_params)).body
+ return (self.class.put(url, :query => query_params, :body => post_params))
elsif request_specification.is_a? Post
- return (self.class.post(url, :query => query_params, :body => post_params)).body
+ return (self.class.post(url, :query => query_params, :body => post_params))
+ end
+ end
+
+ def body_of_request(request)
+ if resquest.respond_to? :body
+ request.body
+ else
+ body
end
end
def constant_params