processes tasks asynchronously by executing actions based on the type of OrderEvent received.
The OrderTaskProcessor class uses the Factory Pattern through the EventActionFactory class.
Factory Class (EventActionFactory):
The EventActionFactory - creates instances of different actions based on the OrderEvent type.
method getAction(OrderEvent orderEvent): returns an appropriate action instance based on the OrderEvent type.
Client Class (OrderTaskProcessor):
The OrderTaskProcessor class uses the EventActionFactory to get the appropriate action for the given OrderEvent.
It calls the execute method on the action instance returned by the factory.
GenerateLeadPdfAction
Fetch the cartDetails of that cartId //TODO: write and learn what’s in cartDetails
Convert pdfs to base64 and add them to orderDTO in OmsTaskEvent
Save OrderStatus in orderStatus table to LEAD_PDF_CREATED
Set the next orderEvent of OmsTaskEvent to CREATE_AURORA_LEAD
Publish the event in “internal_lead_generate” topic.
LeadCreateEventAction
LeadType.EXPLICIT
VehicleLeadService class is called to transform the OmsTaskEvent
Transformed into LeadSubmissionEvent and published to another internal_drp_lead_submit topic : listened by outbound service to publish it to the public topic for it be consumed by another team which works on dealer side of things
Transformed into LeadRequestDto and sent to the OEM via integrations API
Again save the orderStatus in orderStatus table with orderStatus as VEHICLE_LEAD_SUBMITTED.
Then once the lead is submitted to both OEM and Dealer team, the status is changed and saved to ORDER_CREATED.
OmsTaskEvent’s next orderEvent is set to UPDATE_CHECKOUT_COMPLETED
Publish the event in “internal_lead_generate” topic.
If there’s an error in the above steps
saveOrderError in OrderError table with cartId, orderId and error message.
LeadType.IMPLICIT
Build the cart link
Submit implicit lead via integrations api to the OEM which contains customerInfo, vehicle cart link, has consented for promos and purchase interests like Vehicle configs and Subscriptions which is also sent to customer via an email.
UpdateCheckoutAction
Checks if orderStatus is ORDER_CREATED or ORDER_FAILURE and publish it to “internal_drp_lead_status” topic.
Saves the order status to CART_UPDATED
OmsTaskEvent’s next orderEvent is set to SEND_LEAD_SUBMIT_CONFIRMATION_NOTIFICATION
Publish the event in “internal_lead_generate” topic.
SendLeadSubmitNotificationAction (FINAL STEP)
Save the order status to SENT_NOTIFICATION.
OmsTaskEvent’s next orderEvent is set to NULL and not published to the topic.