lib/nationbuilder/client.rb in nationbuilder-rb-1.2.1 vs lib/nationbuilder/client.rb in nationbuilder-rb-1.2.2

- old
+ new

@@ -5,12 +5,12 @@ @api_key = api_key @name_to_endpoint = {} @base_url = opts[:base_url] || 'https://:nation_name.nationbuilder.com' @retries = opts[:retries] || 8 - if @retries < 1 - raise 'A positive number of retries must be specified' + if @retries < 0 + raise 'Retries must be at least zero' end parsed_endpoints.each do |endpoint| @name_to_endpoint[endpoint.name] = endpoint end @@ -73,10 +73,10 @@ def perform_request_with_retries(method, url, request_args) raw_response = HTTPClient.send(method, url, request_args) parsed_response = nil - @retries.times do |i| + (@retries + 1).times do |i| begin parsed_response = parse_response_body(raw_response) rescue NationBuilder::RateLimitedError Kernel.sleep(RETRY_DELAY * 2**i) rescue => e