Log commands

This commit is contained in:
2023-11-25 21:38:00 -03:00
parent ec4b16b2af
commit df679b2a1a
9 changed files with 39 additions and 57 deletions

View File

@ -0,0 +1,14 @@
<?php
namespace Incoviba\Common\Alias;
use Psr\Http\Client\ClientInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console;
class Command extends Console\Command\Command
{
public function __construct(protected ClientInterface $client, protected LoggerInterface $logger, string $name = null)
{
parent::__construct($name);
}
}

View File

@ -1,21 +1,17 @@
<?php <?php
namespace Incoviba\Command; namespace Incoviba\Command;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'comunas' name: 'comunas'
)] )]
class Comunas extends Console\Command\Command class Comunas extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$uri = '/api/direcciones/region/13/comunas'; $uri = '/api/direcciones/region/13/comunas';
$output->writeln("GET {$uri}"); $output->writeln("GET {$uri}");
$response = $this->client->get($uri); $response = $this->client->get($uri);

View File

@ -3,21 +3,17 @@ namespace Incoviba\Command\Money;
use DateTimeImmutable; use DateTimeImmutable;
use DateInterval; use DateInterval;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'money:ipc' name: 'money:ipc'
)] )]
class IPC extends Console\Command\Command class IPC extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$lastMonth = (new DateTimeImmutable())->sub(new DateInterval('P1M')); $lastMonth = (new DateTimeImmutable())->sub(new DateInterval('P1M'));
$uri = '/api/money'; $uri = '/api/money';
$data = [ $data = [

View File

@ -2,21 +2,17 @@
namespace Incoviba\Command\Money; namespace Incoviba\Command\Money;
use DateTimeImmutable; use DateTimeImmutable;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'money:uf' name: 'money:uf'
)] )]
class UF extends Console\Command\Command class UF extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$now = new DateTimeImmutable(); $now = new DateTimeImmutable();
$uri = '/api/money'; $uri = '/api/money';
$data = [ $data = [

View File

@ -1,21 +1,17 @@
<?php <?php
namespace Incoviba\Command\Proyectos; namespace Incoviba\Command\Proyectos;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'proyectos:activos' name: 'proyectos:activos'
)] )]
class Activos extends Console\Command\Command class Activos extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$uri = '/api/proyectos'; $uri = '/api/proyectos';
$output->writeln("GET {$uri}"); $output->writeln("GET {$uri}");
$response = $this->client->get($uri); $response = $this->client->get($uri);

View File

@ -1,21 +1,17 @@
<?php <?php
namespace Incoviba\Command\Ventas\Cierres; namespace Incoviba\Command\Ventas\Cierres;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'ventas:cierres:vigentes' name: 'ventas:cierres:vigentes'
)] )]
class Vigentes extends Console\Command\Command class Vigentes extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$uri = '/api/ventas/cierres/vigentes'; $uri = '/api/ventas/cierres/vigentes';
$output->writeln("GET {$uri}"); $output->writeln("GET {$uri}");
$response = $this->client->get($uri); $response = $this->client->get($uri);

View File

@ -1,21 +1,17 @@
<?php <?php
namespace Incoviba\Command\Ventas\Cuotas; namespace Incoviba\Command\Ventas\Cuotas;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'ventas:cuotas:hoy' name: 'ventas:cuotas:hoy'
)] )]
class Hoy extends Console\Command\Command class Hoy extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$uri = '/api/ventas/cuotas/hoy'; $uri = '/api/ventas/cuotas/hoy';
$output->writeln("GET {$uri}"); $output->writeln("GET {$uri}");
$response = $this->client->get($uri); $response = $this->client->get($uri);

View File

@ -1,21 +1,17 @@
<?php <?php
namespace Incoviba\Command\Ventas\Cuotas; namespace Incoviba\Command\Ventas\Cuotas;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'ventas:cuotas:pendientes' name: 'ventas:cuotas:pendientes'
)] )]
class Pendientes extends Console\Command\Command class Pendientes extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$uri = '/api/ventas/cuotas/pendientes'; $uri = '/api/ventas/cuotas/pendientes';
$output->writeln("GET {$uri}"); $output->writeln("GET {$uri}");
$response = $this->client->get($uri); $response = $this->client->get($uri);

View File

@ -1,21 +1,17 @@
<?php <?php
namespace Incoviba\Command\Ventas\Cuotas; namespace Incoviba\Command\Ventas\Cuotas;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console; use Symfony\Component\Console;
use Incoviba\Common\Alias\Command;
#[Console\Attribute\AsCommand( #[Console\Attribute\AsCommand(
name: 'ventas:cuotas:vencer' name: 'ventas:cuotas:vencer'
)] )]
class PorVencer extends Console\Command\Command class PorVencer extends Command
{ {
public function __construct(protected ClientInterface $client, string $name = null)
{
parent::__construct($name);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$this->logger->debug("Running {$this->getName()}");
$uri = '/api/ventas/cuotas/vencer'; $uri = '/api/ventas/cuotas/vencer';
$output->writeln("GET {$uri}"); $output->writeln("GET {$uri}");
$response = $this->client->get($uri); $response = $this->client->get($uri);