feat: ajout des 3 derniers WS en lecture du bundle malio ednotif (!47)
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
- 3 nouveaux endpoints API Platform pass-through sur /api/bovins/{inventory|returned-dossiers|presumed-exits} consommant BovinApiInterface v0.0.6
- AnimalSummaryMapper (src/Service/) factorisant le mapping DTO EDNOTIF -> ressource
- src/State/ réorganisé par domaine (Bovin/, Reception/, Shipment/, Building/, User/, System/)
- tag OpenAPI "Bovins" pour regrouper les endpoints ednotif dans Swagger
- malio/ednotif-bundle passé à v0.0.6
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| Numéro du ticket | Titre du ticket |
|------------------|-----------------|
| | |
## Description de la PR
## Modification du .env
## Check list
- [ ] Pas de régression
- [ ] TU/TI/TF rédigée
- [ ] TU/TI/TF OK
- [ ] CHANGELOG modifié
Reviewed-on: #47
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #47.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\Bovin;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
76
src/State/Bovin/BovinInventoryProvider.php
Normal file
76
src/State/Bovin/BovinInventoryProvider.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State\Bovin;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\ApiResource\BovinInventory;
|
||||
use App\Service\AnimalSummaryMapper;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use Malio\EdnotifBundle\Bovin\Api\BovinApiInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
use function count;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* @implements ProviderInterface<null|BovinInventory>
|
||||
*/
|
||||
final class BovinInventoryProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private BovinApiInterface $bovinApi,
|
||||
private RequestStack $requestStack,
|
||||
private AnimalSummaryMapper $animalSummaryMapper,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?BovinInventory
|
||||
{
|
||||
$startDateRaw = (string) ($uriVariables['startDate'] ?? '');
|
||||
if ('' === $startDateRaw) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$startDate = new DateTimeImmutable($startDateRaw);
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
|
||||
$endDate = null;
|
||||
$endDateRaw = $request?->query->get('endDate');
|
||||
if (is_string($endDateRaw) && '' !== $endDateRaw) {
|
||||
try {
|
||||
$endDate = new DateTimeImmutable($endDateRaw);
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$includeEarTagStock = (bool) $request?->query->getBoolean('includeEarTagStock', false);
|
||||
|
||||
$inventoryDto = $this->bovinApi->getInventory(
|
||||
startDate: $startDate,
|
||||
endDate: $endDate,
|
||||
includeEarTagStock: $includeEarTagStock,
|
||||
);
|
||||
|
||||
$resource = new BovinInventory();
|
||||
$resource->startDate = $inventoryDto->startDate?->format('Y-m-d') ?? $startDate->format('Y-m-d');
|
||||
$resource->endDate = $inventoryDto->endDate?->format('Y-m-d');
|
||||
$resource->includesEarTagStock = $inventoryDto->includesEarTagStock;
|
||||
$resource->nbBovins = $inventoryDto->nbBovins;
|
||||
$resource->earTagSeriesCount = count($inventoryDto->earTagSeries);
|
||||
|
||||
foreach ($inventoryDto->animals as $animalDto) {
|
||||
$resource->animals[] = $this->animalSummaryMapper->map($animalDto);
|
||||
}
|
||||
|
||||
return $resource;
|
||||
}
|
||||
}
|
||||
40
src/State/Bovin/BovinPresumedExitsProvider.php
Normal file
40
src/State/Bovin/BovinPresumedExitsProvider.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State\Bovin;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\ApiResource\BovinPresumedExit;
|
||||
use App\ApiResource\BovinPresumedExits;
|
||||
use Malio\EdnotifBundle\Bovin\Api\BovinApiInterface;
|
||||
|
||||
/**
|
||||
* @implements ProviderInterface<BovinPresumedExits>
|
||||
*/
|
||||
final class BovinPresumedExitsProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private BovinApiInterface $bovinApi,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): BovinPresumedExits
|
||||
{
|
||||
$dto = $this->bovinApi->getPresumedExits();
|
||||
|
||||
$resource = new BovinPresumedExits();
|
||||
$resource->nbBovins = $dto->nbBovins;
|
||||
|
||||
foreach ($dto->presumedExits as $exitDto) {
|
||||
$exit = new BovinPresumedExit();
|
||||
$exit->countryCode = $exitDto->bovin?->countryCode;
|
||||
$exit->nationalNumber = $exitDto->bovin?->nationalNumber;
|
||||
$exit->exitDate = $exitDto->exitDate?->format('Y-m-d');
|
||||
|
||||
$resource->presumedExits[] = $exit;
|
||||
}
|
||||
|
||||
return $resource;
|
||||
}
|
||||
}
|
||||
50
src/State/Bovin/BovinReturnedDossiersProvider.php
Normal file
50
src/State/Bovin/BovinReturnedDossiersProvider.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State\Bovin;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\ApiResource\BovinReturnedDossiers;
|
||||
use App\Service\AnimalSummaryMapper;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use Malio\EdnotifBundle\Bovin\Api\BovinApiInterface;
|
||||
|
||||
/**
|
||||
* @implements ProviderInterface<null|BovinReturnedDossiers>
|
||||
*/
|
||||
final class BovinReturnedDossiersProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private BovinApiInterface $bovinApi,
|
||||
private AnimalSummaryMapper $animalSummaryMapper,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?BovinReturnedDossiers
|
||||
{
|
||||
$startDateRaw = (string) ($uriVariables['startDate'] ?? '');
|
||||
if ('' === $startDateRaw) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$startDate = new DateTimeImmutable($startDateRaw);
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dto = $this->bovinApi->getReturnedDossiers($startDate);
|
||||
|
||||
$resource = new BovinReturnedDossiers();
|
||||
$resource->startDate = $dto->startDate?->format('Y-m-d') ?? $startDate->format('Y-m-d');
|
||||
$resource->nbBovins = $dto->nbBovins;
|
||||
|
||||
foreach ($dto->animals as $animalDto) {
|
||||
$resource->animals[] = $this->animalSummaryMapper->map($animalDto);
|
||||
}
|
||||
|
||||
return $resource;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\Bovin;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\Building;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\Reception;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\Reception;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\Shipment;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\Shipment;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\System;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\User;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\User;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
namespace App\State\User;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
Reference in New Issue
Block a user