I have a project to sync two systems via web services. The objective is to get customer data and orders from a shopping cart, and then transfer the data into a CRM system. It's a one-way transfer now.
There will be different shopping carts systems, different CRM's, different business rules for different companies, and sometimes slightly different data elements. For example: Company A might use Magento shopping cart with CRM A. Company B might use Volusion shopping cart with CRM A. Company C might use Magento shopping cart with CRM B. To sync the data, this is what needs to happen: 1. Periodically, check the shopping cart for any new orders. 2. For any new order get additional information out of the shopping cart (Some data isn't available via the order API call) 3. Create or update the info in the CRM. 4. Run a set of business rules based on the order and set fields or flags in the CRM. I'm trying to create the right abstractions that make this manageable. I have a procedural version, but I want to divide up the code to make it easier to manage and enhance. Right now, I have to copy the code and make a version for each Company -- Messy! I was thinking I could have a shoppingCartGateway.cfc and a CRMGateway.cfc to manage CRUD for each shopping cart and CRM. I'm hoping to be able to switch out the shopping cart gateway to handle different shopping carts, and then have a one, consistent order object or structure. Then, I can sync the order object with any CRM via the CRM gateway. I'd like to decouple the CRM from the shopping cart to handle all the variations. I'd need an orderObject.cfc to hold all the order and customer data. Or, this could possibly just be a big Struct, or I could store the order data in a database. I expect, it will take several gateway calls to fully set all the data values in the orderObject, so I need a way to keep the data around and get it organized. My question is what's the best design architecture? I'm writing this to clarify my thinking and I'm also hoping some of you will have some good ideas or pointers for me! I'm having trouble thinking about which object should be responsible for what! - Does the orderObject create and use the shoppingCartGateway.cfc as a service to initialize itself? - Or, do I have a separate sync.cfc that just uses the orderObject as a value object, gets the data from shoppingCartGateway.cfc and stores it in the orderObject? - Or, is there a better way of thinking about this that I'm missing? I also need a way to handle business rules between Company A, B, and C. For example, Company A may sell coffee and wants the CRM to reflect whether this customer like mild or strong coffee based on the products the customer bought. Then, they can notify the customer of a new kind of coffee the customer might like. Company B wants their CRM to show the number of orders from each customer so they can use this to send special promotions to their best customers. All the data that's needed to apply the business rules is in the order information. What I'd like to have is a clean way to organize the code so I can keep Company A's and Company B's business rules separate. I thought I might use inheritance and just extend based on the company. But, extend which object? Thanks for listening and for any ideas! Clarke