Class: BingAdsApi::ReportUtils
- Inherits:
-
Object
- Object
- BingAdsApi::ReportUtils
- Defined in:
- lib/bing_ads_api/report_utils.rb
Instance Method Summary collapse
-
#download_report(report_definition, cid = nil) ⇒ Object
Downloads and returns a report.
-
#download_report_as_file(report_definition, path, cid = nil) ⇒ Object
Downloads a report and saves it to a file.
-
#initialize(api, version) ⇒ ReportUtils
constructor
Default constructor.
Constructor Details
#initialize(api, version) ⇒ ReportUtils
Default constructor.
Args:
-
api: BingAdsApi object
-
version: API version to use
17 18 19 |
# File 'lib/bing_ads_api/report_utils.rb', line 17 def initialize(api, version) @api, @version = api, version end |
Instance Method Details
#download_report(report_definition, cid = nil) ⇒ Object
Downloads and returns a report.
Args:
-
report_definition: definition of the report in XML text or hash
-
cid: optional customer ID to run against
Returns:
-
report body
Raises:
-
BingAdsApi::Errors::InvalidReportDefinitionError if the report definition is invalid
-
BingAdsApi::Errors::ReportError if server-side error occurred
35 36 37 |
# File 'lib/bing_ads_api/report_utils.rb', line 35 def download_report(report_definition, cid = nil) return get_report_response(report_definition, cid).body end |
#download_report_as_file(report_definition, path, cid = nil) ⇒ Object
Downloads a report and saves it to a file.
Args:
-
report_definition: definition of the report in XML text or hash
-
path: path to save report to
-
cid: optional customer ID to run against
Returns:
-
nil
Raises:
-
BingAdsApi::Errors::InvalidReportDefinitionError if the report definition is invalid
-
BingAdsApi::Errors::ReportError if server-side error occurred
54 55 56 57 58 |
# File 'lib/bing_ads_api/report_utils.rb', line 54 def download_report_as_file(report_definition, path, cid = nil) report_body = download_report(report_definition, cid) save_to_file(report_body, path) return nil end |