A system to share resources between non-infected humans on a zombie apocalyptic scenario.
Python3
Pip
Python virtualenv
Django
Django Rest Framework
Activate your virtual environment before proceeding with the installation.
To install the requirements:
make setup
or
pip install -r requirements.txt
To do database migrations:
make migrate
To run the tests:
make test
To run the Rest API:
make run
or
./manage.py runserver
Access in: http://127.0.0.1:8000/
The REST API to the ZSSN is described below.
- GET:
/
- API root - GET/POST:
/survivors
- List all survivors / Add survivors - GET:
/survivors/<id>
- Get survivor - GET/PATCH:
/survivors/<id>/last-location
- Update survivor location - GET/PATCH:
/survivors/<id-reporter>/report-infected/<id-reported>
- Flag survivor as infected - GET/PATCH:
/survivors/<id-survivor-1>/trade-items/<id-survivor-2>
- Trade items between non infected survivors - GET:
/survivors/reports
- Get reports
- GET:
/survivors
- POST:
/survivors/
Paramether | Description | Type |
---|---|---|
name | Survivor name | string |
age | Survivor age | number |
gender | Survivor gender | string |
last_location | Last location of survivor (latitude and longitude) | {latitude: string, longitude: string} |
items | Items of survivor | array of objects |
items__name | Item name | string |
items__points | Item points | number |
items__quantity | Item quantity | number |
JSON example:
{
"name": "Ana Paula",
"age": 22,
"gender": "F",
"last_location": {
"latitude": "51.522906000000000000000000000000",
"longitude": "11.411560000000000000000000000000"
},
"inventory": {
"items": [
{
"name": "Water",
"points": 4,
"quantity": 10
},
{
"name": "Food",
"points": 3,
"quantity": 5
},
{
"name": "Medication",
"points": 2,
"quantity": 8
},
{
"name": "Ammunition",
"points": 1,
"quantity": 15
}
]
},
"infected": false,
"reported_infected": 0
}
It's forbidden to register zombies!
- GET:
/survivors/<id>
<id> is the identifier of the survivor.
- GET/PATCH:
/survivors/<id>/last-location
<id> is the identifier of the survivor.
Paramether | Description | Type |
---|---|---|
latitude | New survivor latitude | string |
longitude | New survivor longitude | string |
JSON example:
{
"latitude": "52.522906000000000000000000000000",
"longitude": "10.411560000000000000000000000000"
}
- GET/PATCH:
/survivors/<id-reporter>/report-infected/<id-reported>
<id-reporter> is the identifier of the reporter
<id-reported> is the identifier of the reported
Paramether | Description | Type |
---|---|---|
infected | User is infected | bool |
JSON example:
{
"infected": true
}
It'll have "infected": true in GET when reported_infected >= 3.
- GET/PATCH:
/survivors/<id-survivor-1>/trade-items/<id-survivor-2>
<id-survivor-1> is the identifier of the survivor 1
<id-survivor-2> is the identifier of the survivor 2
Paramether | Description | Type |
---|---|---|
id | Survivor identifier | number |
survivor_1 | Survivor 1 | object |
trade_item | Trade item | object |
survivor_2 | Survivor 2 | object |
JSON example:
[
{
"id": 1,
"survivor_1": {
"trade_item": {
"Water": 1,
"Medication": 1
}
}
},
{
"id": 3,
"survivor_2": {
"trade_item": {
"Food": 1,
"Ammunition": 3
}
}
}
]
Observations:
It's important to keep in order according to the exchange of items you want between them.
- GET:
/survivors/reports
The API will offer the following reports:
- Percentage of infected survivors.
- Percentage of non-infected survivors.
- Average amount of each kind of resource by survivor (e.g. 5 waters per survivor)
- Points lost because of infected survivor.