Source code for eclypse.builders.application.sock_shop.rest_services.shipping
"""The `ShippingService` class.
It manages the logistics and shipment of orders, ensuring items reach customers.
- Key Responsibilities:
- Handles the shipping of completed orders.
- Calculates shipping costs, delivery times, and tracks shipment status.
- Coordinates with third-party shipping providers for physical delivery.
"""
from eclypse.remote.communication import rest
from eclypse.remote.service import RESTService
from eclypse.utils import format_log_kv
[docs]
class ShippingService(RESTService):
"""REST endpoints for the Shipping service."""
[docs]
@rest.endpoint("/details", "GET")
def get_shipping_detils(self, order_id, **_):
"""Get the shipping details for an order.
Args:
order_id (str): The order ID.
Returns:
int: The HTTP status code.
dict: The response body.
Example:
.. code-block:: python
(
200,
{
"order_id": "12345",
"status": "success",
"shipping_details": {
"carrier": "UPS",
"tracking_number": "1234567890",
"estimated_delivery_date": "2024-04-09",
},
},
)
"""
self.logger.info("Received request | " + format_log_kv(order_id=order_id))
return 200, {
"order_id": order_id,
"status": "success",
"shipping_details": {
"carrier": "UPS",
"tracking_number": "1234567890",
"estimated_delivery_date": "2024-04-09",
},
}