Added new Money provider
This commit is contained in:
@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user