Added new Money provider

This commit is contained in:
Juan Pablo Vial
2025-10-24 18:35:52 -03:00
parent 6e32b1debc
commit 04a725e517
8 changed files with 178 additions and 31 deletions

View File

@ -8,9 +8,10 @@ use DateInterval;
use Psr\Http\Client\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Common\Define\Money\Provider;
use Incoviba\Common\Ideal;
use Incoviba\Service\Money;
class Ine implements Provider
class Ine extends Ideal\Money\Provider
{
protected string $uri = 'https://api-calculadora.ine.cl/ServiciosCalculadoraVariacion';
public function __construct(protected ClientInterface $client) {}
@ -21,6 +22,9 @@ class Ine implements Provider
*/
public function get(string $money_symbol, ?DateTimeInterface $dateTime = null): float
{
if (!$this->supported($money_symbol)) {
throw new EmptyResponse($money_symbol);
}
if ($dateTime === null) {
$dateTime = new DateTimeImmutable();
}
@ -29,6 +33,10 @@ class Ine implements Provider
return $this->getVar($start, $end);
}
protected array $supportedMap = [
Money::IPC => 'ipc'
];
/**
* @throws EmptyResponse
*/