https://zomsystem.herokuapp.com/
TECH STACK
Python, Django(Framework), SQLite database, Heroku (for deployment)
● An endpoint to book a ticket using a user’s name, phone number, and timings.
● An endpoint to update a ticket timing.
● An endpoint to view all the tickets for a particular time.
● An endpoint to delete a particular ticket.
● An endpoint to view the user’s details based on the ticket id.
● Mark a ticket as expired if there is a difference of 8 hours between the ticket timing
and current time.
● All the tickets which are expired automatically deleted.
● For a particular timing, a maximum of 20 tickets can be booked.
● REST paradigm implemented.
● SQLite database used.
● POSTMAN snaps of all APIs attached in README.
Field Name | Description |
---|---|
unique_id | Unique customer ID |
index | Number of records (auto incremented) |
name | Customer's name |
time | Start time of movie |
phone number | Customer's phone number |
created_at | Time when ticket is created (automatically attached) |
Time should be in format dd/MM/yyyy HH:mm:ss
https://zomsystem.herokuapp.com/showallrecords
This is the start state when there are no records. Purpose of /showallrecords is to display all
records to infer changes made using APIs.
GET REQUEST : https://zomsystem.herokuapp.com/addRecord?uniqueid=UNIQUE_ID_OF_NEW_RECORD&nm=NAME&phonenumber=PHONENUMBER&time= dd/MM/yyyy HH:mm:ss
This accepts a ‘unique_id’, ‘Name’, ‘Phone number’ and ‘time’ for which ticket is to be booked, a
‘created_at’ entry is automatically stored in database which stores the time when request to add a
new record is generated
Showing all records : https://zomsystem.herokuapp.com/showallrecords
All records are displayed to denote the insertion of a record.
POST REQUEST :
import requests
files = {'upload_file': open('one.txt','rb')}
r = requests.post("https://zomsystem.herokuapp.com/automated_testing",files=files)
# 'one.txt' is Text File containing records.
We can send an automated POST request to the end point with a .txt file which contains records as
shown to add multiple records at a time easily through a POST request.
Showing all inserted records using POST: https://zomsystem.herokuapp.com/showallrecords
Shown here are multiple inserted records using automated POST request.
GET API ensures that for a particular timing, a maximum of 20 tickets can be booked.
An instance is shown through POSTMAN, that when records exceed 20 for a particular time they are rejected.
https://zomsystem.herokuapp.com/updatetime?oldtime=PREVIOUS_OLD_TIME&newtime=UPDATED_TIME
Here shown the endpoint that accepts a previous time and updated time, to update time entry.
If the matching query is not found then an error message is returned by API.
Showing all records: https://zomsystem.herokuapp.com/showallrecords
Shown all records after updating
https://zomsystem.herokuapp.com/listall?query=PARTICULAR_TIME
This is the instance that shows information of tickets booked for a particular time.
https://zomsystem.herokuapp.com/deleteticket?query=UNIQUEID_OF_TICKET_TO_BE_DELETED
Endpoint to delete a particular ticket that accepts unique id of ticket to be deleted
If the matching query is not found then an error message is returned by API.
https://zomsystem.herokuapp.com/ticketinfo?query=TICKETID
Shown here the example, that is used to view users’ detail for a ticket id.
Mark a ticket as expired if there is a difference of 8 hours between the ticket timing and current time.
Since, there is difference of 8 hours between present and other time (the one added here),
it will be deleted automatically. For automatic deletion, a function is called when every
endpoint is executed (API is called) which checks time of every ticket entity and deletes
the record which has difference greater than equal to 8 hours.
In this example:
a. A request is made to add a new record that has a longer difference than 8 hours
b. From postman it is clear that record is added successfully
c. However, a function is invoked automatically in all the endpoints that automatically deletes
entries with difference greater than 8 hours.
Snapshot of function invoked in endpoints to automate deletions.