Mas logging

This commit is contained in:
Juan Pablo Vial
2025-06-09 12:44:42 -04:00
parent f1ed9668fc
commit abb1ce7299
8 changed files with 140 additions and 30 deletions

View File

@ -1,10 +1,10 @@
<?php
namespace Incoviba\Service\Venta\MediosPago\Toku;
use PDOException;
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;
@ -47,24 +47,24 @@ class Customer extends AbstractEndPoint
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);
$tokuIds = $this->customerRepository->fetchAllTokuIds();
$tokuIds = array_filter($tokuIds, function (string $tokuId) use ($skip) {
return !in_array($tokuId, $skip);
});
} catch (EmptyResult $exception) {
$this->logger->warning($exception);
return [];
}
$this->logger->info('Resetando ' . count($customers) . ' clientes');
foreach ($customers as $customer) {
$this->logger->info('Resetando ' . count($tokuIds) . ' clientes');
foreach ($tokuIds as $tokuId) {
try {
$this->delete($customer->toku_id);
$this->customerRepository->remove($customer);
} catch (EmptyResponse $exception) {
$this->logger->warning($exception, ['customer' => $customer]);
$this->delete($tokuId);
$this->customerRepository->removeByTokuId($tokuId);
} catch (EmptyResponse | PDOException $exception) {
$this->logger->warning($exception, ['customer->toku_id' => $tokuId]);
}
}
return $customers;
return $tokuIds;
}
public function save(array $data): bool