Point of Service Patron API Flow
To provide the proper experience to patrons using the Point of Service (POS) API, you’ll need to build the following capabilities:- Allow the patron to browse available dishes by category (appetizers, main course, drinks, and desserts).
- Ensure the essential ingredients for the dish are in stock.
- Allow the patron to view dish details prior to ordering.
- Let the patron add a dish to their cart and view it.
- Create the order in the system.
- Confirm to the patron the order has been successfully placed.
Step 1: Browse dishes by category
Patrons will start by browsing in the ordering app and should be able to view dishes specific to the category they select. Available values for categories:AppetizersMain CourseDessertDrinks
Request
The client sends an HTTP request to retrieve a list of dishes filtered by the selectedcategory.
Endpoint: GET /dishes
Response
If the request was successful, the server responds with a200 okay status code and a response body containing the list of dishes in that category.
Each dish object includes the following properties:
Step 2: Check ingredient quantities
Next, the client app must confirm the in stock quantities of the essential ingredients for the dishes.Request
The client sends HTTP requests to retrieve thename and in_stock_qty properties for each ingredient. You’ll need the ingredient_id for each ingredient to check and you’ll filter the response to include only the in_stock_qty and name fields.
Endpoint: GET /ingredients/{id}
Response
If the request was successful, the server responds with a200 okay status code and a response body that includes the requested resource.
Any dishes that have essential ingredients with an
in_stock_qty of 0 should display as unavailable in the client app so they cannot be added to an order.Step 3: View dish details
The patron will select a dish to see its details.Request
The client sends HTTP requests to retrieve thename, price, description, and ingredients properties for the selected dish. For this call, you’ll need the id for the selected dish.
Endpoint: GET /dishes/{id}
Response
If the request was successful, the server responds with a200 okay status code and a response body that includes the following properties:
Step 4: Add a dish and view the cart
The patron can now add the dish to their cart and then view the cart when they are ready to place their order. The client app keeps track of the dishes added to the cart.Step 5: Place the order
When the patron has finished adding dishes to their cart, they can then place their order. This request requires authorization with a bearer token, as well as the following properties in the request body:Request
The client sends an HTTP request with an authorization header and request body that includes the dish ids from local storage and the other required properties for the order. Endpoint:POST /orders
Response
If the request was successful, the server responds with a201 created status code and a response body that includes the resource.