From c8f79e076eba6ec1a53c0819ac84a2c34f7e4398 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 15 May 2025 16:05:55 -0400 Subject: [PATCH] Envio de datos editados de Propietario --- app/src/Controller/API/Ventas.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/Controller/API/Ventas.php b/app/src/Controller/API/Ventas.php index f18733b..ba2200d 100644 --- a/app/src/Controller/API/Ventas.php +++ b/app/src/Controller/API/Ventas.php @@ -7,8 +7,10 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Incoviba\Common\Ideal\Controller; use Incoviba\Common\Implement\Exception\EmptyRedis; +use Incoviba\Common\Implement\Exception\EmptyResponse; use Incoviba\Common\Implement\Exception\EmptyResult; use Incoviba\Controller\withRedis; +use Incoviba\Exception\InvalidResult; use Incoviba\Exception\ServiceAction\Read; use Incoviba\Exception\ServiceAction\Create; use Incoviba\Exception\ServiceAction\Update; @@ -306,6 +308,7 @@ class Ventas extends Controller return $this->withJson($response, $output); } public function propietario(ServerRequestInterface $request, ResponseInterface $response, + Service\Venta\MediosPago\Toku\Customer $customerService, Service\Venta\Propietario $propietarioService, Repository\Venta $ventaRepository, int $venta_id): ResponseInterface { @@ -335,6 +338,18 @@ class Ventas extends Controller } else { $propietario = $propietarioService->edit($propietario, $data); } + try { + $customer = $customerService->getById($propietario->rut); + $customerData = [ + 'rut' => $customer['rut'], + 'nombreCompleto' => $propietario->nombreCompleto(), + 'email' => $propietario->datos?->email ?? '', + 'telefono' => $propietario->datos?->telefono ?? '' + ]; + $customerService->edit($customer['toku_id'], $customerData); + } catch (InvalidResult|EmptyResponse $exception) { + $this->logger->warning($exception); + } $output['edited'] = true; } catch (EmptyResult|Read|Create|Update) {} return $this->withJson($response, $output);