From 32a573d4733180b3254cf50260b136e831b10d44 Mon Sep 17 00:00:00 2001 From: tristan Date: Wed, 22 Apr 2026 14:58:32 +0200 Subject: [PATCH] feat : expose IpBCreateSortie via BovinApi::createSortie Co-Authored-By: Claude Opus 4.7 (1M context) --- config/services.php | 8 ++++++ src/Bovin/Api/BovinApi.php | 38 +++++++++++++++++++++++++++++ src/Bovin/Api/BovinApiInterface.php | 4 +++ 3 files changed, 50 insertions(+) diff --git a/config/services.php b/config/services.php index c14d47b..cc9f47d 100644 --- a/config/services.php +++ b/config/services.php @@ -8,6 +8,7 @@ use Malio\EdnotifBundle\Bovin\Api\BovinApiInterface; use Malio\EdnotifBundle\Bovin\Mapper\AnimalFileMapper; use Malio\EdnotifBundle\Bovin\Mapper\AnimalSummaryMapper; use Malio\EdnotifBundle\Bovin\Mapper\CreateEntreeResponseMapper; +use Malio\EdnotifBundle\Bovin\Mapper\CreateSortieResponseMapper; use Malio\EdnotifBundle\Bovin\Mapper\InventoryMapper; use Malio\EdnotifBundle\Bovin\Mapper\PresumedExitsMapper; use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper; @@ -71,6 +72,12 @@ return static function (ContainerConfigurator $container): void { ]) ; + $services->set(CreateSortieResponseMapper::class) + ->args([ + service(StandardResponseMapper::class), + ]) + ; + $services->set(TokenProvider::class) ->args([ service('ednotif.soap.guichet'), @@ -93,6 +100,7 @@ return static function (ContainerConfigurator $container): void { service(ReturnedDossiersMapper::class), service(PresumedExitsMapper::class), service(CreateEntreeResponseMapper::class), + service(CreateSortieResponseMapper::class), service(ZipMessageDecoder::class), '%ednotif.exploitation_country_code%', '%ednotif.exploitation_number%', diff --git a/src/Bovin/Api/BovinApi.php b/src/Bovin/Api/BovinApi.php index a93fce8..dc431f4 100644 --- a/src/Bovin/Api/BovinApi.php +++ b/src/Bovin/Api/BovinApi.php @@ -9,11 +9,14 @@ use Malio\EdnotifBundle\Auth\TokenProvider; use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto; use Malio\EdnotifBundle\Bovin\Dto\CreateEntreeRequest; use Malio\EdnotifBundle\Bovin\Dto\CreateEntreeResponseDto; +use Malio\EdnotifBundle\Bovin\Dto\CreateSortieRequest; +use Malio\EdnotifBundle\Bovin\Dto\CreateSortieResponseDto; use Malio\EdnotifBundle\Bovin\Dto\InventoryDto; use Malio\EdnotifBundle\Bovin\Dto\PresumedExitsDto; use Malio\EdnotifBundle\Bovin\Dto\ReturnedDossiersDto; use Malio\EdnotifBundle\Bovin\Mapper\AnimalFileMapper; use Malio\EdnotifBundle\Bovin\Mapper\CreateEntreeResponseMapper; +use Malio\EdnotifBundle\Bovin\Mapper\CreateSortieResponseMapper; use Malio\EdnotifBundle\Bovin\Mapper\InventoryMapper; use Malio\EdnotifBundle\Bovin\Mapper\PresumedExitsMapper; use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper; @@ -33,6 +36,7 @@ final readonly class BovinApi implements BovinApiInterface private ReturnedDossiersMapper $returnedDossiersMapper, private PresumedExitsMapper $presumedExitsMapper, private CreateEntreeResponseMapper $createEntreeResponseMapper, + private CreateSortieResponseMapper $createSortieResponseMapper, private ZipMessageDecoder $zipMessageDecoder, private string $exploitationCountryCode, private string $exploitationNumber, @@ -202,6 +206,40 @@ final readonly class BovinApi implements BovinApiInterface return $this->createEntreeResponseMapper->map($soapResponse); } + public function createSortie(CreateSortieRequest $request): CreateSortieResponseDto + { + $token = $this->tokenProvider->getToken(); + + $payload = [ + 'JetonAuthentification' => $token, + 'Exploitation' => [ + 'CodePays' => $this->exploitationCountryCode, + 'NumeroExploitation' => $this->exploitationNumber, + ], + 'Bovin' => [ + 'CodePays' => $request->bovin->countryCode, + 'NumeroNational' => $request->bovin->nationalNumber, + ], + 'DateSortie' => $request->date->format('Y-m-d'), + 'CauseSortie' => $request->cause->value, + 'ExploitationDestination' => [ + 'CodePays' => $request->destination->countryCode, + 'NumeroExploitation' => $request->destination->exploitationNumber, + ], + ]; + + try { + /** @var object $soapResponse */ + $soapResponse = $this->businessClient->__soapCall('IpBCreateSortie', [$payload]); + } catch (SoapFault $soapFault) { + throw new RuntimeException('SOAP Fault on IpBCreateSortie: '.$soapFault->getMessage(), 0, $soapFault); + } + + $this->assertSuccessfulResponse($soapResponse, 'IpBCreateSortie'); + + return $this->createSortieResponseMapper->map($soapResponse); + } + private function assertSuccessfulResponse(object $soapResponse, string $operation): void { $standardResponseNode = $soapResponse->ReponseStandard ?? null; diff --git a/src/Bovin/Api/BovinApiInterface.php b/src/Bovin/Api/BovinApiInterface.php index 660678b..8b2c987 100644 --- a/src/Bovin/Api/BovinApiInterface.php +++ b/src/Bovin/Api/BovinApiInterface.php @@ -8,6 +8,8 @@ use DateTimeInterface; use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto; use Malio\EdnotifBundle\Bovin\Dto\CreateEntreeRequest; use Malio\EdnotifBundle\Bovin\Dto\CreateEntreeResponseDto; +use Malio\EdnotifBundle\Bovin\Dto\CreateSortieRequest; +use Malio\EdnotifBundle\Bovin\Dto\CreateSortieResponseDto; use Malio\EdnotifBundle\Bovin\Dto\InventoryDto; use Malio\EdnotifBundle\Bovin\Dto\PresumedExitsDto; use Malio\EdnotifBundle\Bovin\Dto\ReturnedDossiersDto; @@ -27,4 +29,6 @@ interface BovinApiInterface public function getPresumedExits(): PresumedExitsDto; public function createEntree(CreateEntreeRequest $request): CreateEntreeResponseDto; + + public function createSortie(CreateSortieRequest $request): CreateSortieResponseDto; }