REST API Endpoints - SE750-Group14-GirlGang/roadtrip-planner GitHub Wiki
Summary
/api/roadtrip
- GET, POST
/api/roadtrip/:id
- GET
/api/roadtrip/:id/isUserOrganiser
- GET
/api/roadtrip/:id/attendees
- GET, PATCH
/api/roadtrip/:id/emergencydetails
- GET, POST
/api/roadtrip/:id/emergencydetails/user
- GET, PUT
/api/roadtrip/:id/map
- GET, POST
/api/roadtrip/:id/packeditems/user
- GET, PUT
/api/roadtrip/:id/packinglist
- GET, PUT
/api/roadtrip/:id/spotify
- GET, PUT
/api/roadtrip/:roadTripId/itinerary/days/:dayId/events
- PATCH
Docs
/api/roadtrip
GET
Description
Returns all roadtrips that the user identified by the authorization token is organising and attending
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: "No authorization token was found" }
- Body:
500
Internal Server Error
Success Response
- Body: JSON object with the following format:
{ roadTripsOrganising: [...], roadTripsAttending: [...] }
POST
Description
Create a new roadtrip, with the organiser being the user identified by the authorization token
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ name: 'example name' }
Response Status
201
Created401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
400
Bad request500
Internal Server Error
Success Response
- Headers:
{ Location: '<roadtrip URI>' }
- Body: JSON roadtrip object
/api/roadtrip/:id
GET
Description
Returns the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: "No authorization token was found" }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body: JSON roadtrip object
/api/roadtrip/:id/isUserOrganiser
GET
Description
Returns if the user identified by the authorization token is the organiser for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: "No authorization token was found" }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body:
{ result: true/false }
/api/roadtrip/:id/attendees
GET
Description
Returns the list of attendees for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body: Array of JSON user objects
PATCH
Description
Add an attendee to the list of attendees for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ userEmail: '[email protected]' }
Response Status
200
OK401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
400
Bad request- Body:
{ message: 'This user is already an attendee' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
{ message: 'User not found' }
- Body:
500
Internal Server Error
Success Response
- Headers:
{ "Location": "<roadtrip URI>" }
- Body: JSON roadtrip object
/api/roadtrip/:id/emergencydetails
GET
Description
Returns the list of emergency detail objects for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body: Array of JSON emergency detail objects
/api/roadtrip/:id/emergencydetails/user
GET
Description
Returns the emergency details object for the user identified by the authorization token for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
{ message: 'Emergency details have not been created for this user' }
- Body:
500
Internal Server Error
Success Response
- Body: JSON emergency details object
PUT
Description
Adds an emergency details object for the user identified by the authorization token for the roadtrip with given id
If an emergency details object has already been created for this user, replace its contents with supplied data
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ name: 'example name', phoneNumber: '1111111', emergencyContact: {name: 'example name', phoneNumer: '0000000', relation: 'father'}
Response Status
201
Created401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Headers:
{ Location: "<emergency details for user URI>" }
- Body: JSON emergency details object
/api/roadtrip/:id/map
GET
Description
Returns the map object for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: "No authorization token was found" }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body: JSON map object
POST
Description
Create a map object for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ primaryDestination: { long: 1, lat: 2, name: "123 street" } }
Response Status
201
Created401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Headers:
{ Location: "<map object URI>" }
- Body: JSON map object
/api/roadtrip/:id/packeditems/user
GET
Description
Returns the packed items object for the user identified by the authorization token for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
{ message: 'Packed items have not been created for this user' }
- Body:
500
Internal Server Error
Success Response
- Body: JSON packed items object
PUT
Description
Adds a packed items object for the user identified by the authorization token for the roadtrip with given id
If a packed items object has already been created for this user, replace its contents with supplied data
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ items: ['item 1', 'item 2'] }
Response Status
201
Created401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Headers:
{ Location: "<packed items for user URI>" }
- Body: JSON packed items object
/api/roadtrip/:id/packinglist
GET
Description
Returns the packing list object for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: "No authorization token was found" }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body: JSON packing list object
PUT
Description
Create a packing list object for the roadtrip with given id
if it does not already exist
Or, if it does exist, replace its contents with supplied data
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ items: ['item 1', 'item 2'] }
Response Status
201
Created401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Headers:
{ Location: "<packing list object URI>" }
- Body: JSON packing list object
/api/roadtrip/:id/spotify
GET
Description
Returns the spotify object for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: "No authorization token was found" }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body: JSON spotify object
POST
Description
Create a spotify object for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ spotifyId: '12kudf' }
Response Status
201
Created401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Headers:
{ Location: "<spotify object URI>" }
- Body: JSON spotify object
/api/roadtrip/:id/itinerary
GET
Description
Returns the itinerary object for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
Response Status
200
OK401
Unauthorized- Body:
{ message: "No authorization token was found" }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Body: JSON itinerary object
POST
Description
Create a itinerary object for the roadtrip with given id
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ days: [<list of day objects>] }
Response Status
201
Created401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error
Success Response
- Headers:
{ Location: "<itinerary object URI>" }
- Body: JSON itinerary object
/api/roadtrip/:roadTripId/itinerary/days/:dayId/events
PATCH
Description
Add an event to the list of events for the itinerary for roadtrip with given roadTripId
for the day with given dayId
Request
- Headers:
{ Authorization: 'Bearer <user authorization token>' }
- Body:
{ event: { time: '10:20', location: 'bach', notes: 'bring your plate', description: 'brunch!' } }
Response Status
200
OK401
Unauthorized- Body:
{ message: 'No authorization token was found' }
- Body:
404
Not found- Body:
{ message: 'Roadtrip with this ID not found' }
- Body:
500
Internal Server Error