Sha256: 0f6cf39bc08b37e2e3266ccfae5e7e9263f8d0c6c2f50e01b27ef0cc704ad382

Contents?: true

Size: 998 Bytes

Versions: 5

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true
module SoapyBing
  module Soap
    module Request
      class PollGenerateReportRequest < Base
        class FailedStatusError < StandardError; end
        class PendingStatusError < StandardError; end
        class PollingTimeoutError < StandardError; end

        API_BASE_URL = 'https://reporting.api.bingads.microsoft.com'
        API_VERSION = 9
        API_ENDPOINT =
          "#{API_BASE_URL}/Api/Advertiser/Reporting/V#{API_VERSION}/ReportingService.svc"

        POLLING_TRIES = 100

        def perform
          Retryable.retryable(tries: POLLING_TRIES, on: PendingStatusError) { poll! }
        rescue PendingStatusError
          raise PollingTimeoutError
        end

        private

        def poll!
          response = Response::PollGenerateReportResponse.new(post(API_ENDPOINT))
          raise PendingStatusError if response.pending?
          raise FailedStatusError if response.error?
          response
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soapy_bing-0.3.1 lib/soapy_bing/soap/request/poll_generate_report_request.rb
soapy_bing-0.3.0 lib/soapy_bing/soap/request/poll_generate_report_request.rb
soapy_bing-0.2.0 lib/soapy_bing/soap/request/poll_generate_report_request.rb
soapy_bing-0.1.0 lib/soapy_bing/soap/request/poll_generate_report_request.rb
soapy_bing-0.0.5 lib/soapy_bing/soap/request/poll_generate_report_request.rb