feat : DTO et mapper de réponse pour IpBCreateSortie
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
66
src/Bovin/Mapper/CreateSortieResponseMapper.php
Normal file
66
src/Bovin/Mapper/CreateSortieResponseMapper.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Malio\EdnotifBundle\Bovin\Mapper;
|
||||
|
||||
use Malio\EdnotifBundle\Bovin\Dto\CreateSortieResponseDto;
|
||||
use Malio\EdnotifBundle\Shared\Mapper\StandardResponseMapper;
|
||||
|
||||
final class CreateSortieResponseMapper
|
||||
{
|
||||
use BovinNodeMappingTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly StandardResponseMapper $standardResponseMapper,
|
||||
) {}
|
||||
|
||||
public function map(object $soapResponse): CreateSortieResponseDto
|
||||
{
|
||||
$standardResponse = $this->standardResponseMapper->map($soapResponse->ReponseStandard ?? null);
|
||||
|
||||
$specific = $soapResponse->ReponseSpecifique ?? null;
|
||||
|
||||
$pending = false;
|
||||
$identification = null;
|
||||
$entryMovement = null;
|
||||
$exitMovement = null;
|
||||
|
||||
if (is_object($specific)) {
|
||||
$pendingFlag = $specific->AttenteValidationBDNi ?? null;
|
||||
if (null !== $pendingFlag) {
|
||||
$pending = (bool) $this->toNullableBool($pendingFlag);
|
||||
}
|
||||
|
||||
$validee = $specific->SortieValidee ?? null;
|
||||
if (is_object($validee)) {
|
||||
$identityNode = $validee->IdentiteBovin ?? null;
|
||||
if (is_object($identityNode)) {
|
||||
$identification = $this->mapIdentification($identityNode);
|
||||
}
|
||||
|
||||
$mouvementBovin = $validee->MouvementBovin ?? null;
|
||||
if (is_object($mouvementBovin)) {
|
||||
$entryNode = $mouvementBovin->MouvementEntreeBovin ?? null;
|
||||
if (is_object($entryNode)) {
|
||||
$entryMovement = $this->mapMovement($entryNode, 'entry');
|
||||
}
|
||||
|
||||
$exitNode = $mouvementBovin->MouvementSortieBovin ?? null;
|
||||
if (is_object($exitNode)) {
|
||||
$exitMovement = $this->mapMovement($exitNode, 'exit');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new CreateSortieResponseDto(
|
||||
standardResponse: $standardResponse,
|
||||
pendingBdniValidation: $pending,
|
||||
identification: $identification,
|
||||
entryMovement: $entryMovement,
|
||||
exitMovement: $exitMovement,
|
||||
rawSoapResponse: $soapResponse,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user