35 lines
1013 B
PHP
35 lines
1013 B
PHP
|
<?php
|
||
|
namespace Incoviba\Command\Money;
|
||
|
|
||
|
use DateTimeImmutable;
|
||
|
use Psr\Http\Client\ClientInterface;
|
||
|
use Symfony\Component\Console;
|
||
|
|
||
|
#[Console\Attribute\AsCommand(
|
||
|
name: 'money:uf'
|
||
|
)]
|
||
|
class UF extends Console\Command\Command
|
||
|
{
|
||
|
public function __construct(protected ClientInterface $client, string $name = null)
|
||
|
{
|
||
|
parent::__construct($name);
|
||
|
}
|
||
|
|
||
|
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||
|
{
|
||
|
$now = new DateTimeImmutable();
|
||
|
$uri = '/api/money';
|
||
|
$data = [
|
||
|
'provider' => 'uf',
|
||
|
'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;
|
||
|
}
|
||
|
}
|