Comando para resetear Toku

This commit is contained in:
Juan Pablo Vial
2025-05-27 18:17:56 -04:00
parent a9a10e012d
commit 892cdf324f
8 changed files with 114 additions and 0 deletions

View File

@ -2,6 +2,9 @@
namespace Incoviba\Service\Venta\MediosPago\Toku;
use Psr\Http\Client\ClientInterface;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
@ -41,6 +44,26 @@ class Customer extends AbstractEndPoint
$request_uri = "/customer/{$id}";
$this->sendDelete($request_uri, [204], [404, 409]);
}
public function reset(array $skip = []): array
{
try {
$customers = $this->customerRepository->fetchAll();
$customers = array_filter($customers, function (Model\Venta\MediosPago\Toku\Customer $customer) use ($skip) {
return !in_array($customer->toku_id, $skip);
});
} catch (EmptyResult $exception) {
$this->logger->warning($exception);
return [];
}
foreach ($customers as $customer) {
try {
$this->delete($customer->toku_id);
} catch (EmptyResponse $exception) {
$this->logger->warning($exception, ['customer' => $customer]);
}
}
return $customers;
}
public function save(array $data): bool
{