Comando para resetear Toku
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
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\Exception\ServiceAction\Read;
|
||||
use Incoviba\Model\Venta;
|
||||
@ -47,6 +48,26 @@ class Subscription extends AbstractEndPoint
|
||||
$request_uri = "/subscriptions/{$id}";
|
||||
$this->sendDelete($request_uri, [204], [404, 409]);
|
||||
}
|
||||
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);
|
||||
});
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->warning($exception);
|
||||
return [];
|
||||
}
|
||||
foreach ($subscriptions as $subscription) {
|
||||
try {
|
||||
$this->delete($subscription->toku_id);
|
||||
} catch (EmptyResponse $exception) {
|
||||
$this->logger->warning($exception, ['subscription' => $subscription]);
|
||||
}
|
||||
}
|
||||
return $subscriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
Reference in New Issue
Block a user