Routes

Orders

Introduction

This Page provides an overview of the routes defined for the Orders purpose endpoints in the Toolstation E-Comm Api.

List of Routes for Orders

  1. /orders/_ping
  2. /orders
  3. /orders/{orderId}
  4. /orders/{orderId}/addresses
  5. /orders/{orderId}/channels
  6. /orders/{orderId}/attributes
  7. /orders/{orderId}/tracking-links
  8. /orders/order-invoice-request
  9. /orders/{orderId}/invoice
  10. /orders/{orderId}/delivery-statuses

GET: orders/_ping

  • Method: GET
  • Controller: PingController
  • Description: Endpoint to check if the authentication is valid and running successfully.

Response

Response Code: 200 OK

Response:

{
    "data": {
        "msg": "OK"
    }
}

POST: orders/orders

  • Controller: OrdersController
  • Method: Post
  • Request: CreateOrderRequest
  • Description: Endpoint for creating an order.

The store function processes an order request, handles potential duplicate requests, builds order details, interacts with the order service to create the order, and manages various exceptions that may occur during the process. The function includes extensive logging for tracking the order processing flow and uses different HTTP responses to communicate the outcome of the request and return as an OrderResource.

public function store(CreateOrderRequest $request): 
{
    // Function implementation goes here
}

Request Parameters for orders/orders:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

GET: orders/{orderId}

  • Controller: OrdersController
  • Method: Get
  • Request: Request
  • Parameters:
    • orderId: Idetifies the orders to be retrieved.
  • Description: Endpoint for retrieving an order.

The get function retrieves an order by its ID, including related items and their current prices. It checks if the user is authorized to view the order and logs a debug message. It then returns a resource representation of the order, encapsulated in the OrderResource class.

public function get(Request $request, $orderId)
{
    // Function implementation goes here
}

Request Parameters for orders/{ordersId}:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

GET: orders/{orderId}/addresses

  • Controller: OrdersController
  • Method: Get
  • Request: Request
  • Parameters:
    • orderId: Idetifies the orders to be retrieved.
  • Description: Endpoint for retrieving the addresses associated with an order.

The addresses function is to provide a way to fetch and return the addresses associated with an order. The function assumes that the authenticated user is authorized to view the order. The function also logs a debug message to indicate that the addresses are being fetched and returned payment addresses and delivery addresses.

public function addresses(Request $request, $orderId)
{
    // Function implementation goes here
}

Request Parameters for orders/{ordersId}/addresses:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

GET: orders/{orderId}/channels

  • Controller: OrdersController
  • Method: Get
  • Request: Request
  • Parameters:
    • orderId: Idetifies the orders to be retrieved.
  • Description: Endpoint for retrieving the channels associated with an order.

The channels function is responsible for fetching the channels associated with a specific order. It takes an order ID as a parameter, retrieves the order using the orderService, checks the user's authorization to view the order, logs a debug message, and returns an instance of OrderChannelsResource representing the channels associated with the order.

public function channels(Request $request, $orderId)
{
    // Function implementation goes here
}

Request Parameters for orders/{ordersId}/channels:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

POST: orders/{orderId}/attributes

  • Controller: OrderAttributesController
  • Method: Post
  • Request: CreateOrderAttributeRequest
  • Parameters:
    • orderId: Idetifies the orders to be retrieved.
  • Description: Endpoint for creating an order attribute.

The store function retrieves an order using the orderService object, checks if the order exists, dispatches a job to create an order attribute, and returns a JSON response with a HTTP 201 Created status code.

public function store(CreateOrderAttributeRequest $request, $orderId)
{
    // Function implementation goes here
}

Request Parameters for orders/{ordersId}/attributes:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}
  • Controller: DeliveryTrackingLinkController
  • Method: Get
  • Request: CreateOrderAttributeRequest
  • Parameters:
    • orderId: Idetifies the orders to be retrieved.
  • Description: Endpoint for retrieving the tracking links associated with an order.

The __invoke function truncates the order ID, retrieves the order, checks authorization, initializes response data, checks for child orders, loops through each order, handles exceptions, processes tracking links, formats response data, and returns a JSON response with the formatted tracking links grouped by carrier name. It uses the orderService and orderDeliveryService to interact with the orders and tracking links, and logs error messages for debugging purposes.

public function __invoke(Request $request, $orderId)
{
    // Function implementation goes here
}

Request Parameters for orders/{ordersId}/tracking-links:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

POST: orders/order-invoice-request

  • Controller: OrderInvoiceController
  • Method: Post
  • Request: OrderInvoiceRequest
  • Description: Endpoint for requesting an invoice for an order.

The emailInvoices function handles the request to email invoices for a set of orders, authorizes access to the orders, and calls the emailInvoiceForOrders method of the orderInvoiceService to send the invoices via email. Fetch the orders id from the orderService by using the get function public function getOrder($orderId, $relationships = [], $returnParent = false);.

public function emailInvoices(OrderInvoiceRequest $request)
{
    // Function implementation goes here
}

Request Parameters for orders/order-invoice-request:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

POST: orders/{orderId}/invoice

  • Controller: OrderInvoiceController
  • Method: Post
  • Request: OrderInvoicePdfRequest
  • Parameters:
    • orderId: Idetifies the orders to be retrieved.
  • Description: Endpoint for generating an invoice for an order.

The getPdfInvoice function generates a PDF invoice for an order and either streams it to the client or downloads it based on the request parameters. It also checks if the current user is authorized to access the order before generating the PDF.

public function getPdfInvoice(OrderInvoicePdfRequest $request, $orderId)
{
    // Function implementation goes here
}

Request Parameters for orders/{ordersId}/invoice:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

GET: orders/{orderId}/delivery-statuses

  • Controller: OrderController
  • Method: Get
  • Request: Request
  • Parameters:
    • orderId: Idetifies the orders to be retrieved.
  • Description: Endpoint for retrieving the delivery statuses.

The getDeliveryStatuses function is responsible for retrieving the delivery statuses of an order. It takes the order ID as a parameter and uses it to retrieve the order from the order service. It then checks if the current user is authorized to view the order. If the user is authorized, it logs a debug message and returns a resource DeliveryStatusResource of the delivery statuses of the order.

public function getDeliveryStatuses(Request $request, $orderId)
{
    // Function implementation goes here
}

Request Parameters for orders/{ordersId}/delivery-statuses:

  • Header :- Accept-Language:- en-UK,en
  • x-toolstation-customer-id:- Token Id of the customer

Response

Response Code: 403 Forbidden

Response:

{
    "error": {
        "code": "500.99",
        "message": "Internal Server Error",
        "info": "https://developers.example.com",
        "data": null
    }
}

Copyright © 2026