feat : expose IpBGetSortiesPresumees via BovinApi::getPresumedExits

This commit is contained in:
2026-04-21 09:00:38 +02:00
parent 6493c8a1a7
commit c939190987
3 changed files with 43 additions and 0 deletions

View File

@@ -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\InventoryMapper;
use Malio\EdnotifBundle\Bovin\Mapper\PresumedExitsMapper;
use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper;
use Malio\EdnotifBundle\Shared\Mapper\StandardResponseMapper;
use Malio\EdnotifBundle\Shared\Soap\SoapClientFactory;
@@ -57,6 +58,12 @@ return static function (ContainerConfigurator $container): void {
])
;
$services->set(PresumedExitsMapper::class)
->args([
service(StandardResponseMapper::class),
])
;
$services->set(TokenProvider::class)
->args([
service('ednotif.soap.guichet'),
@@ -77,6 +84,7 @@ return static function (ContainerConfigurator $container): void {
service(AnimalFileMapper::class),
service(InventoryMapper::class),
service(ReturnedDossiersMapper::class),
service(PresumedExitsMapper::class),
service(ZipMessageDecoder::class),
'%ednotif.exploitation_country_code%',
'%ednotif.exploitation_number%',

View File

@@ -8,9 +8,11 @@ use DateTimeInterface;
use Malio\EdnotifBundle\Auth\TokenProvider;
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
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\InventoryMapper;
use Malio\EdnotifBundle\Bovin\Mapper\PresumedExitsMapper;
use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper;
use Malio\EdnotifBundle\Shared\Exception\EdnotifException;
use Malio\EdnotifBundle\Shared\Soap\ZipMessageDecoder;
@@ -26,6 +28,7 @@ final readonly class BovinApi implements BovinApiInterface
private AnimalFileMapper $bovinDossierMapper,
private InventoryMapper $inventoryMapper,
private ReturnedDossiersMapper $returnedDossiersMapper,
private PresumedExitsMapper $presumedExitsMapper,
private ZipMessageDecoder $zipMessageDecoder,
private string $exploitationCountryCode,
private string $exploitationNumber,
@@ -126,6 +129,35 @@ final readonly class BovinApi implements BovinApiInterface
return $this->returnedDossiersMapper->map($soapResponse, $unzippedMessage);
}
public function getPresumedExits(): PresumedExitsDto
{
$token = $this->tokenProvider->getToken();
$payload = [
'JetonAuthentification' => $token,
'Exploitation' => [
'CodePays' => $this->exploitationCountryCode,
'NumeroExploitation' => $this->exploitationNumber,
],
];
try {
/** @var object $soapResponse */
$soapResponse = $this->businessClient->__soapCall('IpBGetSortiesPresumees', [$payload]);
} catch (SoapFault $soapFault) {
throw new RuntimeException('SOAP Fault on IpBGetSortiesPresumees: '.$soapFault->getMessage(), 0, $soapFault);
}
$this->assertSuccessfulResponse($soapResponse, 'IpBGetSortiesPresumees');
$messageZip = $soapResponse->ReponseSpecifique->MessageZip ?? null;
$unzippedMessage = is_string($messageZip) && '' !== $messageZip
? $this->zipMessageDecoder->decode($messageZip)
: null;
return $this->presumedExitsMapper->map($soapResponse, $unzippedMessage);
}
private function assertSuccessfulResponse(object $soapResponse, string $operation): void
{
$standardResponseNode = $soapResponse->ReponseStandard ?? null;

View File

@@ -7,6 +7,7 @@ namespace Malio\EdnotifBundle\Bovin\Api;
use DateTimeInterface;
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
use Malio\EdnotifBundle\Bovin\Dto\InventoryDto;
use Malio\EdnotifBundle\Bovin\Dto\PresumedExitsDto;
use Malio\EdnotifBundle\Bovin\Dto\ReturnedDossiersDto;
interface BovinApiInterface
@@ -20,4 +21,6 @@ interface BovinApiInterface
): InventoryDto;
public function getReturnedDossiers(DateTimeInterface $startDate): ReturnedDossiersDto;
public function getPresumedExits(): PresumedExitsDto;
}