Sha256: 6b23bcb095abc67c836ddb21d14b566fbfb68e121e862841534f956633ff08e8
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 Bytes
Contents
require 'net/http' require_relative '../provider_utils/rate_limit' # Patch the method which retrieves headers for API rate limit dynamically module NS1::Transport class NetHttp def process_response(response) sleep_time = response.to_hash['x-ratelimit-period'].first.to_i / [1, response.to_hash['x-ratelimit-remaining'].first.to_i].max.to_f rate_limit = RateLimit.new('NS1') rate_limit.sleep_for(sleep_time) body = JSON.parse(response.body) case response when Net::HTTPOK NS1::Response::Success.new(body, response.code.to_i) else NS1::Response::Error.new(body, response.code.to_i) end rescue JSON::ParserError raise NS1::Transport::ResponseParseError end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
record_store-6.1.1 | lib/record_store/provider/ns1/patch_api_header.rb |