Comando para resetear Toku
This commit is contained in:
@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user