Ajout du bundle ednotif (!6)

| 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
- [x] TU/TI/TF OK
- [x] CHANGELOG modifié

Reviewed-on: https://gitea.malio.fr/MALIO-DEV/Ferme/pulls/6
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit is contained in:
tristan
2026-01-27 07:04:19 +00:00
committed by Autin
parent 2cd05a39ba
commit 9ae073e69e
20 changed files with 1767 additions and 1367 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use App\State\BovinIdentificationProvider;
#[ApiResource(
operations: [
new Get(
uriTemplate: '/bovins/{numeroNational}/identification',
provider: BovinIdentificationProvider::class
),
]
)]
final class BovinIdentification
{
#[ApiProperty(identifier: true)]
public string $numeroNational;
public ?string $sex = null;
public ?string $breedType = null;
public ?string $workNumber = null;
public ?string $birthDate = null;
public ?string $birthDateCompletenessFlag = null;
public ?bool $isFilie = null;
public ?string $motherNationalNumber = null;
public ?string $motherBreedType = null;
public ?string $fatherNationalNumber = null;
public ?string $fatherBreedType = null;
public ?string $birthExploitationNumber = null;
/** @var list<PresencePeriod> */
public array $presencePeriods = [];
}
+14
View File
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace App\ApiResource;
final class PresencePeriod
{
public ?string $entryDate = null;
public ?string $entryCause = null;
public ?string $exitDate = null;
public ?string $exitCause = null;
}
+70
View File
@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace App\State;
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;
}
}