From 2c95d087885fef06ed2ed59692198b174939b3a9 Mon Sep 17 00:00:00 2001 From: Ivan Ganev Date: Tue, 13 Apr 2021 11:25:52 +0300 Subject: [PATCH] Updated README.md --- README.md | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index af5c0de..e0038a8 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,9 @@ use \BenMajor\ExchangeRatesAPI\ExchangeRatesAPI; use \BenMajor\ExchangeRatesAPI\Response; use \BenMajor\ExchangeRatesAPI\Exception; -$lookup = new ExchangeRatesAPI(); +$access_key = ''; + +$lookup = new ExchangeRatesAPI($access_key, false); $rates = $lookup->fetch(); ``` @@ -56,14 +58,18 @@ $rates = $lookup->fetch(); Get historical rates for any day since 1999: ``` -$lookup = new ExchangeRatesAPI(); +$access_key = ''; + +$lookup = new ExchangeRatesAPI($access_key); $rates = $lookup->setFetchDate('2015-01-20')->fetch(); ``` Get historical rates for a time period: ``` -$lookup = new ExchangeRatesAPI(); +$access_key = ''; + +$lookup = new ExchangeRatesAPI($access_key); $rates = $lookup->addDateFrom('2015-01-20')->addDateTo('2015-01-21')->fetch(); ``` @@ -71,7 +77,9 @@ $rates = $lookup->addDateFrom('2015-01-20')->addDateTo('2015-01-21')->fetch(); By default, the base currency is set to Euro (EUR), but it can be changed: ``` -$lookup = new ExchangeRatesAPI(); +$access_key = ''; + +$lookup = new ExchangeRatesAPI($access_key); $rates = $lookup->setBaseCurrency('GBP')->fetch(); ``` @@ -79,7 +87,9 @@ $rates = $lookup->setBaseCurrency('GBP')->fetch(); If you do not want all current rates, it's possible to specify only the currencies you want using `addRate()`. The following code fetches only the exchange rate between GBP and EUR: ``` -$lookup = new ExchangeRatesAPI(); +$access_key = ''; + +$lookup = new ExchangeRatesAPI($access_key); $rates = $lookup->addRate('EUR')->setBaseCurrency('GBP')->fetch(); ``` @@ -108,6 +118,12 @@ Set the end date for the retrieval of historic rates. `$to` should be a string c `getDateTo()`:
Returns the specified end date for the retrieval of historic rates. Returns `null` if none is specified. +`getAccessKey()`:
+Returns the `access_key` that is currently in use. + +`getUseSSL()`:
+Returns a boolean flag that determines which API URL will be used to perform requests. Free plans are restricted to non-SSL usage. + `removeDateTo()`:
Removes the specified end date for the retrieval of historic rates. @@ -139,6 +155,12 @@ Removes multiple currencies that has already been added to the retrieval list. Removes a currency that has already been added to the retrieval list. `$code` should be passed an ISO 4217 code (e.g. `EUR`).
`$code` must be one of the [supported currency codes](#5-supported-currencies). +`setAccessKey( string $access_key )`:
+Sets `access_key` to be used in all requests. + +`setUseSSL( bool $use_ssl )`:
+Sets the API URL according to the selected mode (SSL or non-SSL). Free plans are restricted to non-SSL usage. + `fetch( bool $returnJSON = false, bool $parseJSON = true )`:
Send off the request to the API and return either a `Response` object, or the raw JSON response. If `$returnJSON` is set to `true`, a standard PHP object will be returned, rather than the `ExchangeRatesAPI\Response` object.