Skip to content

Latest commit

 

History

History
478 lines (327 loc) · 15 KB

API.md

File metadata and controls

478 lines (327 loc) · 15 KB

Rideshare Endpoints

User Handling

POST /user/create (Create a new user's entry in the DB)
Body
Name Required Data Type Description
name yes string Name of the user
phNo yes number Phone number of the user
email yes string Email of the user
Response
HTTP Code Response
201 {"message": "Created user."}
400 {"message": "Email or Phone Number already exists."}
500 {"message": "Internal Server Error!"}
POST /user/login (Login a user)
Body
Name Required Data Type Description
token yes string User's google idToken
deviceToken yes string User's device FCM Token
Response
HTTP Code Response
200 {"message": "Logged in user.", "token": "xyz"}
404 {"message": "User not found in the DB."}
500 {"message": "Internal Server Error!"}
PUT /user/update (Update the user's details)
Auth

Bearer JWT Token

Body
Name Required Data Type Description
name no string Name of the user
phNo no number Phone number of the user
batch no number Year of admission of the user
Response
HTTP Code Response
200 {"message": "Updated user."}
400 {"message": "Email or Phone Number already exists."}
404 {"message": "User not found in the DB."}
500 {"message": "Internal Server Error!"}
GET /user/find/{email} (Get the user details of self)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
email yes string Email of self
Response
HTTP Code Response
200 {"message": "Found user.", "name": "John Doe", "email": "doe@gmail.com", phNo: 9999999999, batch: 2021, rides: [...], rideRequests: [...]}
404 {"message": "User not found in the DB."}
500 {"message": "Internal Server Error!"}
GET /user/find/{email} (Get the details of a different user)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
email yes string Email of another user
Response
HTTP Code Response
200 {"message": "Found user.", "name": "John Doe", "email": "doe@gmail.com", phNo: 9999999999, batch: 2021, rides: [...]}
404 {"message": "User not found in the DB."}
500 {"message": "Internal Server Error!"}

Ride Handling

POST /ride/create (Post a ride)
Auth

Bearer JWT Token

Body
Name Required Data Type Description
fromPlace yes number Enum of the place leaving from
toPlace yes number Enum of the place arriving at
seats yes number Number of seats available for other users to join
timeRangeStart yes string "YYYY-MM-DD hh:mm:ss"-formatted timestamp of the start of the time range for departure
timeRangeStop yes string "YYYY-MM-DD hh:mm:ss"-formatted timestamp of the end of the time range for departure
description no string Optional caption to the post
Response
HTTP Code Response
201 {"message": "Posted ride.", "id": "xyz"}
403 {"message": "User not found in the DB."}
500 {"message": "Internal Server Error!"}
PUT /ride/update/{id} (Update the ride's details)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Body
Name Required Data Type Description
fromPlace no number Enum of the place leaving from
toPlace no number Enum of the place arriving at
seats no number Number of seats available for other users to join
timeRangeStart no string "YYYY-MM-DD hh:mm:ss"-formatted timestamp of the start of the time slot
timeRangeStop no string "YYYY-MM-DD hh:mm:ss"-formatted timestamp of the end of the time slot
description no string Optional caption to the post
Response
HTTP Code Response
200 {"message": "Updated ride."}
401 {"message": "Unauthorized to edit this ride."}
403 {"message": "Ride not found in the DB."}
403 {"message": "User not found in the DB."}
500 {"message": "Internal Server Error!"}
GET `/ride/find/{id}` (Fetch the details of a particular ride posted by self)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Response
HTTP Code Response
200 {"message": "Fetched ride.", "id": "xyz", , "originalPoster": {...}, "fromPlace": x, "toPlace": y, "seats": z, "timeRangeStart": x, "timeRangeStop": y, "participants": [...], "participantQueue": [...], "status": true, "createdAt": "YYYY-MM-DD hh:mm:ss", "updatedAt": "YYYY-MM-DD hh:mm:ss", "description": "xyz"}
403 {"message": "Ride not found in the DB."}
500 {"message": "Internal Server Error!"}
GET `/ride/find/{id}` (Fetch the details of a particular ride posted by another user)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Response
HTTP Code Response
200 {"message": "Fetched ride.", "id": "xyz", , "originalPoster": {...}, "fromPlace": x, "toPlace": y, "seats": z, "timeRangeStart": x, "timeRangeStop": y, "participants": [...], "status": true, "createdAt": "YYYY-MM-DD hh:mm:ss", "updatedAt": "YYYY-MM-DD hh:mm:ss", "description": "xyz"}
403 {"message": "Ride not found in the DB."}
500 {"message": "Internal Server Error!"}
GET /ride/search? (Search for posts with filters)
Auth

Bearer JWT Token

Query Parameters
Name Required Data Type Description
fromPlace no number Enum of the place leaving from
toPlace no number Enum of the place arriving at
startTime no string "YYYY-MM-DD hh:mm:ss"-formatted timestamp of the start of a time range to search within
endTime no string "YYYY-MM-DD hh:mm:ss"-formatted timestamp of the end of a time range to search within
availableSeats no number Render only those rides with atleast this many free seats
startAtRide no number Starting index for pagination (inclusive)
endAtRide no number Ending index for pagination (inclusive)
orderBy no number 1 returns rides sorted by time of posting, 2 returns rides sorted by time of departure, 3 returns rides sorted by number of seats available. Use the corresponding negative numbers for descending order
Response
HTTP Code Response
200 {"message": "Fetched rides.", "rides": [...]}
500 {"message": "Internal Server Error!"}
DELETE /ride/delete/{id} (Delete a ride you posted)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Response
HTTP Code Response
200 {"message": "Deleted ride."}
401 {"message": "Unauthorized to delete this ride."}
404 {"message": "Ride not found in the DB."}
500 {"message": "Internal Server Error!"}
DELETE /ride/kick/{id} (Remove self from a ride you were accepted into)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Body
Name Required Data Type Description
email yes email email of self
Response
HTTP Code Response
200 {"message": "Removed from ride participants."}
400 {"message": "User has not been accepted into this ride."}
400 {"message": "Cannot kick user from his own ride."}
403 {"message": "Unauthorized to kick users from this ride."}
404 {"message": "Ride not found in the DB."}
500 {"message": "Internal Server Error!"}
DELETE /ride/kick/{id} (Kick a participant out of a ride you created after accepting the user)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Body
Name Required Data Type Description
email yes email email of the user being kicked
Response
HTTP Code Response
200 {"message": "Removed from ride participants."}
400 {"message": "User has not been accepted into this ride."}
400 {"message": "Cannot kick user from his own ride."}
403 {"message": "Unauthorized to kick users from this ride."}
404 {"message": "Ride not found in the DB."}
500 {"message": "Internal Server Error!"}

Request Handling

GET /ride/join/{id} (Make a request to join another user's ride)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Response
HTTP Code Response
200 {"message": "Requested to join this ride."}
400 {"message": "Cannot request to join your own ride."}
400 {"message": "User has already requested to join this ride."}
400 {"message": "User has already been accepted into this ride."}
404 {"message": "User not found in the DB."}
404 {"message": "Ride not found in the DB."}
405 {"message": "Ride is full."}
500 {"message": "Internal Server Error!"}
POST /ride/accept/{id} (Accept another user's request to join your ride)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Body
Name Required Data Type Description
email yes email email of the user being accepted
Response
HTTP Code Response
200 {"message": "Accepted into this ride."}
401 {"message": "Unauthorized to accept users into this ride."}
404 {"message": "User has not requested to join this ride."}
404 {"message": "Ride not found in the DB."}
405 {"message": "Ride is full."}
500 {"message": "Internal Server Error!"}
DELETE /ride/remove/{id} (Decline another user's request to join your ride)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Body
Name Required Data Type Description
email yes email email of the user being declined
Response
HTTP Code Response
200 {"message": "Removed from request queue."}
400 {"message": "Cannot remove user from his own ride."}
400 {"message": "User has not requested to join this ride."}
403 {"message": "Unauthorized to remove users from this ride."}
404 {"message": "Ride not found in the DB."}
500 {"message": "Internal Server Error!"}
DELETE /ride/remove/{id} (Withdraw a request made by you to another user's ride)
Auth

Bearer JWT Token

Parameters
Name Required Data Type Description
id yes string ID of the ride
Body
Name Required Data Type Description
email yes email email of self
Response
HTTP Code Response
200 {"message": "Removed from request queue."}
400 {"message": "Cannot remove user from his own ride."}
400 {"message": "User has not requested to join this ride."}
403 {"message": "Unauthorized to remove users from this ride."}
404 {"message": "Ride not found in the DB."}
500 {"message": "Internal Server Error!"}