shared-housing
shared-housing copied to clipboard
Create REST API for housing location resource
Overview
Create a REST API handling add, update and retrieval operations on the housing location resource.
Action Items
Add HTTP stubs to server source code
-
Retrieve all locations
- method: GET
- route: /api/locations
- accepts: any
- returns: JSON array of HousingLocation objects (described below)
-
Retrieve location information by ID
- method: GET
- route: /api/locations/{locationId}
- accepts: A location ID (assume integer or uuid, TBD)
- returns: A HousingLocation object
-
Add location
- method: POST
- route: /api/locations
- accepts: JSON payload containing HousingLocation object
- returns: HTTP response with status 200, 400 or 500 depending on result of operation
-
Update location information by ID
- method: PUT
- route: /api/locations/{locationId}
- accepts: JSON payload containing HousingLocation object
- returns: HTTP response with status 200, 400 or 500 depending on result of operation
-
(Extra) Update location information attribute by location ID
- method: PATCH
- route: /api/locations/{locationId}
- accepts: JSON Patch payload for a HousingLocation object
- returns: HTTP response with status 200, 400 or 500 depending on result of operation
Resources/Instructions
- Use or improve upon the following data model for the JSON payload:
HousingLocation:
locationId: integer
latitude: float
longitude: float
housingTypeId: integer
bedsAvailable: integer
- Make use of Flask's declarative route definition syntax to specify URIs