Sha256: 19c29d49065ffda6e5fffe9acfaf1e74ede67a0f2edb59630daf2b82a20a6774

Contents?: true

Size: 979 Bytes

Versions: 4

Compression:

Stored size: 979 Bytes

Contents

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'.freeze
        API_VERSION = 9
        API_ENDPOINT =
          "#{API_BASE_URL}/Api/Advertiser/Reporting/V#{API_VERSION}/ReportingService.svc".freeze

        POLLING_TRIES = 40

        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))
          fail PendingStatusError if response.pending?
          fail FailedStatusError if response.error?
          response
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
soapy_bing-0.0.4 lib/soapy_bing/soap/request/poll_generate_report_request.rb
soapy_bing-0.0.3 lib/soapy_bing/soap/request/poll_generate_report_request.rb
soapy_bing-0.0.2 lib/soapy_bing/soap/request/poll_generate_report_request.rb
soapy_bing-0.0.1 lib/soapy_bing/soap/request/poll_generate_report_request.rb