Opcion de enviar update a los servicios externos
This commit is contained in:
@ -11,5 +11,6 @@ $app->group('/external', function($app) {
|
||||
}
|
||||
$app->group('/services', function($app) {
|
||||
$app->get('/check[/]', [External::class, 'check']);
|
||||
$app->get('/update[/]', [External::class, 'update']);
|
||||
});
|
||||
});
|
||||
|
@ -17,4 +17,11 @@ class External extends Ideal\Controller
|
||||
}
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
public function update(ServerRequestInterface $request, ResponseInterface $response, Service\External $externalService): ResponseInterface
|
||||
{
|
||||
if ($externalService->check(true)) {
|
||||
return $response->withStatus(204);
|
||||
}
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class External extends Ideal\Service
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function check(): bool
|
||||
public function check(bool $update = false): bool
|
||||
{
|
||||
$errors = [];
|
||||
foreach ($this->externalServices as $externalService) {
|
||||
@ -36,6 +36,9 @@ class External extends Ideal\Service
|
||||
'service' => get_class($externalService),
|
||||
'action' => 'check',
|
||||
];
|
||||
if ($update) {
|
||||
$queueData['args'] = ['update' => true];
|
||||
}
|
||||
if (!$this->queueService->enqueue($queueData)) {
|
||||
$errors []= get_class($externalService);
|
||||
}
|
||||
|
@ -214,7 +214,9 @@ class Toku extends Ideal\Service
|
||||
'telefono' => $propietario->datos?->telefono ?? ''
|
||||
];
|
||||
$this->customer->edit($customer['toku_id'], $editData);
|
||||
} catch (EmptyResponse) {}
|
||||
} catch (EmptyResponse $exception) {
|
||||
$this->logger->warning($exception);
|
||||
}
|
||||
foreach ($cuotas as $cuota) {
|
||||
try {
|
||||
$invoice = $this->invoice->getById($cuota->id);
|
||||
@ -222,7 +224,8 @@ class Toku extends Ideal\Service
|
||||
'customer' => $customer['toku_id'],
|
||||
'product_id' => $subscription->venta->id,
|
||||
'subscription' => $subscription->toku_id,
|
||||
'cuota' => $cuota
|
||||
'cuota' => $cuota,
|
||||
'venta' => $subscription->venta
|
||||
];
|
||||
try {
|
||||
$this->invoice->edit($invoice['toku_id'], $editData);
|
||||
@ -232,7 +235,8 @@ class Toku extends Ideal\Service
|
||||
'customer' => $customer['toku_id'],
|
||||
'product_id' => $subscription->venta->id,
|
||||
'subscription' => $subscription->toku_id,
|
||||
'cuota' => $cuota
|
||||
'cuota' => $cuota,
|
||||
'venta' => $subscription->venta
|
||||
];
|
||||
try {
|
||||
$this->invoice->add($invoiceData);
|
||||
|
@ -17,7 +17,8 @@ class Invoice extends AbstractEndPoint
|
||||
{
|
||||
public function __construct(ClientInterface $client,
|
||||
protected Repository\Venta\MediosPago\Toku\Invoice $invoiceRepository,
|
||||
protected Pago $pagoService, protected UF $ufService)
|
||||
protected Pago $pagoService,
|
||||
protected UF $ufService)
|
||||
{
|
||||
parent::__construct($client);
|
||||
}
|
||||
|
@ -59,6 +59,9 @@ class Subscription extends AbstractEndPoint
|
||||
$existingSubscriptions = [];
|
||||
try {
|
||||
$existingSubscriptions = $this->subscriptionRepsitory->fetchByVentas($ids);
|
||||
array_walk($existingSubscriptions, function(&$subscription) {
|
||||
$subscription->venta = $this->ventaService->getById($subscription->venta->id);
|
||||
});
|
||||
} catch (EmptyResult) {}
|
||||
if (count($existingSubscriptions) === 0) {
|
||||
$missingVentas = $ventas;
|
||||
|
@ -37,7 +37,12 @@ class CheckExternal extends Ideal\Service implements Service\Worker
|
||||
if (!isset($this->queueService)) {
|
||||
$this->queueService = $this->container->get(Service\Queue::class);
|
||||
}
|
||||
$queues = $service->{$method}();
|
||||
if (isset($configuration['args'])) {
|
||||
$args = $configuration['args'];
|
||||
$queues = call_user_func_array([$service, $method], $args);
|
||||
} else {
|
||||
$queues = call_user_func([$service, $method]);
|
||||
}
|
||||
foreach ($queues as $queue) {
|
||||
$this->queueService->enqueue($queue);
|
||||
}
|
||||
|
Reference in New Issue
Block a user