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); } $this->assertSuccessfulResponse($soapResponse, 'IpBGetDossierAnimal'); return $this->bovinDossierMapper->map($soapResponse); } public function getInventory( DateTimeInterface $startDate, ?DateTimeInterface $endDate = null, bool $includeEarTagStock = false, ): InventoryDto { $token = $this->tokenProvider->getToken(); $payload = [ 'JetonAuthentification' => $token, 'Exploitation' => [ 'CodePays' => $this->exploitationCountryCode, 'NumeroExploitation' => $this->exploitationNumber, ], 'DateDebut' => $startDate->format('Y-m-d'), 'StockBoucles' => $includeEarTagStock, ]; if (null !== $endDate) { $payload['DateFin'] = $endDate->format('Y-m-d'); } try { /** @var object $soapResponse */ $soapResponse = $this->businessClient->__soapCall('IpBGetInventaire', [$payload]); } catch (SoapFault $soapFault) { throw new RuntimeException('SOAP Fault on IpBGetInventaire: '.$soapFault->getMessage(), 0, $soapFault); } $this->assertSuccessfulResponse($soapResponse, 'IpBGetInventaire'); $messageZip = $soapResponse->ReponseSpecifique->MessageZip ?? null; $unzippedMessage = is_string($messageZip) && '' !== $messageZip ? $this->zipMessageDecoder->decode($messageZip) : null; 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); } 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; $isOk = is_object($standardResponseNode) && (($standardResponseNode->Resultat ?? false) === true); if ($isOk) { return; } $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 ?? $operation.' : EDNOTIF error') ); } }