Exemplo n.º 1
0
 /**
  * @param ReportTicket $reportTicket
  *
  * @return ReportStatus
  * @throws ReportException
  */
 public function getReportStatus(ReportTicket $reportTicket)
 {
     $compiledUrl = $this->baseUrl . '?id=' . $reportTicket->getReportId();
     $response = $this->client->request('GET', $compiledUrl);
     $repositoryResponse = RepositoryResponse::fromResponse($response);
     if (!$repositoryResponse->isSuccessful()) {
         throw ReportException::failed($repositoryResponse);
     }
     if (!isset($repositoryResponse->getResponseAsArray()['response']['report'])) {
         throw ReportException::missingIndex('response->report');
     }
     if (!isset($repositoryResponse->getResponseAsArray()['response']['execution_status'])) {
         throw ReportException::missingIndex('response->execution_status');
     }
     /** @var ReportStatus $reportStatus */
     $reportStatus = ReportStatus::fromArray($repositoryResponse->getResponseAsArray()['response']['report']);
     $reportStatus->setStatus($repositoryResponse->getResponseAsArray()['response']['execution_status']);
     $reportStatus->setReportId($reportTicket->getReportId());
     $reportStatus->setCached($reportTicket->getCached());
     return $reportStatus;
 }