lib/keen/client/maintenance_methods.rb in keen-0.8.7 vs lib/keen/client/maintenance_methods.rb in keen-0.8.8

- old
+ new

@@ -14,11 +14,11 @@ ensure_master_key! query_params = preprocess_params(params) if params != {} begin - response = Keen::HTTP::Sync.new(self.api_url, self.proxy_url).delete( + response = http_sync.delete( :path => [api_event_collection_resource_path(event_collection), query_params].compact.join('?'), :headers => api_headers(self.master_key, "sync")) rescue Exception => http_error raise HttpError.new("Couldn't perform delete of #{event_collection} on Keen IO: #{http_error.message}", http_error) end @@ -33,11 +33,11 @@ def event_collections ensure_project_id! ensure_master_key! begin - response = Keen::HTTP::Sync.new(self.api_url, self.proxy_url).get( + response = http_sync.get( :path => "/#{api_version}/projects/#{project_id}/events", :headers => api_headers(self.master_key, "sync")) rescue Exception => http_error raise HttpError.new("Couldn't perform events on Keen IO: #{http_error.message}", http_error) end @@ -52,18 +52,24 @@ def project_info ensure_project_id! ensure_master_key! begin - response = Keen::HTTP::Sync.new(self.api_url, self.proxy_url).get( + response = http_sync.get( :path => "/#{api_version}/projects/#{project_id}", :headers => api_headers(self.master_key, "sync")) rescue Exception => http_error raise HttpError.new("Couldn't perform project info on Keen IO: #{http_error.message}", http_error) end response_body = response.body ? response.body.chomp : '' process_response(response.code, response_body) + end + + private + + def http_sync + @http_sync ||= Keen::HTTP::Sync.new(self.api_url, self.proxy_url, self.read_timeout) end end end end