Skip to main content

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:
  1. Allow the patron to browse available dishes by category (appetizers, main course, drinks, and desserts).
  2. Ensure the essential ingredients for the dish are in stock.
  3. Allow the patron to view dish details prior to ordering.
  4. Let the patron add a dish to their cart and view it.
  5. Create the order in the system.
  6. 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:
  • Appetizers
  • Main Course
  • Dessert
  • Drinks

Request

The client sends an HTTP request to retrieve a list of dishes filtered by the selected category. Endpoint: GET /dishes

Response

If the request was successful, the server responds with a 200 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 the name 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 a 200 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 the name, 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 a 200 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 a 201 created status code and a response body that includes the resource.

Step 6: Confirm the order

The patron should receive a success message that says, “We’ve received your order!” upon the successful creation of the order.