lib/nationbuilder/client.rb in nationbuilder-rb-1.5.0 vs lib/nationbuilder/client.rb in nationbuilder-rb-1.6.0

- old
+ new

@@ -74,18 +74,17 @@ method.validate_args(method_args) return raw_call(method.uri, method.http_method, nonmethod_args, args) end def perform_request_with_retries(method, url, request_args) - raw_response = nil parsed_response = nil exception_to_reraise = nil (@retries + 1).times do |i| begin - raw_response = @http_client.send(method, url, request_args) - parsed_response = parse_response_body(raw_response) + set_response(@http_client.send(method, url, request_args)) + parsed_response = parse_response_body(response) rescue NationBuilder::RateLimitedError => e exception_to_reraise = e Kernel.sleep(RETRY_DELAY * 2**i) rescue => e raise e @@ -94,15 +93,12 @@ break end end # If the retry cycle ended with an error, reraise it - if exception_to_reraise - raise exception_to_reraise - end + raise exception_to_reraise if exception_to_reraise - set_response(raw_response) parsed_response end def set_response(value) Thread.current[:nationbuilder_rb_response] = value @@ -131,10 +127,10 @@ content_type = response.header['Content-Type'].first unless content_type && content_type.include?('application/json') return true end - parsed_body(response.body).merge('status_code' => response.code) + parsed_body(response.body) end def print_all_descriptions endpoints.each do |endpoint_name| self.print_description(endpoint_name)