-
Notifications
You must be signed in to change notification settings - Fork 3
API Routes
Response for all endpoints that require a current user to be logged in
- Request: endpoints that require authentication
- Error Response: Require authentication
- Status Code: 401
- Headers:
- Content-Type: application/json
- Body:
- Error Response: Require authentication
{
"message": "Authentication required",
"statusCode": 401
}Response for all endpoints that require authentication and the current user does not have the correct role(s) or permission(s).
- Request: endpoints that require proper authorization
- Error Response: Require proper authorization
- Status Code: 403
- Headers:
- Content-Type: application/json
- Body:
- Error Response: Require proper authorization
{
"message": "Forbidden",
"statusCode": 403
}Returns the information about the user that is searched for.
- Require Authentication: true
- Request
- Method: GET
- URL: /api/user/:userId
- Body: none
- Successful Response
- Status Code: 200
- Headers: * Content-Type: application/json * Body:
{
"user": {
"id": 1,
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@gmail.com",
"owner": "False",
"phoneNumber": 1234567891
}
}Logs in a current user with valid credentials and returns the current user's information.
- Require Authentication: false
- Request
- Method: POST
- URL: /api/auth/login
- Headers: * Content-Type: application/json * Body:
{
"email": "john.smith@gmail.com",
"password": "secret password"
}- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
"user": {
"id": 1,
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@gmail.com",
"owner": "False",
"phoneNumber": 1234567891
}
}- Error Response: Invalid credentials
- Status Code: 401
- Headers:
- Content-Type: application/json
- Body:
{
"message": "Invalid credentials",
"statusCode": 401
}- Error response: Body validation errors
- Status Code: 400
- Headers:
- Content-Type: application/json
- Body:
{
"message": "Validation error",
"statusCode": 400,
"errors": {
"credential": "Email or username is required",
"password": "Password is required"
}
}Creates a new user, logs them in as the current user, and returns the current user's information.
- Require Authentication: false
- Request
- Method: POST
- URL: /api/auth/signup
- Headers:
- Content-Type: application/json
- Body:
{
"id": 1,
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@gmail.com",
"owner": "False",
"phoneNumber": 1234567891,
"password": "secret password"
}- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
"id": 1,
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@gmail.com",
"owner": "False"
"phoneNumber”: 1234567891,
} - Error response: User already exists with the specified email or phone number
- Status Code: 403
- Headers:
- Content-Type: application/json
- Body:
{
"message": "User already exists",
"statusCode": 403,
"errors": {
"email": "User with that email already exists"
"phoneNumber": "User with that number already exists"
}
}- Error response: Body validation errors
- Status Code: 400
- Headers:
- Content-Type: application/json
- Body:
{
"message": "Validation error",
"statusCode": 400,
"errors": {
"email": "Invalid email",
"phoneNumber": "Phone is required",
"firstName": "First Name is required",
"lastName": "Last Name is required"
}
}Creates and returns a new restaurant.
-
Require Authentication: true
-
Request
-
Method: POST
-
URL: /api/restaurants
-
Headers:
- Content-Type: application/json
-
Body:
{ "restaurauntName": "Apple Academy", "coverImage": "www.photo.example", "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "zipcode": 10021, "country": "United States of America", "cuisineType": “Yummy”, “priceRange”: 3, “phoneNumber”: 123456789, “openHours”: “10 am”, “closingHours” : “3pm" }
-
-
Successful Response
-
Status Code: 201
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "ownerId": 1, "restaurauntName": "Apple Academy", "coverImage": "www.photo.example", "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "zipcode": 10021, "country": "United States of America", "cuisineType": “Yummy”, “priceRange”: 3, “phoneNumber”: 123456789, “openHours”: “10 am”, “closingHours” : “3pm”, "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36",
"nextThreeAvailableSlots": [ "21:30:00", "22:00:00", "17:00:00" ], }
-
-
Error Response: Body validation error
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Validation Error", "statusCode": 400, "errors": { "message": "Validation Error", "statusCode": 400, "errors": { "address": "Street address is required", "city": "City is required", "state": "State is required", "country": "Country is required", “zipcode”: “Zipcode is required”, "coverImage": "Must choose an image for your page", "restaurauntName": "Name must be less than 50 characters", "restaurauntName": “Name is required”, "priceRange": "Price range is required", "cuisineType": “Type of food is required”, "cuisineType": “Type of food must be from dropdown categories”, “openHours”: “Hours of operation required”, “closingHours” : “Closing cannot be before opening”, } }
-
-
Error response: Couldn't find a Restaurant with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Restaurant couldn't be found", "statusCode": 404 }
-
Returns all the restaurants for users to read
-
Require Authentication: false
-
Request
- Method: GET
- URL: /api/restaurants
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "Restaurants": [ { "id": 1, "ownerId": 1, "coverImage": "www.photo.example", "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "zipcode": 10021, "country": "United States of America", "cuisineType": “Yummy”, “priceRange”: 3, “phoneNumber”: 123456789, “openHours”: “10 am”, “closingHours” : “3 pm”, "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36", "avgRating": 4.5,
"nextThreeAvailableSlots": [ "21:30:00", "22:00:00", "17:00:00" ], } ] }
-
Returns all the restaurants owned (created) by the current user.
-
Require Authentication: true
-
Request
-
Method: GET
-
URL: /api/user/restaurants/
-
Body: none
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "Restaurants": [ { "id": 1, "ownerId": 1, "restaurauntName": "Apple Academy", "coverImage": "www.photo.example", "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "zipcode": 10021, "country": "United States of America", "cuisineType": “Yummy”, “priceRange”: 3, “phoneNumber”: 123456789, “openHours”: “10 am”, “closingHours” : “3pm”, "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36", "avgRating": 4.5, } ] }
-
Returns the details of a restaurant specified by its id.
-
Require Authentication: false
-
Request
- Method: GET
- URL: /api/restaurants/:restaurantId
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "ownerId": 1, "Owner": { "id": 1, "firstName": "John", "lastName": "Smith" }, "restaurauntName": "Apple Academy", "coverImage": "www.photo.example", "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "zipcode": 10021, "country": "United States of America", “priceRange”: 3, “phoneNumber”: 123456789, “openHours”: “10 am”, “closingHours” : “3 pm”, "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36", "avgRating": 4.5, "numReviews": 5, "ReviewImages": [ { "id": 1, "url": "image url", }, { "id": 2, "url": "image url", } ], }
-
-
Error response: Couldn't find a Restaurant with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Restaurant couldn't be found", "statusCode": 404 }
-
Deletes an existing restaurant.
-
Require Authentication: true
-
Require proper authorization: Restaurant must belong to the current user
-
Request
- Method: DELETE
- URL: /api/restaurants/:restaurantId
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Successfully deleted", "statusCode": 200 }
-
-
Error response: Couldn't find a Restaurant with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Restaurant couldn't be found", "statusCode": 404 }
-
Return all the reservations that the current user has made.
-
Require Authentication: true
-
Request
- Method: GET
- URL: /api/user/reservations
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "Reservations": [ { "id": 1, "restaurantId": 1, "Restaurant": { "id": 1, "ownerId": 1, "restaurauntName": "Apple Academy", "coverImage": "www.photo.example", "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "zipcode": 10021, "country": "United States of America", "cuisineType": “Yummy”, “priceRange”: 3, “phoneNumber”: 123456789, “openHours”: “10 am”, “closingHours” : “3pm”, "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36", }, "userId": 2, "reservationTime": "2021-11-19 20:39:36", "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36" } ] }
-
Return all the reservations for a restaurant specified by id.
-
Require Authentication: true
-
Request
- Method: GET
- URL: /api/restaurant/:restaurantId/reservations
- Body: none
-
Successful Response: If you ARE NOT the owner of the restaurant.
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "Reservations": [ { "restaurantId": 1, "reservationId": 1, "reservationTime": "2021-11-19 20:30:00", }, { "restaurantId": 1, "reservationId": 2, "reservationTime": "2021-11-19 20:00:00", } ] }
-
-
Successful Response: If you ARE the owner of the restaurant.
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "Reservations": [ { "id": 1, "restaurantId": 1, "userId": 2, "User": { "id": 2, "firstName": "John", "lastName": "Smith" “phoneNumber”: 1234567891, }, “numberOfPeople”: 3, "reservationTime": "2021-11-19 20:30:00", “status”: “confirmed”, “notes”: “this is my birthday, please sing”, "createdAt": "2021-11-19 20:30:36", "updatedAt": "2021-11-19 20:30:36" } ] }
-
-
Error response: Couldn't find a Restaurant with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Restaurant couldn't be found", "statusCode": 404 }
-
Create and return a new reservation from a restaurant specified by id.
-
Require Authentication: true
-
Require proper authorization: Restaurant must NOT belong to the current user
-
Request
-
Method: POST
-
URL: /api/restaurant/:restaurantId/reservations
-
Body:
{ “numberOfPeople”: 3, “notes”: “this is my birthday, please sing”, "reservationTime": "2021-11-19 20:30:00", }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "restaurantId": 1, "userId": 2, “numberOfPeople”: 3, "reservationTime": "2021-11-19 20:30:00", “status”: “confirmed”, “notes”: “this is my birthday, please sing”, "createdAt": "2021-11-19 20:30:36", "updatedAt": "2021-11-19 20:30:36" }
-
-
Error response: Body validation errors
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Validation error", "statusCode": 400, "errors": { "reservationTime": "reservation time cannot be in the past" } }
-
-
Error response: Couldn't find a Restaurant with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Restaurant couldn't be found", "statusCode": 404 }
-
-
Error response: Reservation conflict
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Sorry, this restaurant is already booked to capacity for the specified time- try a later time or date.", "statusCode": 403, "errors": { "reservationTime": "This choice conflicts with existing reservations", “numberOfPeople” : “This restaurant does not have enough seats at that time” } }
-
-
Error response: Reservation duplicate
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Oops! Looks like you already made a reservation here at this time.", "statusCode": 403, "errors": { "reservationTime": "You have a reservation at this time", “userId” : “You have a reservation at this time”, } }
-
Update and return an existing reservation.
-
Require Authentication: true
-
Require proper authorization: Reservation must belong to the current user
-
Request
-
Method: PUT
-
URL: /api/restaurant/:restaurantId/reservations/:reservationId
-
Headers:
- Content-Type: application/json
-
Body:
{ “numberOfPeople”: 4, “notes”: “this is my friend’s birthday, please don’t sing” "reservationTime": "2021-11-19 20:00:00", }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "restaurantId": 1, "userId": 2, “numberOfPeople”: 4, “notes”: “this is my friend’s birthday, please don’t sing” "reservationTime": "2021-11-19 20:00:00", "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36" }
-
-
Error response: Couldn't find a Reservation with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Reservation couldn't be found", "statusCode": 404 }
-
-
Error response: Can't edit a reservation that's past the reservation date time
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Past reservations can't be modified", "statusCode": 403 }
-
-
Error response: Reservation conflict
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Sorry, this restaurant is already booked to capacity for the specified time- try a later time or date.", "statusCode": 403, "errors": { "reservationTime": "This choice conflicts with existing reservations", “numberOfPeople” : “This restaurant does not have enough seats at that time” } }
-
Delete an existing reservation.
-
Require Authentication: true
-
Require proper authorization: Reservation must belong to the current user or the Restaurant must belong to the current user
-
Request
- Method: DELETE
- URL: /api/reservations/:reservationId
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Successfully deleted", "statusCode": 200 }
-
-
Error response: Couldn't find a Reservation with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Reservation couldn't be found", "statusCode": 404 }
-
-
Error response: Reservations that have been started or are in the past can't be deleted
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Reservations that have been started or are in the past can't be deleted", "statusCode": 403 }
-
Adds a restaurant to the user’s list of favorite restaurants
- Require Authentication: True
- Require proper authorization: User must be logged in to like and save a restaurant
- Request
- Method: POST
- URL: /api/user/:userId/favorites
- Headers:
- Content-Type: application/json
- Body:
{
restaurantId: 1
}- Successful Response
- Status Code: 200
- Headers:
- Content-type: application/json
- Body:
{
id: 1
userId: 1
restaurantId: 1
}- Error Response: The user or restaurant with the provided ID does not exist
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“Message”: “Restaurant not found”,
“statusCode”: 404
}- Error Response: The restaurant is already in the user’s list of favorites
- Status Code: 409
- Headers:
- Content-Type: application/json
- Body:
{
“Message”: “Restarant already exists in user’s list of favorites”
“statusCode”: 409
}Returns a list of the user’s favorite restaurants
- Require Authentication: True
- Request
- Method: GET
- URL: /api/user/:userId/favorites
- Body: none
- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“Favorites”: {
“id” : 1,
“userId”: 1,
“restaurantId”: 1,
"restaurant" : {
"restaurantName": Fleming’s Steakhouse,
"city": Los Angeles,
"state": California
}
},
{
“id”: 2,
“userId”: 1,
“restaurantId”: 2,
"restaurant": {
"restaurantName": Chilis,
"city": Denver,
"state": Colorado
}
}
}- Error Response: An existing user with the provided “User ID” was not found
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“Message”: “User cound not be found”,
“statusCode”: 404
}Removes a restaurant from the user’s list of favorite restaurants
- Require Authentication: True
- Request
- Method: DELETE
- URL: /api/user/:userId/favorites/
- Body:
{“id”: 1} - Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“Message”: “Successfully removed”,
“statusCode”: 200
}- Error Response: restaurant with provided ID does not exist
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“Message”:”Restaurant couldn’t be found”,
“statusCode”: 404
}Create and return a new review for a spot specified by id
- Require Authentication: True
- Request
- Method: POST
- URL: /api/restaurants/:restaurantId/reviews
- Headers:
- Content-Type: application/json
- Body:
- Method: POST
{
“rating”: 5,
“comment”: “The food was amazing!”
“reviewImage”: “image URL”
}- Successful Response
- Status Code: 201
- Headers:
- Content-Type: application/json
- Body:
{
“Id”: 1,
“userId”: 1,
“restaurantId”: 1,
“rating”: 5,
“comment”: “The food was amazing!”,
“reviewImage”: “image url”,
“createdAt”: “2021-11-19 20:39:36”,
“updatedAt”: “2021-11-19 20:39:36”
}- Error Response: Body validation errors
- Status Code: 400
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “validation error”,
“statusCode”: 400,
“errors”: [
“Comment is required”,
“Rating must be an integer from 1 to 5”
]
}- Error response: Couldn’t find a restaurant with the specified id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Restaurant couldn’t be found”
“statusCode”: 404
}- Error Response: Review from the current user already exists for the restaurant
- Status Code: 403
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “User already has a review for this restaurant”,
“statusCode”: 403
}Returns all the reviews that belong to a restaurant specified by id
- Require Authentication: True
- Request
- Method: GET
- URL: /api/restaurants/:restaurantId/reviews
- Body: none
- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“Reviews”: [{
“Id”: 1,
“userId”: 1,
“restaurantId”: 1,
“rating”: 5,
“comment”: “The food was amazing!”,
“reviewImage”: “image url”,
“createdAt”: “2021-11-19 20:39:36”,
“updatedAt”: “2021-11-19 20:39:36”,
}]
}-
Error Response: Couldn’t find a Restaurant with the specified id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body: none
-
Error Response: Couldn’t find a Restaurant with the specified id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{“Message”: “Restaurant couldn’t be found”}Update and return an existing review
- Require Authentication: True
- Require proper authorization: Review must belong to the current user
- Request
- Method: PUT
- URL: api/restaurants/int:restaurant_id/reviews/int:review_id
- Headers:
- Content-Type: application/json
- Body:
{
“rating”: 2,
“comment”: “The service was terrible!”
“reviewImage”: “image URL”
}- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“Id”: 1,
“userId”: 1,
“restaurantId”: 1,
“rating”: 2,
“comment”: “The service was terrible!”,
“reviewImage”: “image url”,
“createdAt”: “2021-11-19 20:39:36”,
“updatedAt”: “2021-11-19 20:39:36”
}- Error Reponse: Body validation errors
- Status Code: 400
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “validation error”,
“statusCode”: 400,
“errors”: [
“Comment is required”,
“Rating must be an integer from 1 to 5”
]
}- Error response: Couldn’t find a restaurant with the specified id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Restaurant couldn’t be found”
“statusCode”: 404
}Delete an existing review
- Require Authentication: True
- Require proper authorization: Review must belong to the current user
- Request
- Method: DELETE
- URL: /api/restaurants/:restaurantId/reviews/:reviewId
- Body: None
- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Successfully deleted”,
“statusCode”: 200
}- Error Response: Couldn’t find a Review with specified id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Restaurant couldn’t be found”
“statusCode”: 404
}