Ejemplo n.º 1
0
 /**
  * @test
  */
 public function get_report_status_will_return_an_object_containing_the_downaload_id()
 {
     $client = $this->prophesize(Auth::class);
     $uploadTicket = new ReportTicket();
     $uploadTicket->setReportId('_a_job_id');
     $fakeResponse = $this->getFakeResponse($this->getReportStatus());
     $client->request('GET', Argument::any(), Argument::any())->willReturn($fakeResponse);
     $report = new Report($client->reveal());
     $reportTicket = $report->getReportStatus($uploadTicket);
     $this->assertEquals('report-download?id=4b22a2c9a361f6d8a8feb99c10745a66', $reportTicket->getUrl());
 }
Ejemplo n.º 2
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;
 }