Routes
Partner Orders
The following API routes are available under the partner-orders prefix.
The following API routes are available under the partner-orders prefix.
Overview
This document details the data flow for creating partner orders in the Ecom application, specifically for the ComestriController. It describes the request parameters, how they are processed, and the response generated.
List of API end-points prefix partner-orders
- GET:
/partner-orders/_ping - POST:
/partner-orders
Routes Prefix /partner-orders
1. Health Check
GET /partner-orders/_ping- Controller:
PingController - Description: Checks if the API is alive and responsive.
- Request:
- Method:
GET - URL:
/partner-orders/_ping - Parameters: None
- Method:
- Response:
{ data: { "status": "ok" } }
- Controller:
2. POST: ../partner-orders
- Request Parameters:
The POST /partner-orders/ endpoint expects a request payload that adheres to the validation
rules defined in
CreateComestriOrderRequest. Here is the detailed structure:- Request Payload:
{ "shipment": { "shipment_id": "string", "skus": [ { "wms_sku_id": "string", "quantity": 0 } ], "customer_info": { "title": "string", "given_name": "string", "family_name": "string", "phone": "string" }, "shipping_address": { "lines": [ "string", "string", "string" ], "city": "string", "postcode": "string" }, "provisional_tx": { "billing_address": { "lines": [ "string", "string", "string" ], "city": "string", "postcode": "string" } }, "shipping_options": { "delivery_instruction": "string" } } }
- Request Payload:
- Data Flow:
- Request Handling:
- The
storemethod ofComestriControlleris invoked when a POST request is made to/partner-orders/. - The request is validated against CreateComestriOrderRequest.
- The
- Validation:
- The CreateComestriOrderRequest class validates the incoming request parameters.
- If validation fails, an HTTP 422 response with validation errors is returned.
- Data Processing:
- Upon successful validation, the getRequestData method is called to transform the request data into a format suitable for the OrderService.
- The
productServicesused within getRequestData to fetch product details by SKU. - The processed data is formatted according to the requirements of the OrderService.
- Order Creation:
- The
OrderServicecreates a new order using the formatted request data. - The
orderServiceinstance is injected into thePartnerOrderControllerand used for order creation.
- The
- Response:
- After order creation, a successful HTTP 200 response is returned with no content.
- Request Handling:
- Request Example:
POST /partner-orders/ HTTP/1.1 Content-Type: application/json { "shipment": { "shipment_id": "xyz", "skus": [ { "wms_sku_id": "ABC123", "quantity": 10 } ], "customer_info": { "title": "Mr.", "given_name": "John", "family_name": "Doe", "phone": "+1234567890" }, "shipping_address": { "lines": ["123 Main St", "Apt 4B"], "city": "Springfield", "postcode": "12345" }, "provisional_tx": { "billing_address": { "lines": ["123 Main St", "Apt 4B"], "city": "Springfield", "postcode": "12345" } }, "shipping_options": { "delivery_instruction": "Leave at the front door" } } } - Response Example:
HTTP/1.1 200 OK Content-Type: application/json {}
Services
ProductService
- Method:
getProductByCode($sku_id)- Description: Retrieves product details using the SKU.
- Returns: Product object containing id and price.
OrderService
- Method:
createOrder($data)- Description: Creates a new order with the given data.
- Parameters: Array of order data formatted by
CreateComestriOrderRequest. - Returns: Order creation response.