From 2ad6367a4587164b3ffc88fc5f4f532af0ebb299 Mon Sep 17 00:00:00 2001 From: Dimitar Dinchev Date: Mon, 16 Apr 2018 19:20:14 +0300 Subject: [PATCH 1/3] Update swap towards latest exchanger version. --- README.md | 34 +++++++++++++++++----------------- composer.json | 2 +- src/Service/Registry.php | 6 +++--- tests/Service/RegistryTest.php | 8 ++++---- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index cd99296..667a00d 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ use Swap\Builder; // Build Swap with Fixer.io $swap = (new Builder()) - ->add('fixer') + ->add('fixer', ['access_key' => 'your-access-key']) ->build(); // Get the latest EUR/USD rate @@ -48,23 +48,23 @@ The complete documentation can be found [here](https://github.com/florianv/swap/ Here is the list of the currently implemented services. -| Service | Base Currency | Quote Currency | Historical | -|---------------------------------------------------------------------------|----------------------|----------------|----------------| -| [Fixer](http://fixer.io) | * | * | Yes | -| [European Central Bank](http://www.ecb.europa.eu/home/html/index.en.html) | EUR | * | Yes | -| [Google](http://www.google.com/finance) | * | * | No | +| Service | Registry Alias | Base Currency | Quote Currency | Historical | +|----------------------------------------------------------------|---------------|----------------------|----------------|----------------| +| [Fixer](http://fixer.io) | `fixer` | * | * | Yes | +| [European Central Bank](http://www.ecb.europa.eu/home/html/index.en.html) | `european_central_bank` | EUR | * | Yes | +| [Google](http://www.google.com/finance) | `google` | * | * | No | | [Open Exchange Rates](https://openexchangerates.org) | USD (free), * (paid) | * | Yes | -| [Xignite](https://www.xignite.com) | * | * | Yes | -| [WebserviceX](http://www.webservicex.net/ws/default.aspx) | * | * | No | -| [National Bank of Romania](http://www.bnr.ro) | RON | * | No | -| [Central Bank of the Republic of Turkey](http://www.tcmb.gov.tr) | * | TRY | No | -| [Central Bank of the Czech Republic](http://www.cnb.cz) | * | CZK | No | -| [Russian Central Bank](http://http://www.cbr.ru) | * | RUB | Yes | -| [currencylayer](https://currencylayer.com) | USD (free), * (paid) | * | Yes | -| [Cryptonator](https://www.cryptonator.com) | * Crypto (Limited standard currencies) | * Crypto (Limited standard currencies) | No | -| [1Forge](https://1forge.com) | * (free but limited or paid) | * (free but limited or paid) | No | -| [CurrencyDataFeed](https://currencydatafeed.com) | * (free but limited or paid) | * (free but limited or paid) | No | -| Array | * | * | Yes | +| [Xignite](https://www.xignite.com) | `xignite` | * | * | Yes | +| [WebserviceX](http://www.webservicex.net/ws/default.aspx) | `webservicex` | * | * | No | +| [National Bank of Romania](http://www.bnr.ro) | `national_bank_of_romania` | RON | * | No | +| [Central Bank of the Republic of Turkey](http://www.tcmb.gov.tr) | `central_bank_of_republic_turkey` | * | TRY | No | +| [Central Bank of the Czech Republic](http://www.cnb.cz) | `central_bank_of_czech_republic` | * | CZK | No | +| [Russian Central Bank](http://http://www.cbr.ru) | `russian_central_bank` | * | RUB | Yes | +| [currencylayer](https://currencylayer.com) | `currency_layer` | USD (free), * (paid) | * | Yes | +| [Cryptonator](https://www.cryptonator.com) | `cryptonator` | * Crypto (Limited standard currencies) | * Crypto (Limited standard currencies) | No | +| [1Forge](https://1forge.com) | `forge` | * (free but limited or paid) | * (free but limited or paid) | No | +| [CurrencyDataFeed](https://currencydatafeed.com) | `currency_data_feed` | * (free but limited or paid) | * (free but limited or paid) | No | +| Array | `array` | * | * | Yes | ## Integrations diff --git a/composer.json b/composer.json index e7bf0b6..db5211a 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "require": { "php": "^5.5 || ^7.0", - "florianv/exchanger": "^1.0" + "florianv/exchanger": "^1.1" }, "require-dev": { "phpunit/phpunit": "^4.8 || ^5.4", diff --git a/src/Service/Registry.php b/src/Service/Registry.php index b0ae168..bf036ef 100644 --- a/src/Service/Registry.php +++ b/src/Service/Registry.php @@ -93,22 +93,22 @@ public static function register($name, $classOrCallable) private function registerServices() { $services = [ + 'array' => PhpArray::class, 'central_bank_of_czech_republic' => CentralBankOfCzechRepublic::class, 'central_bank_of_republic_turkey' => CentralBankOfRepublicTurkey::class, 'currency_layer' => CurrencyLayer::class, 'currency_data_feed' => CurrencyDataFeed::class, + 'cryptonator' => Cryptonator::class, 'european_central_bank' => EuropeanCentralBank::class, 'fixer' => Fixer::class, 'forge' => Forge::class, 'google' => Google::class, 'national_bank_of_romania' => NationalBankOfRomania::class, 'open_exchange_rates' => OpenExchangeRates::class, - 'array' => PhpArray::class, + 'russian_central_bank' => RussianCentralBank::class, 'webservicex' => WebserviceX::class, 'xignite' => Xignite::class, 'yahoo' => Yahoo::class, - 'russian_central_bank' => RussianCentralBank::class, - 'cryptonator' => Cryptonator::class, ]; foreach ($services as $name => $class) { diff --git a/tests/Service/RegistryTest.php b/tests/Service/RegistryTest.php index f9a64cf..5c04213 100644 --- a/tests/Service/RegistryTest.php +++ b/tests/Service/RegistryTest.php @@ -23,10 +23,10 @@ use Exchanger\Service\NationalBankOfRomania; use Exchanger\Service\OpenExchangeRates; use Exchanger\Service\PhpArray; +use Exchanger\Service\RussianCentralBank; use Exchanger\Service\WebserviceX; use Exchanger\Service\Xignite; use Exchanger\Service\Yahoo; -use Exchanger\Service\RussianCentralBank; use Swap\Service\Registry; class RegistryTest extends \PHPUnit_Framework_TestCase @@ -45,8 +45,10 @@ public function testCoreServices($name, $class) public function serviceProviders() { return [ + ['array', PhpArray::class], ['central_bank_of_czech_republic', CentralBankOfCzechRepublic::class], ['central_bank_of_republic_turkey', CentralBankOfRepublicTurkey::class], + ['cryptonator', Cryptonator::class], ['currency_data_feed', CurrencyDataFeed::class], ['currency_layer', CurrencyLayer::class], ['european_central_bank', EuropeanCentralBank::class], @@ -55,12 +57,10 @@ public function serviceProviders() ['google', Google::class], ['national_bank_of_romania', NationalBankOfRomania::class], ['open_exchange_rates', OpenExchangeRates::class], - ['array', PhpArray::class], + ['russian_central_bank', RussianCentralBank::class], ['webservicex', WebserviceX::class], ['xignite', Xignite::class], ['yahoo', Yahoo::class], - ['russian_central_bank', RussianCentralBank::class], - ['cryptonator', Cryptonator::class], ]; } From 8f82438f41665dcf6c0876897163e0e5716a5daf Mon Sep 17 00:00:00 2001 From: Dimitar Dinchev Date: Tue, 17 Apr 2018 12:18:39 +0300 Subject: [PATCH 2/3] Update docs. --- doc/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/readme.md b/doc/readme.md index b11f14d..9c0906b 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -35,7 +35,7 @@ Let's say we want to use the [Fixer.io](http://fixer.io) service and fallback to use Swap\Builder; $swap = (new Builder()) - ->add('fixer') + ->add('fixer', ['access_key' => 'your-access-key']) ->add('google') ->build(); ``` @@ -133,7 +133,7 @@ $client = new PluginClient(new GuzzleClient(), [$cachePlugin]); $swap = (new Builder()) ->useHttpClient($client); - ->add('fixer') + ->add('fixer', ['access_key' => 'your-access-key']) ->build(); // A http request is sent @@ -231,7 +231,7 @@ $swap = (new Builder()) ->add('currency_data_feed', ['api_key' => 'secret']) ->add('currency_layer', ['access_key' => 'secret', 'enterprise' => false]) ->add('european_central_bank') - ->add('fixer') + ->add('fixer', ['access_key' => 'your-access-key']) ->add('forge', ['api_key' => 'secret']) ->add('google') ->add('national_bank_of_romania') From 0d4d35bb86d11630611151747fbcc29f0483c55c Mon Sep 17 00:00:00 2001 From: Dimitar Dinchev Date: Thu, 19 Apr 2018 17:05:41 +0300 Subject: [PATCH 3/3] Fix tests. --- tests/BuilderTest.php | 2 +- tests/Service/FactoryTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/BuilderTest.php b/tests/BuilderTest.php index 44c0c09..07bde2d 100644 --- a/tests/BuilderTest.php +++ b/tests/BuilderTest.php @@ -25,7 +25,7 @@ public function testBuild() $this->assertInstanceOf(Swap::class, $builder->build()); $builder = new Builder(); - $builder->add('fixer'); + $builder->add('fixer', ['access_key' => 'access_key']); $builder->add('open_exchange_rates', ['app_id' => 'secret']); $this->assertInstanceOf(Swap::class, $builder->build()); } diff --git a/tests/Service/FactoryTest.php b/tests/Service/FactoryTest.php index e5118b3..f9aa392 100644 --- a/tests/Service/FactoryTest.php +++ b/tests/Service/FactoryTest.php @@ -51,7 +51,7 @@ public function servicesProvider() ['currency_data_feed', CurrencyDataFeed::class, ['api_key' => 'api_key']], ['currency_layer', CurrencyLayer::class, ['access_key' => 'access_key']], ['european_central_bank', EuropeanCentralBank::class], - ['fixer', Fixer::class], + ['fixer', Fixer::class, ['access_key' => 'access_key']], ['forge', Forge::class, ['api_key' => 'api_key']], ['google', Google::class], ['national_bank_of_romania', NationalBankOfRomania::class],