Closed yethee closed 2 years ago
use Biplane\YandexDirect\Api\ReportServiceFactory; use Biplane\YandexDirect\Api\V5\Reports; use Biplane\YandexDirect\Config; $config = new Config(...); $service = (new ReportServiceFactory())->create($config); $reportDefinition = Reports\ReportDefinition::create() ->setReportName('test') ->setReportType(Reports\ReportTypeEnum::CAMPAIGN_PERFORMANCE_REPORT) ->setFieldNames([ Reports\FieldEnum::DATE, Reports\FieldEnum::CAMPAIGN_ID, Reports\FieldEnum::IMPRESSIONS, Reports\FieldEnum::CLICKS, Reports\FieldEnum::COST, ]) ->setDateRangeType(Reports\DateRangeTypeEnum::AUTO) ->setIncludeVAT(true); $reportRequest = Reports\ReportRequestBuilder::create() ->setReportDefinition($reportDefinition) ->skipReportHeader(true) ->returnMoneyInMicros(false) ->getReportRequest(); $result = $service->get($reportRequest); if ($result->isReady()) { // process ... } else { echo 'Report is not ready yet.'; }