feat : restructuration des dossiers pour implementer plus facilement la suite des WS
All checks were successful
Auto Tag Develop / tag (push) Successful in 5s
Build Release Artefact / build (push) Successful in 36s

This commit is contained in:
2026-01-23 16:19:50 +01:00
parent b279f1ac47
commit 7e0c084ebe
36 changed files with 2633 additions and 226 deletions

View File

@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace Malio\EdnotifBundle\Bovin\Api;
use Malio\EdnotifBundle\Auth\TokenProvider;
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
use Malio\EdnotifBundle\Bovin\Mapper\AnimalFileMapper;
use Malio\EdnotifBundle\Shared\Exception\EdnotifException;
use RuntimeException;
use SoapClient;
use SoapFault;
final readonly class BovinApi implements BovinApiInterface
{
public function __construct(
private TokenProvider $tokenProvider,
private SoapClient $businessClient,
private AnimalFileMapper $bovinDossierMapper,
private string $exploitationCountryCode,
private string $exploitationNumber,
) {}
public function getAnimalFile(string $nationalNumber, string $countryCode = 'FR'): AnimalFileDto
{
$token = $this->tokenProvider->getToken();
$requestPayload = [[
'JetonAuthentification' => $token,
'Exploitation' => [
'CodePays' => $this->exploitationCountryCode,
'NumeroExploitation' => $this->exploitationNumber,
],
'Bovin' => [
'CodePays' => $countryCode,
'NumeroNational' => $nationalNumber,
],
]];
try {
/** @var object $soapResponse */
$soapResponse = $this->businessClient->__soapCall('IpBGetDossierAnimal', $requestPayload);
} catch (SoapFault $soapFault) {
throw new RuntimeException('SOAP Fault on IpBGetDossierAnimal: '.$soapFault->getMessage(), 0, $soapFault);
}
// Throw uniquement si Resultat=false (erreur métier)
$standardResponseNode = $soapResponse->ReponseStandard ?? null;
$isOk = is_object($standardResponseNode) && (($standardResponseNode->Resultat ?? false) === true);
if (!$isOk) {
$anomalyNode = is_object($standardResponseNode) ? ($standardResponseNode->Anomalie ?? null) : null;
throw new EdnotifException(
codeAnomalie: (string) ($anomalyNode->Code ?? 'UNKNOWN'),
severite: (int) ($anomalyNode->Severite ?? 1),
message: (string) ($anomalyNode->Message ?? 'EDNOTIF error')
);
}
return $this->bovinDossierMapper->map($soapResponse);
}
}