lib/nationbuilder/client.rb in nationbuilder-rb-1.4.3 vs lib/nationbuilder/client.rb in nationbuilder-rb-1.5.0
- old
+ new
@@ -4,10 +4,11 @@
@nation_name = nation_name
@api_key = api_key
@name_to_endpoint = {}
@base_url = opts[:base_url] || 'https://:nation_name.nationbuilder.com'
@retries = opts[:retries] || 8
+ @http_client = opts[:http_client] || HTTPClient.new
if @retries < 0
raise 'Retries must be at least zero'
end
@@ -79,10 +80,10 @@
parsed_response = nil
exception_to_reraise = nil
(@retries + 1).times do |i|
begin
- raw_response = HTTPClient.send(method, url, request_args)
+ raw_response = @http_client.send(method, url, request_args)
parsed_response = parse_response_body(raw_response)
rescue NationBuilder::RateLimitedError => e
exception_to_reraise = e
Kernel.sleep(RETRY_DELAY * 2**i)
rescue => e