42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Domain\Shared\Application\Response;
|
|
|
|
use App\Domain\Shared\Domain\Contract\ResponseInterface;
|
|
use App\Domain\Shared\Domain\Model\Job;
|
|
|
|
readonly class JobResponse implements ResponseInterface
|
|
{
|
|
public function __construct(
|
|
public string $id,
|
|
public string $type,
|
|
public string $status,
|
|
public \DateTimeImmutable $createdAt,
|
|
public ?\DateTimeImmutable $startedAt,
|
|
public ?\DateTimeImmutable $completedAt,
|
|
public ?string $failureReason,
|
|
public int $attempts,
|
|
public int $maxAttempts,
|
|
public array $context
|
|
) {
|
|
}
|
|
|
|
public static function fromJob(Job $job): self
|
|
{
|
|
return new self(
|
|
id: $job->id,
|
|
type: $job->type,
|
|
status: $job->status->value,
|
|
createdAt: $job->createdAt,
|
|
startedAt: $job->startedAt,
|
|
completedAt: $job->completedAt,
|
|
failureReason: $job->failureReason,
|
|
attempts: $job->attempts,
|
|
maxAttempts: $job->maxAttempts,
|
|
context: $job->context
|
|
);
|
|
}
|
|
}
|