Skip to content

Commit 70ecc39

Browse files
committed
BUGFIX: Job::getId() returns JobId Object
1 parent 8a68640 commit 70ecc39

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Classes/Dto/Job.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
namespace Flowpack\Prunner\Dto;
55

6+
use Flowpack\Prunner\ValueObject\JobId;
67
use Neos\Flow\Annotations as Flow;
78

89
/**
910
* @Flow\Proxy(false)
1011
*/
1112
class Job
1213
{
13-
private string $id;
14+
private JobId $id;
1415
/**
1516
* @var string Pipeline name
1617
*/
@@ -26,7 +27,7 @@ class Job
2627
private array $variables;
2728
private string $user;
2829

29-
private function __construct(string $id, string $pipeline, TaskResults $taskResults, bool $completed, bool $canceled, bool $errored, \DateTimeImmutable $created, ?\DateTimeImmutable $start, ?\DateTimeImmutable $end, ?string $lastError, array $variables, string $user)
30+
private function __construct(JobId $id, string $pipeline, TaskResults $taskResults, bool $completed, bool $canceled, bool $errored, \DateTimeImmutable $created, ?\DateTimeImmutable $start, ?\DateTimeImmutable $end, ?string $lastError, array $variables, string $user)
3031
{
3132
$this->id = $id;
3233
$this->pipeline = $pipeline;
@@ -46,7 +47,7 @@ private function __construct(string $id, string $pipeline, TaskResults $taskResu
4647
public static function fromJsonArray(array $in): self
4748
{
4849
return new self(
49-
$in['id'],
50+
JobId::create($in['id']),
5051
$in['pipeline'],
5152
TaskResults::fromJsonArray($in['tasks']),
5253
$in['completed'],
@@ -64,7 +65,7 @@ public static function fromJsonArray(array $in): self
6465
/**
6566
* @return string
6667
*/
67-
public function getId(): string
68+
public function getId(): JobId
6869
{
6970
return $this->id;
7071
}

Classes/PrunnerApiService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function schedulePipeline(PipelineName $pipeline, array $variables): JobI
8181

8282
public function cancelJob(Job $job): void
8383
{
84-
$response = $this->apiCall('POST', 'job/cancel?' . http_build_query(['id' => $job->getId()]), '');
84+
$response = $this->apiCall('POST', 'job/cancel?' . http_build_query(['id' => $job->getId()->getId()]), '');
8585
if ($response->getStatusCode() !== 200) {
8686
throw new \RuntimeException('Cancelling a job should have returned status code 200, but got: ' . $response->getStatusCode());
8787
}

0 commit comments

Comments
 (0)