|
1 | | -# food-delivery-backend |
| 1 | +# Food Delivery Backend API |
| 2 | + |
| 3 | +Welcome to the Food Delivery Backend API documentation. |
| 4 | + |
| 5 | +## Base URL |
| 6 | + |
| 7 | +[https://espresso-food-delivery-backend-cc3e106e2d34.herokuapp.com/](https://espresso-food-delivery-backend-cc3e106e2d34.herokuapp.com/) |
| 8 | + |
| 9 | +## DTOs |
| 10 | + |
| 11 | +For information on the Data Transfer Objects (DTOs) used in the requests and responses, [check out the DTOs here](/src/main/kotlin/com/example/dto). |
| 12 | + |
| 13 | +## User API Endpoints |
| 14 | + |
| 15 | +### Register User |
| 16 | +- **POST** `/register` |
| 17 | + - Description: Registers a new user with the provided details. |
| 18 | + - Request Body: `UserRegisterDto` (Object) - Data Transfer Object containing user registration details. |
| 19 | + - Responses: |
| 20 | + - `201 Created` if registration is successful. |
| 21 | + - `400 Bad Request` with error message if registration fails. |
| 22 | + |
| 23 | +### User Login |
| 24 | +- **POST** `/login` |
| 25 | + - Description: Authenticates a user and returns a user identifier upon successful login. |
| 26 | + - Request Body: `UserLoginDto` (Object) - Data Transfer Object containing user login credentials. |
| 27 | + - Responses: |
| 28 | + - `200 OK` with user identifier if login is successful. |
| 29 | + - `401 Unauthorized` with error message if login fails. |
| 30 | + |
| 31 | +### Get User Profile |
| 32 | +- **GET** `/profile/{userId}` |
| 33 | + - Description: Retrieves the profile details of a specific user. |
| 34 | + - Path Parameters: `userId` (UUID) - The unique identifier of the user. |
| 35 | + - Responses: |
| 36 | + - `200 OK` with user profile details if found. |
| 37 | + - `404 Not Found` with error message if user profile is not found. |
| 38 | + |
| 39 | +### Get User Profile Flow |
| 40 | +- **GET** `/profile/{userId}/flow` |
| 41 | + - Description: Retrieves a flow of profile details for a specific user. This is typically used for real-time updates. |
| 42 | + - Path Parameters: `userId` (UUID) - The unique identifier of the user. |
| 43 | + - Responses: |
| 44 | + - `200 OK` with a flow of user profile details if found. |
| 45 | + - `404 Not Found` with error message if user profile is not found. |
| 46 | + |
| 47 | +### Update User Location |
| 48 | +- **POST** `/profile/{userId}/location` |
| 49 | + - Description: Updates the location details for a specific user's profile. |
| 50 | + - Path Parameters: `userId` (UUID) - The unique identifier of the user. |
| 51 | + - Request Body: `UserUpdateLocationDto` (Object) - Data Transfer Object containing new location details. |
| 52 | + - Responses: |
| 53 | + - `200 OK` if the location is successfully updated. |
| 54 | + - `404 Not Found` with error message if the user profile is not found or update fails. |
| 55 | + |
| 56 | +## Order API Endpoints |
| 57 | + |
| 58 | +### Add Item to Order |
| 59 | +- **POST** `/orders/{userId}/items` |
| 60 | + - Adds a food item to the user's order. |
| 61 | + - **Path**: `userId` (UUID as string) |
| 62 | + - **Body**: `FoodDto` (JSON) |
| 63 | + - **Response**: `200 OK` with order ID, `500 Internal Server Error` with error message. |
| 64 | + |
| 65 | +### Update Order Item Quantity |
| 66 | +- **POST** `/orders/items/{itemId}` |
| 67 | + - Updates the quantity of an item in the order. |
| 68 | + - **Path**: `itemId` (Integer) |
| 69 | + - **Body**: Quantity (Integer) |
| 70 | + - **Response**: `200 OK` with item details, `500 Internal Server Error` with error message. |
| 71 | + |
| 72 | +### Get Active Order |
| 73 | +- **GET** `/orders/{userId}` |
| 74 | + - Retrieves the user's active order. |
| 75 | + - **Path**: `userId` (UUID as string) |
| 76 | + - **Response**: `200 OK` with order details, `404 Not Found` with error message. |
| 77 | + |
| 78 | +### Complete Order |
| 79 | +- **GET** `/orders/{userId}/complete` |
| 80 | + - Completes the user's current order. |
| 81 | + - **Path**: `userId` (UUID as string) |
| 82 | + - **Response**: `200 OK` with completion status, `500 Internal Server Error` with error message. |
| 83 | + |
| 84 | +### Delete Current Order |
| 85 | +- **DELETE** `/orders/{userId}/current` |
| 86 | + - Deletes the user's current order. |
| 87 | + - **Path**: `userId` (UUID as string) |
| 88 | + - **Response**: `200 OK` with deletion status, `500 Internal Server Error` with error message. |
| 89 | + |
| 90 | +### Delete Specific Order |
| 91 | +- **DELETE** `/orders/{userId}/{orderId}` |
| 92 | + - Deletes a specific order for the user. |
| 93 | + - **Path**: `userId` (UUID as string), `orderId` (Integer) |
| 94 | + - **Response**: `200 OK` with deletion status, `500 Internal Server Error` with error message. |
| 95 | + |
| 96 | +## Food API Endpoints |
| 97 | + |
| 98 | +### Get Food Details |
| 99 | +- **GET** `/foods/{foodId}` |
| 100 | + - Retrieves details for a specific food item. |
| 101 | + - **Path**: `foodId` (Integer) |
| 102 | + - **Response**: `200 OK` with food details, `404 Not Found` with error message. |
| 103 | + |
| 104 | +### List All Foods or Search |
| 105 | +- **GET** `/foods` |
| 106 | + - Lists all foods or returns search results based on query. |
| 107 | + - **Query**: `search` (String, optional) - Search term for food items. |
| 108 | + - **Response**: `200 OK` with list of foods or search results, `404 Not Found` with error message. |
| 109 | + |
| 110 | +### Get Foods by Category |
| 111 | +- **GET** `/foods/categories` |
| 112 | + - Retrieves foods filtered by category. |
| 113 | + - **Query**: `type` (String, optional) - Category type, defaults to "all". |
| 114 | + - **Response**: `200 OK` with foods by category, `404 Not Found` with error message. |
0 commit comments