A simple Laravel package used for interacting with the Bank of Russia and National Bank of Ukraine API. 'Larate' allow you to get the latest or historical converted monetary values between RUB (UAH) and other currencies.
You can install the package via composer:
composer require dostrog/larate
You can publish the config file with:
php artisan vendor:publish --provider="Dostrog\Larate\Providers\LarateServiceProvider" --tag="config"
This is the contents of the published config file:
return [
'default_base_currency' => 'RUB',
'service' => [
'RUB' => Dostrog\Larate\Services\RussianCentralBank::class,
'UAH' => Dostrog\Larate\Services\NationalBankOfUkraine::class,
],
];
// instantiate from Laravel IoC for inject provider
// according to config it maybe RUB (converted) rates from Central Bank OF Russia
$provider = app()->make(Larate::class);
$pair = new CurrencyPair('RUB', 'USD');
$date = Carbon::parse('2020-01-16');
$rate = $provider->getExchangeRate($pair, $date);
$value = $rate->getValue(); // 61.4328
// ...or using factory method, i.e. for getting UAH (converted) rates from National Bank of Ukraine
$provider = Larate::createForBaseCurrency('UAH');
$pair = new CurrencyPair('UAH', 'USD');
$date = Carbon::parse('2020-01-16');
$rate = $provider->getExchangeRate($pair, $date);
$value = $rate->getValue(); // 23.9821
// ...or using Laravel's Facades
$rate = LarateFacade::getExchangeRate($pair, $date);
$value = $rate->getValue();
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.