src/Google/AdsApi/AdManager/Util/v201805/ReportDownloader.php
public function downloadReport($exportFormat, $filePath = null)
    {
        $downloadUrl = $this->getDownloadUrl($exportFormat);

        $requestOptions = [];
        $requestOptions[RequestOptions::HEADERS] = [
            'User-Agent' => $this->getFormattedUserAgent()
        ];
        $proxy = $this->reportService->getAdsSession()->getConnectionSettings()
            ->getProxyUrl();
        if (!empty($proxy)) {
            $requestOptions[RequestOptions::PROXY] = ['https' => $proxy];
        }
        if ($filePath !== null) {
            $requestOptions[RequestOptions::SINK] = $filePath;
            $this->httpClient->request('GET', $downloadUrl, $requestOptions);
        } else {
            $requestOptions[RequestOptions::STREAM] = true;
            $response = $this->httpClient->request(
                'GET',
                $downloadUrl,
                $requestOptions
            );

            return $response->getBody();
        }
    }
public function downloadReport($exportFormat, $filePath = null)
    {
        $downloadUrl = $this->getDownloadUrl($exportFormat);

        $requestOptions = [];
        $requestOptions[RequestOptions::HEADERS] = [
            'User-Agent' => $this->getFormattedUserAgent()
        ];
        $proxy = $this->reportService->getAdsSession()->getConnectionSettings()
            ->getProxyUrl();
        if (!empty($proxy)) {
            $requestOptions[RequestOptions::PROXY] = ['https' => $proxy];
        }
        if ($filePath !== null) {
            $requestOptions[RequestOptions::SINK] = $filePath;
            $this->httpClient->request('GET', $downloadUrl, $requestOptions);
        } else {
            $requestOptions[RequestOptions::STREAM] = true;
            $response = $this->httpClient->request(
                'GET',
                $downloadUrl,
                $requestOptions
            );

            return $response->getBody();
        }
    }
public function downloadReport ( $ exportFormat , $ filePath = null ) { $ downloadUrl = $ this -> getDownloadUrl ( $ exportFormat ) ; $ requestOptions = [ ] ; $ requestOptions [ RequestOptions :: HEADERS ] = [ 'User-Agent' => $ this -> getFormattedUserAgent ( ) ] ; $ proxy = $ this -> reportService -> getAdsSession ( ) -> getConnectionSettings ( ) -> getProxyUrl ( ) ; if ( ! empty ( $ proxy ) ) { $ requestOptions [ RequestOptions :: PROXY ] = [ 'https' => $ proxy ] ; } if ( $ filePath !== null ) { $ requestOptions [ RequestOptions :: SINK ] = $ filePath ; $ this -> httpClient -> request ( 'GET' , $ downloadUrl , $ requestOptions ) ; } else { $ requestOptions [ RequestOptions :: STREAM ] = true ; $ response = $ this -> httpClient -> request ( 'GET' , $ downloadUrl , $ requestOptions ) ; return $ response -> getBody ( ) ; } }
Downloads the report with the specified export format.

@param string $exportFormat the export format of the report
@param string $filePath an optional file path to download the report to
@return void|StreamInterface nothing if a file path is specified,
otherwise report contents as a stream
@throws UnexpectedValueException if the report is still in progress or
has failed
Downloads the report with the specified export format .