From c5bb4d460351035d6b8bda5ca39a7645ea73d6b1 Mon Sep 17 00:00:00 2001 From: tristan Date: Wed, 22 Apr 2026 14:54:57 +0200 Subject: [PATCH] feat : expose IpBCreateEntree via BovinApi::createEntree Co-Authored-By: Claude Opus 4.7 (1M context) --- config/services.php | 8 ++++++ src/Bovin/Api/BovinApi.php | 44 +++++++++++++++++++++++++++++ src/Bovin/Api/BovinApiInterface.php | 4 +++ 3 files changed, 56 insertions(+) diff --git a/config/services.php b/config/services.php index 36dd385..c14d47b 100644 --- a/config/services.php +++ b/config/services.php @@ -7,6 +7,7 @@ use Malio\EdnotifBundle\Bovin\Api\BovinApi; 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\InventoryMapper; use Malio\EdnotifBundle\Bovin\Mapper\PresumedExitsMapper; use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper; @@ -64,6 +65,12 @@ return static function (ContainerConfigurator $container): void { ]) ; + $services->set(CreateEntreeResponseMapper::class) + ->args([ + service(StandardResponseMapper::class), + ]) + ; + $services->set(TokenProvider::class) ->args([ service('ednotif.soap.guichet'), @@ -85,6 +92,7 @@ return static function (ContainerConfigurator $container): void { service(InventoryMapper::class), service(ReturnedDossiersMapper::class), service(PresumedExitsMapper::class), + service(CreateEntreeResponseMapper::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 8fda161..a93fce8 100644 --- a/src/Bovin/Api/BovinApi.php +++ b/src/Bovin/Api/BovinApi.php @@ -7,10 +7,13 @@ namespace Malio\EdnotifBundle\Bovin\Api; use DateTimeInterface; 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\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\InventoryMapper; use Malio\EdnotifBundle\Bovin\Mapper\PresumedExitsMapper; use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper; @@ -29,6 +32,7 @@ final readonly class BovinApi implements BovinApiInterface private InventoryMapper $inventoryMapper, private ReturnedDossiersMapper $returnedDossiersMapper, private PresumedExitsMapper $presumedExitsMapper, + private CreateEntreeResponseMapper $createEntreeResponseMapper, private ZipMessageDecoder $zipMessageDecoder, private string $exploitationCountryCode, private string $exploitationNumber, @@ -158,6 +162,46 @@ final readonly class BovinApi implements BovinApiInterface return $this->presumedExitsMapper->map($soapResponse, $unzippedMessage); } + public function createEntree(CreateEntreeRequest $request): CreateEntreeResponseDto + { + $token = $this->tokenProvider->getToken(); + + $payload = [ + 'JetonAuthentification' => $token, + 'Exploitation' => [ + 'CodePays' => $this->exploitationCountryCode, + 'NumeroExploitation' => $this->exploitationNumber, + ], + 'Bovin' => [ + 'CodePays' => $request->bovin->countryCode, + 'NumeroNational' => $request->bovin->nationalNumber, + ], + 'DateEntree' => $request->date->format('Y-m-d'), + 'CauseEntree' => $request->cause->value, + 'ExploitationProvenance' => [ + 'CodePays' => $request->provenance->countryCode, + 'NumeroExploitation' => $request->provenance->exploitationNumber, + ], + ]; + if (null !== $request->codeAtelier) { + $payload['CodeAtelier'] = $request->codeAtelier; + } + if (null !== $request->codeCategorieBovin) { + $payload['CodeCategorieBovin'] = $request->codeCategorieBovin->value; + } + + try { + /** @var object $soapResponse */ + $soapResponse = $this->businessClient->__soapCall('IpBCreateEntree', [$payload]); + } catch (SoapFault $soapFault) { + throw new RuntimeException('SOAP Fault on IpBCreateEntree: '.$soapFault->getMessage(), 0, $soapFault); + } + + $this->assertSuccessfulResponse($soapResponse, 'IpBCreateEntree'); + + return $this->createEntreeResponseMapper->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 e8131c8..660678b 100644 --- a/src/Bovin/Api/BovinApiInterface.php +++ b/src/Bovin/Api/BovinApiInterface.php @@ -6,6 +6,8 @@ namespace Malio\EdnotifBundle\Bovin\Api; 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\InventoryDto; use Malio\EdnotifBundle\Bovin\Dto\PresumedExitsDto; use Malio\EdnotifBundle\Bovin\Dto\ReturnedDossiersDto; @@ -23,4 +25,6 @@ interface BovinApiInterface public function getReturnedDossiers(DateTimeInterface $startDate): ReturnedDossiersDto; public function getPresumedExits(): PresumedExitsDto; + + public function createEntree(CreateEntreeRequest $request): CreateEntreeResponseDto; }