feat: firsts endpoints and firsts tests
This commit is contained in:
parent
89570ad951
commit
6bc3696190
@@ -0,0 +1,45 @@
|
||||
<?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: 'ScrapingStatus',
|
||||
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
|
||||
) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user