43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Scraping\Infrastructure\ApiPlatform\Dto;
|
|
|
|
use ApiPlatform\Metadata\ApiProperty;
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Get;
|
|
use App\Domain\Scraping\Infrastructure\ApiPlatform\State\Provider\ScrapingStatusStateProvider;
|
|
use ApiPlatform\Metadata\Link;
|
|
use App\Domain\Scraping\Domain\Model\ScrapingJob;
|
|
|
|
#[ApiResource(
|
|
shortName: 'Scraping',
|
|
operations: [
|
|
new Get(
|
|
uriTemplate: '/scraping/jobs/{jobId}/status',
|
|
provider: ScrapingStatusStateProvider::class,
|
|
uriVariables: [
|
|
'jobId' => new Link(
|
|
fromProperty: 'jobId',
|
|
toProperty: 'id',
|
|
fromClass: ScrapingStatusResponse::class,
|
|
toClass: ScrapingJob::class
|
|
)
|
|
]
|
|
),
|
|
],
|
|
)]
|
|
readonly class ScrapingStatusResponse
|
|
{
|
|
public function __construct(
|
|
#[ApiProperty(identifier: true)]
|
|
public string $jobId,
|
|
#[ApiProperty]
|
|
public string $status,
|
|
#[ApiProperty]
|
|
public ?float $progress = null,
|
|
#[ApiProperty]
|
|
public ?string $error = null
|
|
) {
|
|
}
|
|
}
|