Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOL-10] Order Tracking Service #97

Closed
wants to merge 2 commits into from
Closed

Conversation

piyushswain
Copy link
Contributor

@piyushswain piyushswain commented May 26, 2022

This PR adds the order tracking service for Bolt API and also syncs the tracking data on both Bolt and Solidus.

Refer: https://help.bolt.com/api-bolt/#tag/Orders/operation/trackOrder

@piyushswain piyushswain linked an issue May 26, 2022 that may be closed by this pull request
@piyushswain piyushswain self-assigned this May 26, 2022
@piyushswain piyushswain marked this pull request as draft May 26, 2022 09:40
@piyushswain piyushswain force-pushed the ps/order_tracking_details branch from a129801 to 12f861e Compare June 9, 2022 10:47
@piyushswain piyushswain requested a review from Naokimi June 9, 2022 10:48
@piyushswain piyushswain marked this pull request as ready for review June 9, 2022 10:48
@piyushswain piyushswain force-pushed the ps/order_tracking_details branch from 32f4960 to 2b6591c Compare June 10, 2022 05:38
@piyushswain piyushswain requested a review from Naokimi June 10, 2022 05:48
Comment on lines 6 to 33
base.class_eval do
before_save :update_bolt_tracking_info
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you have used

base.class_eval do
        before_save :update_bolt_tracking_info
      end

rather than base.before_save :update_bolt_tracking_info ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified here 4644cca

end

def update_bolt_tracking_info
return unless tracking_was.nil?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that return if tracking_was is more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified here 4644cca

transaction_reference = payment&.response_code
return if transaction_reference.blank?

SolidusBolt::ShipmentTrackingJob.perform_later(transaction_reference: transaction_reference, shipment: self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if the order contains more than one shipment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure yet if Bolt supports multiple shipments like Solidus.

Nothing in the bolt docs points to supporting multiple shipments and also this API returns an error if we have already added one instance of tracking details to the Order on Bolt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should ask the Bolt team how they would like to handle that part. I don't want to return an error anytime that a user marks the second shipment as shipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

transaction_reference: transaction_reference,
tracking_number: shipment.tracking,
carrier: shipment.shipping_method.name,
items: order.bolt_items,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not right, the shipped items should be the items in the shipment, not the items in the order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to the shipment_decorator.

This commit adds the order tracking service for Bolt API.

This service calls the bolt order_tracking endpoint with updated data for Order Tracking.

Refer: https://help.bolt.com/api-bolt/#tag/Orders/operation/trackOrder
@piyushswain piyushswain force-pushed the ps/order_tracking_details branch from 36bc3a4 to e432ca5 Compare June 14, 2022 05:55
This commit adds a ShipmentTrackingJob that calls the ShipmentTracking Service.

This was necessary because the check for the update on the tracking number is called before_save and calling the service at this point would cause a lot of delay for the API to execute. Hence, the service is called asynchronously from this point in the code.
@piyushswain piyushswain force-pushed the ps/order_tracking_details branch from e432ca5 to d4dba27 Compare June 14, 2022 06:13
@DanielePalombo DanielePalombo marked this pull request as draft June 21, 2022 15:44
Copy link
Contributor

@DanielePalombo DanielePalombo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solidus should invoke Order Tracking API multiple times for the same transaction reference, but different items and different tracking information base on shipments information.

@DanielePalombo DanielePalombo changed the title Order Tracking Service [BOL-10] Order Tracking Service Jul 14, 2022
@stale
Copy link

stale bot commented Nov 11, 2022

This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 11, 2022
@gsmendoza gsmendoza removed the stale label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send order tracking details via Bolt API
4 participants