lib/homeflow/api/request.rb in homeflow_api-0.17.14 vs lib/homeflow/api/request.rb in homeflow_api-0.17.15
- old
+ new
@@ -20,15 +20,11 @@
end
response
end
def perform_request
- if request_specification.is_a? Query
- url = "#{Homeflow::API.config.source}/#{request_specification.resource_class.resource_uri}"
- else
- url = "#{Homeflow::API.config.source}/#{request_specification.resource_uri}"
- end
+ url = normalised_base_url
query_params = @request_specification.to_params.merge(constant_params)
post_params = (@request_specification.respond_to?(:post_params) ? @request_specification.post_params : {})
if Homeflow::API.config.show_debug && Homeflow::API.configuration.logger
log_line = []
log_line << "Destination - #{url}"
@@ -47,9 +43,18 @@
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))
elsif request_specification.is_a? Post
return (self.class.post(url, :query => query_params, :body => post_params))
+ end
+ end
+
+ def normalised_base_url
+ source = Homeflow::API.config.source.gsub(/.\/$/,'')
+ if request_specification.is_a? Query
+ return "#{source}/#{request_specification.resource_class.resource_uri}"
+ else
+ return "#{source}/#{request_specification.resource_uri}"
end
end
def body_of_request(request)
if request.respond_to? :body