feat : DTO et mapper de réponse pour IpBCreateEntree

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-22 14:53:27 +02:00
parent 7c028f79c7
commit 971e160120
3 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Malio\EdnotifBundle\Bovin\Dto;
use Malio\EdnotifBundle\Shared\Dto\StandardResponseDto;
/**
* Réponse de `IpBCreateEntree`.
*
* Si `$pendingBdniValidation === true`, EDNOTIF a accepté la requête mais
* attend la validation asynchrone de la BDNi — `identification` et
* `entryMovement` sont `null`. Sinon, les deux sont populés avec les données
* validées du bovin et du mouvement d'entrée.
*/
final readonly class CreateEntreeResponseDto
{
public function __construct(
public StandardResponseDto $standardResponse,
public bool $pendingBdniValidation,
public ?BovinIdentificationDto $identification,
public ?MovementDto $entryMovement,
public ?object $rawSoapResponse,
) {}
}

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace Malio\EdnotifBundle\Bovin\Mapper;
use Malio\EdnotifBundle\Bovin\Dto\CreateEntreeResponseDto;
use Malio\EdnotifBundle\Shared\Mapper\StandardResponseMapper;
final class CreateEntreeResponseMapper
{
use BovinNodeMappingTrait;
public function __construct(
private readonly StandardResponseMapper $standardResponseMapper,
) {}
public function map(object $soapResponse): CreateEntreeResponseDto
{
$standardResponse = $this->standardResponseMapper->map($soapResponse->ReponseStandard ?? null);
$specific = $soapResponse->ReponseSpecifique ?? null;
$pending = false;
$identification = null;
$entryMovement = null;
if (is_object($specific)) {
$pendingFlag = $specific->AttenteValidationBDNi ?? null;
if (null !== $pendingFlag) {
$pending = (bool) $this->toNullableBool($pendingFlag);
}
$validee = $specific->EntreeValidee ?? null;
if (is_object($validee)) {
$identityNode = $validee->IdentiteBovin ?? null;
if (is_object($identityNode)) {
$identification = $this->mapIdentification($identityNode);
}
$movementNode = $validee->MouvementEntreeBovin ?? null;
if (is_object($movementNode)) {
$entryMovement = $this->mapMovement($movementNode, 'entry');
}
}
}
return new CreateEntreeResponseDto(
standardResponse: $standardResponse,
pendingBdniValidation: $pending,
identification: $identification,
entryMovement: $entryMovement,
rawSoapResponse: $soapResponse,
);
}
}