Reorden Toku

This commit is contained in:
Juan Pablo Vial
2025-05-10 12:38:14 -04:00
parent 1486d6cf38
commit fb7177fd65
24 changed files with 213 additions and 215 deletions

View File

@ -4,7 +4,6 @@ namespace Incoviba\Controller\API\Ventas\MediosPago;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Controller\API\withJson;
use Incoviba\Exception\InvalidResult;
@ -15,8 +14,8 @@ class Toku extends Controller
{
use withJson;
public function cuotas(ServerRequestInterface $request, ResponseInterface $response,
Service\MediosPago\Toku $tokuService, Service\Venta $ventaService, int $venta_id): ResponseInterface
public function cuotas(ServerRequestInterface $request, ResponseInterface $response,
Service\Venta\MediosPago\Toku $tokuService, Service\Venta $ventaService, int $venta_id): ResponseInterface
{
$input = $request->getParsedBody();
$output = [
@ -38,9 +37,9 @@ class Toku extends Controller
} catch (Read | InvalidResult) {}
return $this->withJson($response, $output);
}
public function success(ServerRequestInterface $request, ResponseInterface $response,
ResponseFactoryInterface $responseFactory,
Service\MediosPago\Toku $tokuService): ResponseInterface
public function success(ServerRequestInterface $request, ResponseInterface $response,
ResponseFactoryInterface $responseFactory,
Service\Venta\MediosPago\Toku $tokuService): ResponseInterface
{
$body = $request->getBody();
$input = json_decode($body->getContents(), true);

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Model\MediosPago\Toku;
namespace Incoviba\Model\Venta\MediosPago\Toku;
use Incoviba\Common\Ideal;
use Incoviba\Model\Persona;

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Model\MediosPago\Toku;
namespace Incoviba\Model\Venta\MediosPago\Toku;
use Incoviba\Common\Ideal;
use Incoviba\Model\Venta\Cuota;

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Model\MediosPago\Toku;
namespace Incoviba\Model\Venta\MediosPago\Toku;
use Incoviba\Common\Ideal;
use Incoviba\Model\Venta;

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Repository\MediosPago\Toku;
namespace Incoviba\Repository\Venta\MediosPago\Toku;
use DateTimeImmutable;
use Incoviba\Common\Define;
@ -20,7 +20,7 @@ class Customer extends Ideal\Repository
return 'teku_customers';
}
public function create(?array $data = null): Model\MediosPago\Toku\Customer
public function create(?array $data = null): Model\Venta\MediosPago\Toku\Customer
{
$map = (new Implement\Repository\MapperParser(['toku_id']))
->register('rut', (new Implement\Repository\Mapper())
@ -30,9 +30,9 @@ class Customer extends Ideal\Repository
return $this->personaService->getById($rut);
})
);
return $this->parseData(new Model\MediosPago\Toku\Customer(), $data, $map);
return $this->parseData(new Model\Venta\MediosPago\Toku\Customer(), $data, $map);
}
public function save(Define\Model $model): Model\MediosPago\Toku\Customer
public function save(Define\Model $model): Model\Venta\MediosPago\Toku\Customer
{
$model->id = $this->saveNew(
['rut', 'toku_id', 'created_at'],
@ -40,17 +40,17 @@ class Customer extends Ideal\Repository
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Model\MediosPago\Toku\Customer
public function edit(Define\Model $model, array $new_data): Model\Venta\MediosPago\Toku\Customer
{
return $this->update($model, ['rut', 'toku_id', 'updated_at'], array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]));
}
/**
* @param string $rut
* @return Model\MediosPago\Toku\Customer
* @return \Incoviba\Model\Venta\MediosPago\Toku\Customer
* @throws Implement\Exception\EmptyResult
*/
public function fetchByRut(string $rut): Model\MediosPago\Toku\Customer
public function fetchByRut(string $rut): Model\Venta\MediosPago\Toku\Customer
{
if (str_contains($rut, '-')) {
$rut = str_replace('-', '', $rut);
@ -68,10 +68,10 @@ class Customer extends Ideal\Repository
/**
* @param string $toku_id
* @return Model\MediosPago\Toku\Customer
* @return \Incoviba\Model\Venta\MediosPago\Toku\Customer
* @throws Implement\Exception\EmptyResult
*/
public function fetchByTokuId(string $toku_id): Model\MediosPago\Toku\Customer
public function fetchByTokuId(string $toku_id): Model\Venta\MediosPago\Toku\Customer
{
$query = $this->connection->getQueryBuilder()
->select()

View File

@ -1,12 +1,12 @@
<?php
namespace Incoviba\Repository\MediosPago\Toku;
namespace Incoviba\Repository\Venta\MediosPago\Toku;
use DateTimeImmutable;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Repository;
use Incoviba\Model;
use Incoviba\Repository;
class Invoice extends Ideal\Repository
{
@ -19,7 +19,7 @@ class Invoice extends Ideal\Repository
{
return 'toku_invoices';
}
public function create(?array $data = null): Model\MediosPago\Toku\Invoice
public function create(?array $data = null): Model\Venta\MediosPago\Toku\Invoice
{
$map = (new Implement\Repository\MapperParser(['toku_id']))
->register('cuota_id', (new Implement\Repository\Mapper())
@ -27,9 +27,9 @@ class Invoice extends Ideal\Repository
->setFunction(function($data) {
return $this->cuotaRepository->fetchById($data['cuota_id']);
}));
return $this->parseData(new Model\MediosPago\Toku\Invoice(), $data, $map);
return $this->parseData(new Model\Venta\MediosPago\Toku\Invoice(), $data, $map);
}
public function save(Define\Model $model): Model\MediosPago\Toku\Invoice
public function save(Define\Model $model): Model\Venta\MediosPago\Toku\Invoice
{
$model->id = $this->saveNew(
['cuota_id', 'toku_id', 'created_at'],
@ -37,17 +37,17 @@ class Invoice extends Ideal\Repository
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Model\MediosPago\Toku\Invoice
public function edit(Define\Model $model, array $new_data): Model\Venta\MediosPago\Toku\Invoice
{
return $this->update($model, ['cuota_id', 'toku_id', 'updated_at'], array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]));
}
/**
* @param int $cuota_id
* @return Model\MediosPago\Toku\Invoice
* @return \Incoviba\Model\Venta\MediosPago\Toku\Invoice
* @throws Implement\Exception\EmptyResult
*/
public function fetchByCuota(int $cuota_id): Model\MediosPago\Toku\Invoice
public function fetchByCuota(int $cuota_id): Model\Venta\MediosPago\Toku\Invoice
{
$query = $this->connection->getQueryBuilder()
->select()
@ -58,10 +58,10 @@ class Invoice extends Ideal\Repository
/**
* @param string $toku_id
* @return Model\MediosPago\Toku\Invoice
* @return \Incoviba\Model\Venta\MediosPago\Toku\Invoice
* @throws Implement\Exception\EmptyResult
*/
public function fetchByTokuId(string $toku_id): Model\MediosPago\Toku\Invoice
public function fetchByTokuId(string $toku_id): Model\Venta\MediosPago\Toku\Invoice
{
$query = $this->connection->getQueryBuilder()
->select()

View File

@ -1,9 +1,9 @@
<?php
namespace Incoviba\Repository\MediosPago\Toku;
namespace Incoviba\Repository\Venta\MediosPago\Toku;
use DateTimeImmutable;
use Incoviba\Common\Ideal;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Repository;
@ -20,7 +20,7 @@ class Subscription extends Ideal\Repository
return 'toku_subscriptions';
}
public function create(?array $data = null): Model\MediosPago\Toku\Subscription
public function create(?array $data = null): Model\Venta\MediosPago\Toku\Subscription
{
$map = (new Implement\Repository\MapperParser(['toku_id']))
->register('venta_id', (new Implement\Repository\Mapper())
@ -28,9 +28,9 @@ class Subscription extends Ideal\Repository
->setFunction(function($data) {
return $this->ventaRepository->fetchById($data['venta_id']);
}));
return $this->parseData(new Model\MediosPago\Toku\Subscription(), $data, $map);
return $this->parseData(new Model\Venta\MediosPago\Toku\Subscription(), $data, $map);
}
public function save(Define\Model $model): Model\MediosPago\Toku\Subscription
public function save(Define\Model $model): Model\Venta\MediosPago\Toku\Subscription
{
$model->id = $this->saveNew(
['venta_id', 'toku_id', 'created_at'],
@ -38,12 +38,12 @@ class Subscription extends Ideal\Repository
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Model\MediosPago\Toku\Subscription
public function edit(Define\Model $model, array $new_data): Model\Venta\MediosPago\Toku\Subscription
{
return $this->update($model, ['venta_id', 'toku_id', 'updated_at'], array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]));
}
public function fetchByVenta(int $venta_id): Model\MediosPago\Toku\Subscription
public function fetchByVenta(int $venta_id): Model\Venta\MediosPago\Toku\Subscription
{
$query = $this->connection->getQueryBuilder()
->select()
@ -51,7 +51,7 @@ class Subscription extends Ideal\Repository
->where('venta_id = :venta_id');
return $this->fetchOne($query, compact('venta_id'));
}
public function fetchByTokuId(string $toku_id): Model\MediosPago\Toku\Subscription
public function fetchByTokuId(string $toku_id): Model\Venta\MediosPago\Toku\Subscription
{
$query = $this->connection->getQueryBuilder()
->select()

View File

@ -1,15 +1,15 @@
<?php
namespace Incoviba\Service\MediosPago;
namespace Incoviba\Service\Venta\MediosPago;
use HttpException;
use Incoviba\Common\Define\Repository;
use Incoviba\Common\Ideal\LoggerEnabled;
use Incoviba\Common\Implement\Exception\{EmptyResponse, EmptyResult};
use Incoviba\Exception\InvalidResult;
use PDOException;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ResponseInterface;
use Incoviba\Common\Define\Repository;
use Incoviba\Common\Implement\Exception\{EmptyResponse, EmptyResult};
use Incoviba\Common\Ideal\LoggerEnabled;
use Incoviba\Exception\InvalidResult;
abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint
{

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Service\MediosPago;
namespace Incoviba\Service\Venta\MediosPago;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Exception\InvalidResult;

View File

@ -1,14 +1,14 @@
<?php
namespace Incoviba\Service\MediosPago;
namespace Incoviba\Service\Venta\MediosPago;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Exception\InvalidResult;
use Incoviba\Model;
use Incoviba\Model\Persona;
use Incoviba\Model\Venta\Propietario;
use Incoviba\Model;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
class Toku extends Ideal\Service
{

View File

@ -1,14 +1,14 @@
<?php
namespace Incoviba\Service\MediosPago\Toku;
namespace Incoviba\Service\Venta\MediosPago\Toku;
use Psr\Http\Client\ClientInterface;
use Incoviba\Repository;
use Incoviba\Service\MediosPago\AbstractEndPoint;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Psr\Http\Client\ClientInterface;
class Customer extends AbstractEndPoint
{
public function __construct(ClientInterface $client,
protected Repository\MediosPago\Toku\Customer $customerRepository)
public function __construct(ClientInterface $client,
protected Repository\Venta\MediosPago\Toku\Customer $customerRepository)
{
parent::__construct($client);
}

View File

@ -1,22 +1,22 @@
<?php
namespace Incoviba\Service\MediosPago\Toku;
namespace Incoviba\Service\Venta\MediosPago\Toku;
use DateTimeImmutable;
use DateMalformedStringException;
use Psr\Http\Client\ClientInterface;
use Incoviba\Exception\InvalidResult;
use DateTimeImmutable;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Exception\InvalidResult;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service\MediosPago\AbstractEndPoint;
use Incoviba\Service\UF;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Incoviba\Service\Venta\Pago;
use Psr\Http\Client\ClientInterface;
class Invoice extends AbstractEndPoint
{
public function __construct(ClientInterface $client,
protected Repository\MediosPago\Toku\Invoice $invoiceRepository,
protected Pago $pagoService, protected UF $ufService)
public function __construct(ClientInterface $client,
protected Repository\Venta\MediosPago\Toku\Invoice $invoiceRepository,
protected Pago $pagoService, protected UF $ufService)
{
parent::__construct($client);
}

View File

@ -1,14 +1,14 @@
<?php
namespace Incoviba\Service\MediosPago\Toku;
namespace Incoviba\Service\Venta\MediosPago\Toku;
use Psr\Http\Client\ClientInterface;
use Incoviba\Model\Venta;
use Incoviba\Repository;
use Incoviba\Service\MediosPago\AbstractEndPoint;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Psr\Http\Client\ClientInterface;
class Subscription extends AbstractEndPoint
{
public function __construct(ClientInterface $client, protected Repository\MediosPago\Toku\Subscription $subscriptionRepsitory)
public function __construct(ClientInterface $client, protected Repository\Venta\MediosPago\Toku\Subscription $subscriptionRepsitory)
{
parent::__construct($client);
}