##Status Codes
Status Code | Description |
---|---|
200 | OK |
201 | CREATED |
400 | BAD REQUEST |
404 | NOT FOUND |
##API endpoints ####Connect to API
POST: http://localhost:9090/api>
####Create new User
POST: http://localhost:9090/api/users
#####Request
{ “nic”: “{nic}”, “mobile”: “+94778976377” }
#####Response
400 Bad Request
If mobile no is not set { "message": "Mobile no is not set", "developerMessage": " User creation failed because the mobile no is not set" } If nic no is not set { "message": "Nic no is not set", "developerMessage": " User creation failed because the nic no is not set" }
####Create new Vehicle
POST: http://localhost:9090/api/vehicles
#####Response Status 201
{ “self”: “http://localhost:9090/api/vehicles/{vehicle_id}”, “vehicle_number”: “{vehicle_number} ” }
400 Bad Request If the vehicle no is invalid or if vehicle no is not set. Status 409 If a vehicle with that number already exists.
{ "message": "A vehicle with vehicle_number: {vehicle_number} already exists", "developerMessage": "Vehicle creation failed because the vehicle_number: {vehicle_number} already exists", }
####Return all available vehicles
GET: http://localhost:9090/api/vehicles
#####Response Status 200
{ “vehicles”: [ { “self”: “http://localhost:9090/api/vehicles/{vehicle_id}”, “id”: “{id}”, “vehicle_number”: “{vehicle_number}” }, … ] }
####Create new Officers
POST: http://localhost:9090/api/officers
#####Request
{ “employment_number”: “{employment_number}” } Or { “employment_number”: “{employment_number}”, "role": "admin" }
#####Response
Status 201
{ “self”: “http://localhost:9090/api/officers/{officer_id}”, “employment_number”:“{employment_number}”, "role": "employee" } Or { “self”: “http://localhost:9090/api/officers/{officer_id}”, “employment_number”: “{employment_number}”, "role": "admin" }
Status 409
{ "message": "Officer with employment_number: {employment_number} already exists", "developerMessage": "Officer creation failed because the employment_number: {employment_number} already exists" }
####Return all available employees
GET: http://localhost:9090/api/officers
#####Response
{ “officers”: [ { “self”: “http://localhost:9090/api/officers/{officer_id}”, “id”: “{id}”, “employment_number”: “{employment_number}”, "role": "{role}" }, … ]
####Create new Route
POST: http://localhost:9090/api/routes
#####Request
{ "route_name": "{route_name}" }
#####Response Status 201
{ "self": "http://localhost:9090/api/routes/{route_id}", "route_name": "{route_name}" }
Status 409
{ "message": "A route with route_name: {route_name} already exists", "developerMessage": "Route creation failed because the route_name: {route_name} already exists" }
####Return, all the available routes.
GET: http://localhost:9090/api/routes
#####Response
{ "routes": [ { "self": "http://localhost:9090/api/routes/{route_id}", "id": "{id}", "route_name": "{route}" }, … ] }
####Create newTime Table
POST: http://localhost:9090/api/timetables
Request
{ “start_time”: “11:30:00”, “end_time”: “14:30:00”, “day”: “Tuesday”, “officer_id”: “{officer_id}”, “vehicle_id”: “{vehicle_id}”, “route_id”: “{route_id}, }
#####Response Status 201
{ “self”: “http://localhost:9090/api/timetables/{timetable_id}”, “start_time”: “11:30:00”, “end_time”: “14:30:00”, “day”: “Tuesday”, “officer”: { “self”: “http://localhost:9090/api/officers/{officer_id}”, “employment_number”: “{employment_number}” ... }, “vehicle”: { “self”: “http://localhost:9090/api/vehicles/{vehicle_id}”, “vehicle_number”: “{vehicle_number} ” .. }, “route”: { “self”: “http://localhost:9090/api/routes/{route_id}”, “route_name”: “{route_name}” ... } }
**Status 400 ** Return if the vehicle_id or officer_id or route_id is not set
Status 404 If vehicle_id or officer_id or route_id not present to find.
{ "message": " No value present route_id: {route_id}", "developerMessage": "Timetable creation failed because no value present route_id: {route_id}" }
####Get time table by id number
GET: http://localhost:9090/api/timetables/{timetable_id}
#####Response
{ “self”: “http://localhost:9090/api/timetables/{timetable_id}”, “id”: “{id}”, “start_time”: “{start_time}”, “end_time”: “{end_time}”, “day”: “{day}”, “officer”: { “self”: “http://localhost:9090/api/officers/{officer_id}”, “employment_number”: “{employment_number}” ... }, “vehicle”: { “self”: “http://localhost:9090/api/vehicles/{vehicle_id}”, “vehicle_number”: “{vehicle_number} ” ... }, “route”: { “self”: “http://localhost:9090/api/routes/{route_id}”, “route_name”: “{route_name}” …. } }
Status 401 If the requested timetable was not found.
####Get All Timetables
GET: http://localhost:9090/api/timetables
#####Query parameters
Status Code | Description |
---|---|
vehicle_id={vehicle_id} | Query timetables by vehicle. |
officer_id={officer_id} | Query timetables by officers. |
route_id={route_id} | Query timetables by route. |
#####Response
{ “timetables”: [ { “self”: “http://localhost:9090/api/timetables/{timetable_id}”, “id”: “{id}”, “start_time”: “{start_time}”, “end_time”: “{end_time}”, “day”: “{day}”, “officer”: { “self”: “http://localhost:9090/api/officers/{officer_id}”, “employment_number”: “{employment_number}”, ... }, “vehicle”: { “self”: “http://localhost:9090/api/vehicles/{vehicle_id}”, “vehicle_number”: “{vehicle_number} ”, ... }, “route”: { “self”: “http://localhost:9090/api/routes/{route_id}”, “route_name”: “{route_name}”, .... } }, … ] }
####Best practices for culture and communication
- Adapt the language good for non-native english speakers
- Be super friendly
- Use a friendly tone when talking to each other
- Staying modest for new comers.
- Be nice and welcoming and show appreciation for the good work of the co-developers
- If you don't know something try to understand from public channels (stackoverflow, youtube)
- All pull requests are associated with one issue
- All pull-requests are assigned to the person who os working on it
- Larger issues must be divided down into samller issues
- Add the issue number to the description of the issue
- Write clear meaningful commit messages
- Squash the commit if there are very small changes in the code
- Must not push straight to the master
- Must not commit the code changes as an unidentified author
- Must not commit the dependancies to the git repository
- Create meaningful gitignore files
- Using a banch naming convention
####Coding best practices
- Code refactoring