REST API with swappable backends
What would be the best way to have a single REST API but with multiple "backends" (Not sure if this is the correct terminology)? Currently we have a basket/cart API that handles product creation, adding and removing products to a customer's basket, and handles all the checkout related stuff (Pricing, discount, instalments etc) While this is good for us internally it doesn't integrate into any CRMs without exporting information out of it and into something like Shopify or Magento. I would like to be able to skip our intermediate step and go straight to the CRM however I am unsure how best to go about designing something like this. My current idea is an interface, say IBasketBackend, which has all the methods we need and each backend such as Magento or Shopify will implement this interface. My idea is based on some parameter in the URL (most likely client ID), either build or retrieve an appropriate instance of IBasketBackend, however this seems like it would an a signifigant amount of overhead if it had to be done for each request.
What would be the best way to have a single REST API but with multiple "backends" (Not sure if this is the correct terminology)? Currently we have a basket/cart API that handles product creation, adding and removing products to a customer's basket, and handles all the checkout related stuff (Pricing, discount, instalments etc)
While this is good for us internally it doesn't integrate into any CRMs without exporting information out of it and into something like Shopify or Magento.
I would like to be able to skip our intermediate step and go straight to the CRM however I am unsure how best to go about designing something like this.
My current idea is an interface, say IBasketBackend, which has all the methods we need and each backend such as Magento or Shopify will implement this interface.
My idea is based on some parameter in the URL (most likely client ID), either build or retrieve an appropriate instance of IBasketBackend, however this seems like it would an a signifigant amount of overhead if it had to be done for each request.