Пример #1
0
    def new_booking(self, user_id, rest_id, number_of_people, booking_datetime):

        """ Add a new booking.

        POST /bookings
        
        Returns the booking if it can be made, otherwise returns an error message.

        Requires a json object with:
            - number_of_people: the number of people for the booking
            - booking_datetime: the datetime of the booking
            - user_id: the id of the user who made the booking
            - restaurant_id: the id of the restaurant

        Status Codes:
            201 - The booking has been created
            400 - Wrong datetime
            409 - Impossible to change the booking (it is full, it is closed ...)
            500 - Error in communicating with the restaurant service or problem with the database (try again)
        """

        booking = {
            "user_id": user_id,
            "restaurant_id": rest_id,
            "number_of_people": number_of_people,
            "booking_datetime": booking_datetime,
        }

        return post(self.addr + "/bookings", booking)
Пример #2
0
 def create_user(self, userdata):
     return post(url= self.addr + '/users', json=userdata)
Пример #3
0
 def post_restaurant_rate(self, rest_id, rater_id,rating):
     return post(f"{self.addr}/restaurants/{rest_id}/rate", json={"rater_id":rater_id, "rating":rating })        
Пример #4
0
 def post_restaurants_tables(self, rest_id, capacity):
     url = f"{self.addr}/restaurants/{rest_id}/tables"
     return post(url, json={"capacity": capacity})
Пример #5
0
 def post_restaurants(self, json):
     return post(f"{self.addr}/restaurants", json=json)