Customers

Favourite Branch

Overview by Shivang

Add Customer Favourite Branch

  • Route: POST ../customers/{customerId}/favourite-branches
  • Controller: AssociatedBranchesController
  • Method: add
  • Request: AddFavouriteBranchRequest
  • Description: Endpoint to add a favourite branch for a specific customer.

The add method in the AssociatedBranchesController handles the addition of a favourite branch for a customer identified by their ID. It begins by logging the site_id from the request. The customer is retrieved using the customerService, ensuring a 404 error is returned if the customer does not exist. The method checks for authorization to update the customer's details. It then calls the addFavouriteBranchForCustomer method to add the specified branch to the customer's favourites. A debug log records the addition of the favourite branch, including the customer ID and the updated list of favourite branches. Finally, it returns a JSON response containing the updated list of favourite branches.


Overview by Atul

POST: customers/{customerId}/favourite-branches

  • Controller: AssociatedBranchesController
  • Method: POST
  • Request: AddFavouriteBranchRequest
  • Parameters:
    • customerId: Identify the customer for whom the favourite branch is being added.
  • Description: Endpoint to add a favourite branch.

The request this function adds a favourite branch for a customer by calling the appropriate service method and returns the updated favourite branches data in a JSON response. It also includes security measures to ensure that only authorized users can update customer data.

public function add(AddFavouriteBranchRequest $request, $customerId)
{
    // Function implementation goes here
}

Request Parameters for customers/{customerId}/favourite-branches:

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

Response

Response Code: 403 Forbidden

Response:


<!doctype html>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<title>403</title>403 Forbidden

DELETE: customers/{customerId}/favourite-branches/{siteId}

  • Controller: AssociatedBranchesController
  • Method: DELETE
  • Request: Request
  • Parameters:
    • customerId: Identify the customer for whom the favourite branch is being removed.
  • Description: Endpoint to remove a favourite branch.

The request function is responsible for removing a favorite branch for a customer, ensuring that the user is authorized to perform the update, and returning the updated favorite branches in a JSON response.

public function remove(Request $request, $customerId, $siteId)
{
    // Function implementation goes here
}

Request Parameters for customers/{customerId}/favourite-branches/{siteId}:

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

Response

Response Code: 403 Forbidden

Response:


<!doctype html>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<title>403</title>403 Forbidden

Copyright © 2026