Mas logging
This commit is contained in:
@ -140,6 +140,7 @@ abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint
|
||||
*/
|
||||
protected function sendDelete(string $request_uri, array $validStatus, array $invalidStatus): void
|
||||
{
|
||||
$this->logger->info('Send Delete', ['uri' => $request_uri]);
|
||||
try {
|
||||
$response = $this->client->delete($request_uri);
|
||||
} catch (ClientExceptionInterface $exception) {
|
||||
@ -147,6 +148,7 @@ abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint
|
||||
}
|
||||
|
||||
$this->validateResponse($response, $request_uri, $validStatus, $invalidStatus);
|
||||
$this->logger->info('Delete Response', ['request_uri' => $request_uri]);
|
||||
}
|
||||
protected function doSave(Repository $repository, array $data): bool
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -55,23 +55,23 @@ class Invoice extends AbstractEndPoint
|
||||
public function reset(array $skip = []): array
|
||||
{
|
||||
try {
|
||||
$invoices = $this->invoiceRepository->fetchAll();
|
||||
$invoices = array_filter($invoices, function (Model\Venta\MediosPago\Toku\Invoice $invoice) use ($skip) {
|
||||
return !in_array($invoice->toku_id, $skip);
|
||||
$tokuIds = $this->invoiceRepository->fetchAllTokuIds();
|
||||
$tokuIds = array_filter($tokuIds, function (string $tokuId) use ($skip) {
|
||||
return !in_array($tokuId, $skip);
|
||||
});
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->warning($exception);
|
||||
return [];
|
||||
}
|
||||
foreach ($invoices as $invoice) {
|
||||
foreach ($tokuIds as $tokuId) {
|
||||
try {
|
||||
$this->delete($invoice->toku_id);
|
||||
$this->invoiceRepository->remove($invoice);
|
||||
$this->delete($tokuId);
|
||||
$this->invoiceRepository->removeByTokuId($tokuId);
|
||||
} catch (EmptyResponse $exception) {
|
||||
$this->logger->warning($exception, ['invoice' => $invoice]);
|
||||
$this->logger->warning($exception, ['invoice->toku_id' => $tokuId]);
|
||||
}
|
||||
}
|
||||
return $invoices;
|
||||
return $tokuIds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,23 +51,23 @@ class Subscription extends AbstractEndPoint
|
||||
public function reset(array $skip = []): array
|
||||
{
|
||||
try {
|
||||
$subscriptions = $this->subscriptionRepsitory->fetchAll();
|
||||
$subscriptions = array_filter($subscriptions, function (Venta\MediosPago\Toku\Subscription $subscription) use ($skip) {
|
||||
return !in_array($subscription->toku_id, $skip);
|
||||
$tokuIds = $this->subscriptionRepsitory->fetchAllTokuIds();
|
||||
$tokuIds = array_filter($tokuIds, function (string $tokuId) use ($skip) {
|
||||
return !in_array($tokuId, $skip);
|
||||
});
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->warning($exception);
|
||||
return [];
|
||||
}
|
||||
foreach ($subscriptions as $subscription) {
|
||||
foreach ($tokuIds as $tokuId) {
|
||||
try {
|
||||
$this->delete($subscription->toku_id);
|
||||
$this->subscriptionRepsitory->remove($subscription);
|
||||
$this->delete($tokuId);
|
||||
$this->subscriptionRepsitory->removeByTokuId($tokuId);
|
||||
} catch (EmptyResponse $exception) {
|
||||
$this->logger->warning($exception, ['subscription' => $subscription]);
|
||||
$this->logger->warning($exception, ['subscription->toku_id' => $tokuId]);
|
||||
}
|
||||
}
|
||||
return $subscriptions;
|
||||
return $tokuIds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user