feat : expose IpBGetRetourDossiers via BovinApi::getReturnedDossiers
This commit is contained in:
@@ -8,6 +8,7 @@ use Malio\EdnotifBundle\Bovin\Api\BovinApiInterface;
|
|||||||
use Malio\EdnotifBundle\Bovin\Mapper\AnimalFileMapper;
|
use Malio\EdnotifBundle\Bovin\Mapper\AnimalFileMapper;
|
||||||
use Malio\EdnotifBundle\Bovin\Mapper\AnimalSummaryMapper;
|
use Malio\EdnotifBundle\Bovin\Mapper\AnimalSummaryMapper;
|
||||||
use Malio\EdnotifBundle\Bovin\Mapper\InventoryMapper;
|
use Malio\EdnotifBundle\Bovin\Mapper\InventoryMapper;
|
||||||
|
use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper;
|
||||||
use Malio\EdnotifBundle\Shared\Mapper\StandardResponseMapper;
|
use Malio\EdnotifBundle\Shared\Mapper\StandardResponseMapper;
|
||||||
use Malio\EdnotifBundle\Shared\Soap\SoapClientFactory;
|
use Malio\EdnotifBundle\Shared\Soap\SoapClientFactory;
|
||||||
use Malio\EdnotifBundle\Shared\Soap\ZipMessageDecoder;
|
use Malio\EdnotifBundle\Shared\Soap\ZipMessageDecoder;
|
||||||
@@ -49,6 +50,13 @@ return static function (ContainerConfigurator $container): void {
|
|||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$services->set(ReturnedDossiersMapper::class)
|
||||||
|
->args([
|
||||||
|
service(AnimalSummaryMapper::class),
|
||||||
|
service(StandardResponseMapper::class),
|
||||||
|
])
|
||||||
|
;
|
||||||
|
|
||||||
$services->set(TokenProvider::class)
|
$services->set(TokenProvider::class)
|
||||||
->args([
|
->args([
|
||||||
service('ednotif.soap.guichet'),
|
service('ednotif.soap.guichet'),
|
||||||
@@ -68,6 +76,7 @@ return static function (ContainerConfigurator $container): void {
|
|||||||
service('ednotif.soap.business'),
|
service('ednotif.soap.business'),
|
||||||
service(AnimalFileMapper::class),
|
service(AnimalFileMapper::class),
|
||||||
service(InventoryMapper::class),
|
service(InventoryMapper::class),
|
||||||
|
service(ReturnedDossiersMapper::class),
|
||||||
service(ZipMessageDecoder::class),
|
service(ZipMessageDecoder::class),
|
||||||
'%ednotif.exploitation_country_code%',
|
'%ednotif.exploitation_country_code%',
|
||||||
'%ednotif.exploitation_number%',
|
'%ednotif.exploitation_number%',
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ use DateTimeInterface;
|
|||||||
use Malio\EdnotifBundle\Auth\TokenProvider;
|
use Malio\EdnotifBundle\Auth\TokenProvider;
|
||||||
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
|
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
|
||||||
use Malio\EdnotifBundle\Bovin\Dto\InventoryDto;
|
use Malio\EdnotifBundle\Bovin\Dto\InventoryDto;
|
||||||
|
use Malio\EdnotifBundle\Bovin\Dto\ReturnedDossiersDto;
|
||||||
use Malio\EdnotifBundle\Bovin\Mapper\AnimalFileMapper;
|
use Malio\EdnotifBundle\Bovin\Mapper\AnimalFileMapper;
|
||||||
use Malio\EdnotifBundle\Bovin\Mapper\InventoryMapper;
|
use Malio\EdnotifBundle\Bovin\Mapper\InventoryMapper;
|
||||||
|
use Malio\EdnotifBundle\Bovin\Mapper\ReturnedDossiersMapper;
|
||||||
use Malio\EdnotifBundle\Shared\Exception\EdnotifException;
|
use Malio\EdnotifBundle\Shared\Exception\EdnotifException;
|
||||||
use Malio\EdnotifBundle\Shared\Soap\ZipMessageDecoder;
|
use Malio\EdnotifBundle\Shared\Soap\ZipMessageDecoder;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
@@ -23,6 +25,7 @@ final readonly class BovinApi implements BovinApiInterface
|
|||||||
private SoapClient $businessClient,
|
private SoapClient $businessClient,
|
||||||
private AnimalFileMapper $bovinDossierMapper,
|
private AnimalFileMapper $bovinDossierMapper,
|
||||||
private InventoryMapper $inventoryMapper,
|
private InventoryMapper $inventoryMapper,
|
||||||
|
private ReturnedDossiersMapper $returnedDossiersMapper,
|
||||||
private ZipMessageDecoder $zipMessageDecoder,
|
private ZipMessageDecoder $zipMessageDecoder,
|
||||||
private string $exploitationCountryCode,
|
private string $exploitationCountryCode,
|
||||||
private string $exploitationNumber,
|
private string $exploitationNumber,
|
||||||
@@ -93,6 +96,36 @@ final readonly class BovinApi implements BovinApiInterface
|
|||||||
return $this->inventoryMapper->map($soapResponse, $unzippedMessage);
|
return $this->inventoryMapper->map($soapResponse, $unzippedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getReturnedDossiers(DateTimeInterface $startDate): ReturnedDossiersDto
|
||||||
|
{
|
||||||
|
$token = $this->tokenProvider->getToken();
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'JetonAuthentification' => $token,
|
||||||
|
'Exploitation' => [
|
||||||
|
'CodePays' => $this->exploitationCountryCode,
|
||||||
|
'NumeroExploitation' => $this->exploitationNumber,
|
||||||
|
],
|
||||||
|
'DateDebut' => $startDate->format('Y-m-d'),
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
/** @var object $soapResponse */
|
||||||
|
$soapResponse = $this->businessClient->__soapCall('IpBGetRetourDossiers', [$payload]);
|
||||||
|
} catch (SoapFault $soapFault) {
|
||||||
|
throw new RuntimeException('SOAP Fault on IpBGetRetourDossiers: '.$soapFault->getMessage(), 0, $soapFault);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSuccessfulResponse($soapResponse, 'IpBGetRetourDossiers');
|
||||||
|
|
||||||
|
$messageZip = $soapResponse->ReponseSpecifique->MessageZip ?? null;
|
||||||
|
$unzippedMessage = is_string($messageZip) && '' !== $messageZip
|
||||||
|
? $this->zipMessageDecoder->decode($messageZip)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return $this->returnedDossiersMapper->map($soapResponse, $unzippedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
private function assertSuccessfulResponse(object $soapResponse, string $operation): void
|
private function assertSuccessfulResponse(object $soapResponse, string $operation): void
|
||||||
{
|
{
|
||||||
$standardResponseNode = $soapResponse->ReponseStandard ?? null;
|
$standardResponseNode = $soapResponse->ReponseStandard ?? null;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Malio\EdnotifBundle\Bovin\Api;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
|
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
|
||||||
use Malio\EdnotifBundle\Bovin\Dto\InventoryDto;
|
use Malio\EdnotifBundle\Bovin\Dto\InventoryDto;
|
||||||
|
use Malio\EdnotifBundle\Bovin\Dto\ReturnedDossiersDto;
|
||||||
|
|
||||||
interface BovinApiInterface
|
interface BovinApiInterface
|
||||||
{
|
{
|
||||||
@@ -17,4 +18,6 @@ interface BovinApiInterface
|
|||||||
?DateTimeInterface $endDate = null,
|
?DateTimeInterface $endDate = null,
|
||||||
bool $includeEarTagStock = false,
|
bool $includeEarTagStock = false,
|
||||||
): InventoryDto;
|
): InventoryDto;
|
||||||
|
|
||||||
|
public function getReturnedDossiers(DateTimeInterface $startDate): ReturnedDossiersDto;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user