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>
71 lines
2.5 KiB
PHP
71 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\State\Bovin;
|
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
use ApiPlatform\State\ProviderInterface;
|
|
use App\ApiResource\BovinIdentification;
|
|
use App\ApiResource\PresencePeriod;
|
|
use Malio\EdnotifBundle\Bovin\Api\BovinApiInterface;
|
|
|
|
/**
|
|
* @implements ProviderInterface<null|BovinIdentification>
|
|
*/
|
|
final class BovinIdentificationProvider implements ProviderInterface
|
|
{
|
|
public function __construct(
|
|
private BovinApiInterface $bovinApi
|
|
) {}
|
|
|
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?BovinIdentification
|
|
{
|
|
$numeroNational = (string) ($uriVariables['numeroNational'] ?? '');
|
|
if ('' === $numeroNational) {
|
|
return null;
|
|
}
|
|
|
|
$animalFileDto = $this->bovinApi->getAnimalFile(
|
|
nationalNumber: $numeroNational,
|
|
countryCode: 'FR'
|
|
);
|
|
|
|
$identificationDto = $animalFileDto->identification;
|
|
|
|
$resource = new BovinIdentification();
|
|
$resource->numeroNational = $numeroNational;
|
|
|
|
$resource->sex = $identificationDto?->sex;
|
|
$resource->breedType = $identificationDto?->breedType;
|
|
$resource->workNumber = $identificationDto?->workNumber;
|
|
|
|
$resource->birthDate = $identificationDto?->birthDate?->date?->format('Y-m-d');
|
|
$resource->birthDateCompletenessFlag = $identificationDto?->birthDate?->completenessFlag;
|
|
|
|
$resource->isFilie = $identificationDto?->isFilie;
|
|
|
|
$resource->motherNationalNumber = $identificationDto?->motherCarrier?->bovin?->nationalNumber;
|
|
$resource->motherBreedType = $identificationDto?->motherCarrier?->breedType;
|
|
|
|
$resource->fatherNationalNumber = $identificationDto?->fatherIpg?->bovin?->nationalNumber;
|
|
$resource->fatherBreedType = $identificationDto?->fatherIpg?->breedType;
|
|
|
|
$resource->birthExploitationNumber = $identificationDto?->birthExploitation?->exploitationNumber;
|
|
|
|
foreach ($animalFileDto->presencePeriods as $presencePeriodDto) {
|
|
$presencePeriod = new PresencePeriod();
|
|
|
|
$presencePeriod->entryDate = $presencePeriodDto->entry?->date?->format('Y-m-d');
|
|
$presencePeriod->entryCause = $presencePeriodDto->entry?->cause;
|
|
|
|
$presencePeriod->exitDate = $presencePeriodDto->exit?->date?->format('Y-m-d');
|
|
$presencePeriod->exitCause = $presencePeriodDto->exit?->cause;
|
|
|
|
$resource->presencePeriods[] = $presencePeriod;
|
|
}
|
|
|
|
return $resource;
|
|
}
|
|
}
|