ilknur-dogan / exchange-rate
Exchange rate transformation package
v1.0.1
2024-08-08 10:02 UTC
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.9
- illuminate/support: ^11.0
README
This library is designed to fetch exchange rates from the Central Bank of the Republic of Turkey (TCMB) and perform currency conversions for specific dates.
Installation
You can install this library using Composer.
composer require ilknur-dogan/exchange-rate
Usage
1. Fetching Exchange Rates
You can use the getRate method to retrieve exchange rates for a specific date.
getRate($date)
- Returns exchange rates for the specified date as an array.
- $date: The date for which exchange rates are to be retrieved (in YYYY-MM-DD format).
require 'vendor/autoload.php'; use IlknurDogan\ExchangeRate\ExchangeRate; $exchangeRate = new ExchangeRate(); $rates = $exchangeRate->getRate('2024-08-01'); // Example date print_r($rates);
2. Currency Conversion
You can use the convert method to perform a currency conversion between two currencies for a specific date.
convert($date, $from, $to)
- Returns the conversion rate between the two currencies for the specified date (as a string).
- $date: The date for which the exchange rate is to be used (in YYYY-MM-DD format).
- $from: The currency to be converted from (e.g., USD).
- $to: The currency to be converted to (e.g., EUR).
require 'vendor/autoload.php'; use IlknurDogan\ExchangeRate\ExchangeRate; $exchangeRate = new ExchangeRate(); $convertedAmount = $exchangeRate->convert('2024-08-01', 'USD', 'EUR'); // Example date and currencies echo $convertedAmount;
License
This package is open source software licensed under the MIT License.