\Google\AdsApi\AdManager\Util\v202108ReportDownloader

Provides functionality to help with retrieving a report. Encapsulates common tasks, such as polling for a report's status until it is ready to be downloaded and downloading the report.

Summary

Methods
Properties
Constants
__construct()
waitForReportToFinish()
downloadReport()
No public properties found
DEFAULT_POLL_SECONDS
No protected methods found
No protected properties found
N/A
getDownloadUrl()
getFormattedUserAgent()
$REDACTED_DATA_MESSAGE
$logger
$reportService
$reportJobId
$pollTimeSeconds
$httpClient
N/A

Constants

DEFAULT_POLL_SECONDS

DEFAULT_POLL_SECONDS

Properties

$REDACTED_DATA_MESSAGE

$REDACTED_DATA_MESSAGE :

Type

$logger

$logger :

Type

$reportService

$reportService :

Type

$reportJobId

$reportJobId :

Type

$pollTimeSeconds

$pollTimeSeconds :

Type

$httpClient

$httpClient :

Type

Methods

__construct()

__construct(\Google\AdsApi\AdManager\v202108\ReportService  $reportService,integer  $reportJobId,integer|null  $pollTimeSeconds = null,\GuzzleHttp\Client|null  $httpClient = null,\Google\AdsApi\Common\GuzzleHttpClientFactory|null  $httpClientFactory = null)

Creates a downloader for the specified report job ID and requires an instance of a report service for making API calls on the report.

Parameters

\Google\AdsApi\AdManager\v202108\ReportService $reportService
integer $reportJobId
integer|null $pollTimeSeconds

optional, specify the time to sleep, in seconds, when polling for a report's status

\GuzzleHttp\Client|null $httpClient

optional, the Guzzle HTTP client whose handler stacks this library's logging middleware will be pushed to

\Google\AdsApi\Common\GuzzleHttpClientFactory|null $httpClientFactory

optional, the Guzzle HTTP client factory that will generate a client handling HTTP calls

waitForReportToFinish()

waitForReportToFinish(): boolean

Blocks and waits for the report to finish running by polling for the report's status and sleeping in between polls.

Returns

boolean —

whether or not the report finished successfully

downloadReport()

downloadReport(string  $exportFormat,string  $filePath = null): void|\Psr\Http\Message\StreamInterface

Downloads the report with the specified export format.

Parameters

string $exportFormat

the export format of the report

string $filePath

an optional file path to download the report to

Throws

\UnexpectedValueException

if the report is still in progress or has failed

Returns

void|\Psr\Http\Message\StreamInterface —

nothing if a file path is specified, otherwise report contents as a stream

getDownloadUrl()

getDownloadUrl(string  $exportFormat): string

Gets the download URL for the report.

Parameters

string $exportFormat

the export format of the report

Throws

\UnexpectedValueException

if the report is still in progress or has failed

Returns

string —

the download URL for the report

getFormattedUserAgent()

getFormattedUserAgent()