A simple transit card server that can store rides and passes for multiple unique users
1.1K
The commands below detail the usage of this container assuming you have docker installed. By default, the Transit Server is hosted at 127.0.0.1 on port 8081, but this can be configured by replacing either the IP or port values in the spin-up command below.
docker run --name "transit_server" -p 127.0.0.1:8081:8099 lyanthropos/hw1_api
docker stop transit_server
docker start transit_server
docker rm tranist_server
The transit server allows a developer to create and track multiple users ride cards. Each card is associated with a unique userId which is required for all transactions. This id can be obtained when creating a new user.
Note: The responsibility of tracking these ids is left to the developer. Losing an id means losing access to the linked record.
All new users start with zero rides and a without a pass. Rides can be added and removed, whiles passes are a permanent activation. Detailed in the next section are each of the actions that can be taken for an account.
Each of these actions can be performed by sending the specified request to 127.0.0.1:8099 with the matching query parameters or JSON body
Creates a new user in the transit server. The value of the userId field in the response JSON should be saved as it is required for all interactions with that user's account.
/account/addUserPOST{ "name": "<name>"}{"userId": "<userId>"}Returns the status of the user's card, consisting of name, available rides, pass status, and a log of all executed transactions.
/account/getStatusGETuserId=<userId>{"name": "<name>", "rides":"<number of remaining rides>", "pass":"<boolean if pass is active>","transactions":"<array of transactions>"}Add a ride to a user's card.
/account/addRidePOST{ "userId": "<userId>"}{"success": "<boolean>", "rides": "<number of remaining rides>"}Remove a ride from a user's card. Will error if a user has 0 rides remaining.
/account/removeRidePOST{ "userId": "<userId>"}{"success": "<boolean>", "rides": "<number of remaining rides>"}Activates the infinite transit pass for a user's card.
/account/addPassPOST{ "userId": "<userId>"}{"success": "<boolean>"}Content type
Image
Digest
Size
52.6 MB
Last updated
over 4 years ago
docker pull lyanthropos/hw1_api