Giter Club home page Giter Club logo

Comments (2)

ash-jc-allen avatar ash-jc-allen commented on July 29, 2024 1

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.

michabbb avatar michabbb commented on July 29, 2024 1

Thanks for the detailed answer 👍🙏

from laravel-exchange-rates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.