32 lines
1017 B
PHP
32 lines
1017 B
PHP
<?php
|
|
namespace Incoviba\Command\Money;
|
|
|
|
use DateTimeImmutable;
|
|
use DateTimeZone;
|
|
use Symfony\Component\Console;
|
|
use Incoviba\Common\Alias\Command;
|
|
|
|
#[Console\Attribute\AsCommand(
|
|
name: 'money:uf',
|
|
description: 'Get the UF value for today'
|
|
)]
|
|
class UF extends Command
|
|
{
|
|
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
|
|
{
|
|
$this->logger->debug("Running {$this->getName()}");
|
|
$now = new DateTimeImmutable('now', new DateTimeZone($_ENV['TZ'] ?? 'America/Santiago'));
|
|
$uri = '/api/money/uf';
|
|
$data = [
|
|
'fecha' => $now->format('Y-m-d')
|
|
];
|
|
$output->writeln("POST {$uri}");
|
|
$response = $this->client->post($uri, [
|
|
'body' => http_build_query($data),
|
|
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded']
|
|
]);
|
|
$output->writeln("Response Code: {$response->getStatusCode()}");
|
|
return Console\Command\Command::SUCCESS;
|
|
}
|
|
}
|