Comando para resetear Toku
This commit is contained in:
@ -51,6 +51,26 @@ class Invoice extends AbstractEndPoint
|
||||
$request_uri = "/invoices/{$id}";
|
||||
$this->sendDelete($request_uri, [204], [404, 409]);
|
||||
}
|
||||
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);
|
||||
});
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->warning($exception);
|
||||
return [];
|
||||
}
|
||||
foreach ($invoices as $invoice) {
|
||||
try {
|
||||
$this->delete($invoice->toku_id);
|
||||
} catch (EmptyResponse $exception) {
|
||||
$this->logger->warning($exception, ['invoice' => $invoice]);
|
||||
}
|
||||
}
|
||||
return $invoices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $customer_id
|
||||
|
Reference in New Issue
Block a user