Trolley
Overview by Shivang
GET Customer Trolleys
- Route:
GET ../customers/{customerId}/trolleys - Controller:
TrolleyController - Method:
getCustomerTrolleys - Request:
ViewCustomerTrolleysRequest - Description: Endpoint to retrieve a list of trolleys associated with a specific customer.
The getCustomerTrolleys method in the TrolleyController fetches the trolleys linked to a customer identified by their ID. It uses the trolleyService to retrieve the trolleys associated with the customer. The method logs the trolley fetch event, including the customer ID and the retrieved trolley IDs, for debugging purposes. Finally, it returns a TrolleyResource collection containing the customer's trolleys.
GET Customer Active Trolleys
- Route:
GET ../customers/{customerId}/trolleys/active - Controller:
TrolleyController - Method:
getCustomerActiveTrolleys - Request:
ViewCustomerTrolleysRequest - Description: Endpoint to retrieve a list of active trolleys associated with a specific customer.
The getCustomerActiveTrolleys method in the TrolleyController retrieves the active trolleys for a customer identified by their ID. It uses the trolleyService to fetch the active trolleys linked to the customer. The method logs the retrieval of active trolleys, including the customer ID and the corresponding trolley IDs, for debugging purposes. Finally, it returns a TrolleyResource collection containing the customer's active trolleys.
Create New Customer Trolley
- Route:
POST ../customers/{customerId}/trolleys - Controller:
TrolleyController - Method:
createNewCustomerTrolley - Request:
CreateNewTrolleyRequest - Description: Endpoint to create a new trolley for a specific customer.
The createNewCustomerTrolley method in the TrolleyController handles the creation of a new trolley for a customer identified by their ID. If the customer ID is not "guest," it retrieves the customer to ensure they exist. The method then creates a new trolley using the trolleyService, associating it with the customer or marking it as a guest if applicable. It logs the creation event, including the customer ID, trolley ID, session ID, and trolley name. Finally, it returns a TrolleyResource with the created trolley and a 201 Created response.
Overview by Atul
GET: customers/{customerId}/trolleys
- Controller:
TrolleyController - Method:
GET - Request:
ViewCustomerTrolleysRequest - Parameters:
customerId: Identifies the customer whose trolleys are being retrieved.
- Description: Endpoint for retrieve trolley list.
The getCustomerTrolleys function retrieves the trolleys list associated with a specified customer, logs the details of the trolleys fetched, and returns them as a collection of standardized TrolleyResource objects.
public function getCustomerTrolleys(ViewCustomerTrolleysRequest $request, $customerId)
{
// Function implementation goes here
}
Request Parameters for customers/{customerId}/trolleys:
- Header :-
Accept-Language:- en-UK,en, - x-toolstation-customer-id:-
Token Id of the customer
Response
Response Code: 200 OK
Response:
{
"data": []
}
Response Code: 403 Forbidden
Response:
{
"error": {
"code": "403.99",
"message": "Forbidden",
"info": "https://developers.example.com",
"data": null
}
}
GET: customers/{customerId}/trolleys/active
- Controller:
TrolleyController - Method:
GET - Request:
ViewCustomerTrolleysRequest - Parameters:
customerId: Identifies the customer whose active trolleys are being retrieved.
- Description: Endpoint for retrieve active trolley list.
The getCustomerActiveTrolleys function retrieves the active trolleys list associated with a specified customer, logs the details of the active trolleys fetched, and returns them as a collection of standardized TrolleyResource objects.
public function getCustomerActiveTrolleys(ViewCustomerTrolleysRequest $request, $customerId)
{
// Function implementation goes here
}
Request Parameters for customers/{customerId}/trolleys/active:
- Header :-
Accept-Language:- en-UK,en, - x-toolstation-customer-id:-
Token Id of the customer
Response
Response Code: 200 OK
Response:
{
"data": []
}
Response Code: 403 Forbidden
Response:
{
"error": {
"code": "403.99",
"message": "Forbidden",
"info": "https://developers.example.com",
"data": null
}
}
POST: customers/{customerId}/trolleys
- Controller:
TrolleyController - Method:
POST - Request:
CreateNewTrolleyRequest - Parameters:
customerId: Identifies the customer for whom the trolley is being created.
- Description: Endpoint for create a new trolley for a specified customer or guest.
The createNewCustomerTrolley function efficiently handles the creation of a new trolley by checking if the customer is registered or a guest, creating the trolley accordingly, logging the operation, and returning TrolleyResource.
public function getCustomerTrolleys(ViewCustomerTrolleysRequest $request, $customerId)
{
// Function implementation goes here
}
Request Parameters for customers/{customerId}/trolleys:
- Header :-
Accept-Language:- en-UK,en, - x-toolstation-customer-id:-
Token Id of the customer
Response
Response Code: 200 OK
Response:
{
"data": {
"id": "f2a924f6-3634-4dea-8df1-98d5161da383",
"customer_id": "CWW02068816",
"session_id": "80af5a7f-93f2-4acf-a1e3-2b6cca84f20b",
"status": 1,
"name": null,
"created_at": "2024-08-12T10:15:06+02:00",
"updated_at": "2024-08-12T10:15:06+02:00",
"lines": [],
"attributes": [],
"applied_promo_codes": [],
"order_id": null,
"ordered_at": null
}
}
Response Code: 403 Forbidden
Response:
{
"error": {
"code": "403.99",
"message": "Forbidden",
"info": "https://developers.example.com",
"data": null
}
}