Comments (2)
Hey @michabbb!
I do think that the idea of having a failover driver could be a nice-to-have for the package. But at the moment, I've got no plans of adding anything like that, sorry.
At the moment, it's possible to choose your driver at runtime like shown in the docs (https://github.com/ash-jc-allen/laravel-exchange-rates#drivers). For example:
// Using the "ExchangeRate" class:
$result = app(ExchangeRate::class)
->driver('exchange-rates-data-api')
->exchangeRate('GBP', ['EUR', 'USD']);
// Using the "ExchangeRate" facade:
$result = ExchangeRate::driver('exchange-rates-data-api')
->exchangeRate('GBP', ['EUR', 'USD']);
However, because of the way I've built the package so far (without the intention of there being a failover), the drivers get the API key from the same config variable. So if you wanted to use a different service on the fly, I think you'd probably want to override the config when switching drivers. For example:
ExchangeRate::driver('exchange-rates-data-api')
->exchangeRate('GBP', ['EUR', 'USD']);
// If the call didn't work, try with a different provider...
config(['laravel-exchange-rates.api_key' => 'MY OTHER API KEY']);
ExchangeRate::driver('exchange-rate-host')
->exchangeRate('GBP', ['EUR', 'USD']);
It's not ideal, but it should hopefully do the job 🙂
from laravel-exchange-rates.
Thanks for the detailed answer 👍🙏
from laravel-exchange-rates.
Related Issues (20)
- Automatic cache clearing / choosing the cache store HOT 1
- ArgumentCountError HOT 2
- ExchangeRateHost Driver now needs an API key HOT 2
- API Error HOT 7
- Format converted values
- Installation Failed (Guzzle version Issue) HOT 2
- Invalid conversion for Float values HOT 1
- convert() method does not calculate accurately HOT 1
- How to add Local Currency HOT 1
- Can't convert decimal numbers HOT 1
- Undefined index: rates exception caused by missing_access_key API error HOT 9
- base_currency_access_restricted HOT 1
- free Subscription Plan does not work HOT 1
- New Exchange Rates API
- You have not specified a Time-Frame HOT 4
- Update $allowableCurrencies HOT 2
- How do you generate Facade php docs? HOT 2
- Use frankfurter.app HOT 1
- now() helper function not always available. Use Carbon::now() instead. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-exchange-rates.