class Bing::Ads::API::HttpClient

Bing::Ads::API::HttpClient

Constants

API_CALL_RETRY_COUNT

Public Class Methods

download(url, retry_count = API_CALL_RETRY_COUNT) click to toggle source
# File lib/bing/ads/api/http_client.rb, line 8
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