From 064c9d3e933974c343d04532e630a4771d28c7b9 Mon Sep 17 00:00:00 2001 From: thilonel Date: Wed, 29 Nov 2017 23:53:00 +0100 Subject: [PATCH 1/3] workaround for error too many connection resets --- lib/bookingsync/api/client.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/bookingsync/api/client.rb b/lib/bookingsync/api/client.rb index c0b4509b..56ddeb73 100644 --- a/lib/bookingsync/api/client.rb +++ b/lib/bookingsync/api/client.rb @@ -43,6 +43,7 @@ require "bookingsync/api/serializer" require "logger" require "addressable/template" +require "net/http/persistent" module BookingSync::API class Client @@ -264,6 +265,7 @@ def call(method, path, data = nil, options = nil) def middleware Faraday::RackBuilder.new do |builder| + builder.use ::Faraday::Request::Retry, max: 1, exceptions: [::Net::HTTP::Persistent::Error] builder.use :logger, logger builder.adapter :net_http_persistent end From 242ef2c32f8e52840fab8177fd9ba36ae6cf47e0 Mon Sep 17 00:00:00 2001 From: thilonel Date: Wed, 29 Nov 2017 23:57:37 +0100 Subject: [PATCH 2/3] remove unused assignments --- spec/bookingsync/api/client/rentals_amenities_spec.rb | 2 +- spec/bookingsync/api/client_spec.rb | 2 +- spec/bookingsync/api/response_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/bookingsync/api/client/rentals_amenities_spec.rb b/spec/bookingsync/api/client/rentals_amenities_spec.rb index 2bfd4cea..4817a35f 100644 --- a/spec/bookingsync/api/client/rentals_amenities_spec.rb +++ b/spec/bookingsync/api/client/rentals_amenities_spec.rb @@ -30,7 +30,7 @@ } it "returns rentals_amenity" do - amenity = client.rentals_amenity(prefetched_rentals_amenity_id) + client.rentals_amenity(prefetched_rentals_amenity_id) assert_requested :get, bs_url("rentals_amenities/#{prefetched_rentals_amenity_id}") end end diff --git a/spec/bookingsync/api/client_spec.rb b/spec/bookingsync/api/client_spec.rb index 132800db..9dd1cafa 100644 --- a/spec/bookingsync/api/client_spec.rb +++ b/spec/bookingsync/api/client_spec.rb @@ -118,7 +118,7 @@ it "requests with proper User-Agent" do stub_get("resource", body: {}.to_json) - response = client.call(:get, "resource") + client.call(:get, "resource") assert_requested :get, bs_url("resource"), headers: { "User-Agent" => "BookingSync API gem v#{BookingSync::API::VERSION}" } diff --git a/spec/bookingsync/api/response_spec.rb b/spec/bookingsync/api/response_spec.rb index 198351c1..4704f1c0 100644 --- a/spec/bookingsync/api/response_spec.rb +++ b/spec/bookingsync/api/response_spec.rb @@ -29,7 +29,7 @@ end end let(:response) do - stubs = Faraday::Adapter::Test::Stubs.new + Faraday::Adapter::Test::Stubs.new client.call(:get, "/rentals") end From e3ba6b427d718c905b428ab2000eb4ad2ea8a0c6 Mon Sep 17 00:00:00 2001 From: thilonel Date: Wed, 29 Nov 2017 23:59:29 +0100 Subject: [PATCH 3/3] add encoding info to gemspec --- bookingsync-api.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/bookingsync-api.gemspec b/bookingsync-api.gemspec index a8e29fae..c18ccb27 100644 --- a/bookingsync-api.gemspec +++ b/bookingsync-api.gemspec @@ -1,3 +1,4 @@ +# encoding: UTF-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "bookingsync/api/version"