Skip to content

Commit

Permalink
fix: ANAF can send empty for found key (#18)
Browse files Browse the repository at this point in the history
* fix: ANAF can send empty for found key

* pint
  • Loading branch information
ciungulete authored Jan 13, 2024
1 parent 0828016 commit c8a8d7e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Resources/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Anaf\Resources;

use Anaf\Exceptions\TaxIdentificationNumberNotFoundException;
use Anaf\Exceptions\TransporterException;
use Anaf\Exceptions\UnserializableResponse;
use Anaf\Responses\Info\CreateResponse;
use Anaf\Responses\Info\CreateResponses;
use Anaf\ValueObjects\Transporter\Payload;
Expand All @@ -19,6 +22,10 @@ class Info
* @see https://static.anaf.ro/static/10/Anaf/Informatii_R/Servicii_web/doc_WS_V8.txt
*
* @param list<array{cui: string, data: string}> $parameters
*
* @throws TaxIdentificationNumberNotFoundException
* @throws TransporterException
* @throws UnserializableResponse
*/
public function create(array $parameters): CreateResponse|CreateResponses
{
Expand All @@ -33,6 +40,10 @@ public function create(array $parameters): CreateResponse|CreateResponses
*/
$response = $this->transporter->requestObject($payload);

if (count($response['found']) === 0) {
throw new TaxIdentificationNumberNotFoundException();
}

if (count($response['found']) > 1) {
return CreateResponses::from($response['found']);
}
Expand Down

0 comments on commit c8a8d7e

Please sign in to comment.