A REST API interface for booking tickets
- A maximum of 20 tickets can be booked.
- A ticket is marked expired if there is a difference of 8 hours or more between the ticket timing and current time.
- A user can book more than 1 seat and has to provide the seat numbers too.
pip install -r requirements.txt
export FLASK_APP=ticket.py
flask run
{
"ticketID" : 1,
"name" : "XYZ",
"phn" : 1234567890,
"time" : "15:00",
"date" : "2020-09-01",
"tickets" : 2,
"seats" : ["A1","A2"]
}
ticketID : It's a primary key assigned to each booking
name : Name of the user who is booking the ticket
phn : Phone Number of the user
time : Time slot of the movie
date : Date for which the user wants to book the seats
tickets : Number of tickets the user is booking
seats : Seat numbers the user wishes to book
GET Request ===> http://127.0.0.1:5000/ ===> {'msg' : 'Welcome to Ticket Booking System', 'status' : 200}
Initial Call to the API
POST Request ===> http://127.0.0.1:5000/book ===> {'msg' : 'Booked successfully', 'status' : 200}
To book a Ticket the user provides name, phone number, time, date, number of tickets to be booked and seat numbers. After which a ticket ID is alloted to the user. If an exception is raised the API returns with status code 400
GET Request ===> http://127.0.0.1:5000/view/<ticket_id> ===> {'info' : ticketInfo, 'status' : 200}
To view a ticket information for the given ticket ID. If an exception is raised the API returns with status code 500
GET Request ===> http://127.0.0.1:5000/view ===> {'AllTickets' : data, 'status' : 200}
To view All the tickets at a particular time. If an exception is raised the API returns with status code 500
PUT/PATCH Request ===> http://127.0.0.1:5000/update ===> {'msg' : 'Updated successfully', 'status' : 200}
To update the time of a booked ticket. If an exception is raised the API returns with status code 500.
DELETE Request ===> http://127.0.0.1:5000/delete/ ===> {'msg' : 'Deleted successfully', 'status' : 200}
To delete a ticket for a given user name. If an exception is raised the API returns with status code 500.
Expired Tickets Handling
To mark the expired tickets a background scheduling is done.