Class: Bing::Ads::API::V11::Services::Reporting

Inherits:
Base
  • Object
show all
Defined in:
lib/bing/ads/api/v11/services/reporting.rb

Overview

Bing::Ads::API::V11::Services::CampaignManagement

Instance Attribute Summary

Attributes inherited from Base

#environment, #retry_attempts, #soap_client

Instance Method Summary collapse

Methods inherited from Base

#call, #response_body

Constructor Details

#initialize(options = {}) ⇒ Reporting

Returns a new instance of Reporting.



8
9
10
# File 'lib/bing/ads/api/v11/services/reporting.rb', line 8

def initialize(options = {})
  super(options)
end

Instance Method Details

#poll_generate_report(report_request_id) ⇒ Object



19
20
21
22
23
# File 'lib/bing/ads/api/v11/services/reporting.rb', line 19

def poll_generate_report(report_request_id)
  response = call(:poll_generate_report, report_request_id: report_request_id)
  response_body = response_body(response, __method__)
  response_body
end

#report_body(report_request_id) ⇒ Object



37
38
39
# File 'lib/bing/ads/api/v11/services/reporting.rb', line 37

def report_body(report_request_id)
  HttpClient.download(report_url(report_request_id))
end

#report_ready?(report_request_id) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/bing/ads/api/v11/services/reporting.rb', line 25

def report_ready?(report_request_id)
  polled = poll_generate_report(report_request_id)
  status = polled.dig(:report_request_status, :status)
  raise "Report status: Error for ID: #{report_request_id}" if status == "Error"
  status == "Success"
end

#report_url(report_request_id) ⇒ Object



32
33
34
35
# File 'lib/bing/ads/api/v11/services/reporting.rb', line 32

def report_url(report_request_id)
  polled = poll_generate_report(report_request_id)
  polled.dig(:report_request_status, :report_download_url)
end

#submit_generate_report(type, report_options) ⇒ Object



12
13
14
15
16
17
# File 'lib/bing/ads/api/v11/services/reporting.rb', line 12

def submit_generate_report(type, report_options)
  payload = Bing::Ads::API::V11::Data::ReportRequest.prepare(type, report_options)
  response = call(:submit_generate_report, payload)
  response_body = response_body(response, __method__)
  response_body
end