RESTful API with Replicants and Blade Runners resources, as well as a Retirements resource. This API is designed for the LAPD to keep track of Replicants and tracking Blade Runners' retirements thereof.
When a new Replicant is discovered, or found to be in violation and in need of retirement, send a POST request to the /replicants resource with the following information:
- Name (if known)
- Serial number
- Model
- Incept Date
- Manufacturer
- Purpose (if known)
Name and purpose fields are optional; all others are required. This will create a new Replicant in the database with an assigned ID number. The replicant is assumed to not be retired, so retired: false and retiredBy: null default values are set.
Replicant Routes
- GET /replicants - returns a list of all replicants in the database
- POST /replicants - add a new replicant to the database
- GET /replicants/:id - returns an individual replicant, based on id (uuid v4)
- PUT /replicants/:id - updates a replicant based on id - all fields are required
- DELETE /replicants/:id - deletes a replicant based on id.
Replicant Schema:
{
id,
name,
model,
serial,
manufacturer,
inceptDate,
retired = false
retiredDate = null
}
Blade Runners are tracked along with a list of their individual retirements. When a new Blade Runner is hired, send a POST request to the /bladerunners route with their name, species, and employer. This will return the newly created Blade Runner object with a UUID as well as an array of retired Replicants (which is empty).
Blade Runner Routes
- GET /bladerunners - returns all known Blade Runners
- POST /bladerunners - add a new Blade Runner
- GET /bladerunners/:id - get an individual Blade Runner, based on id
- PUT /bladerunners/:id - updates a Blade Runner based on id - all fields are required
- DELETE /bladerunners/:id - deletes a Blade Runner based on id.
Blade Runner Schema:
{
id,
name,
species,
employer,
retired: [
'id'
]
}
When a Blade Runner completes a mission, update the database by sending a POST request to: /bladerunners/:id/retirements with the Replicant's ID number and the date of the retirement.
- POST /bladerunners/:id/retirements - adds a new Retirement resource to the given Blade Runner.
- Schema for request body:
{
"id": Replicant ID
"retiredOn": date
}
This creates a new retirement:
{
id (retirementId)
replicantId
bladeRunnerId
retirementDate
}
This also updates the associated Replicant record with retiredOn date and retiredBy Blade Runner ID:
{
retired: true,
retiredBy: bladerunnerId
}
as well as adding the Replicant ID to the Blade Runner retired [] array.
This POST request returns the new Retirement object:
{
data: {
retirement: {
id,
replicantId,
bladeRunnerId,
date
}
}
}
Other Retirements routes:
- GET /bladerunners/:id/retirements - retrieve a list of all replicants retired by a given Blade Runner
- GET /bladerunners/:id/retirements/:retirementId - retrieve information for a particular retirement
- PUT /bladerunners/:id/retirements/:retirementId - update information for given retirement; all fields are required
- DELETE /bladerunners/:id/retirements/:retirementId - should not be used as a rule, but exists in case incorrect information is given, or a replicant is thought retired but is in fact not retired