Hi guys,
I wanna throw a slightly radioactive curveball at you :D
All of our projects are using the LiveIntegrationV1 or LSRetailIntegrationFramework and more and more our team is getting into scenarios where we'd like to edit the data returned from the dwapi requests, ideally without having to update the data in the database. For example when we're getting live prices for specific customers, I think we can all agree that updating the prices in the EcomPrices table is not a trivial task, specially if you're not familiar with the DW source code.
Nicolai mentioned to us a few weeks / days ago the possibility of creating an extension method of sorts that could return a custom model and that would override the pre-existing method, but if I remember correctly that would only work in DW 10.
What about notification subscribers for each dwapi request?
It's definetily more work for you guys to implement, but it could allow us to manipulate the ViewModels each request returns before the response is served without having to modify the data in the database. I could see this being implemented in two ways:
Scenario A: Each request would have a BeforeResponseIsReturned / AfterRequestIsProcessed subscriber that is triggered just before the return command in the controller method, after all internal DW logic is done and the ViewModel has been populated with data from Dynamicweb.
Scenario B: could be to have 2 subscribers per request:
- BeforeRequestIsProcessed: Arguments could contain the input ViewModel (so we know what the hell is being asked for), the response ViewModel (empty ofc) and a boolean that cancels/skips all internal DW logic for that request so that the logic we write in the OnNotify override method would basicly be a new implementation for that request.
- BeforeResponseIsReturned / AfterRequestIsProcessed: Arguments would probably only have to contain the response ViewModel. Allowing us to edit that data on the ViewModel to be returned from the DWAPI.
Changing the response ViewModel in either subscriber would affect the response returned from the DWAPI request, but ultimately if you implement the latter one then that's the data that you get.
What do you guys think? Should I be institutionalized or are we on to something here?
Best regards,
Arnór