Sha256: 4d9cf499e9db4a6eee882a560b9aaea2807608908461151b6e46d7cf5ad88f76

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

module Bing
  module Ads
    module API
      # Bing::Ads::API::HttpClient
      class HttpClient
        API_CALL_RETRY_COUNT = 3

        def self.download(url, retry_count = API_CALL_RETRY_COUNT)
          1.upto(retry_count + 1) do |retry_index|
            response = Net::HTTP.get_response(URI(url))
            if response.is_a?(Net::HTTPSuccess)
              break response.body
            else
              next if retry_index <= retry_count
              raise Bing::Ads::API::Errors::DownloadError, "#{response.code} #{response.msg}"
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bing-ads-0.2.0 lib/bing/ads/api/http_client.rb