A simple api endpoints to the Andela iReporter
Corruption is a huge bane to Africa’s development. African countries must develop novel and localised solutions that will curb this menace, hence the birth of iReporter. iReporter enables any/every citizen to bring any form of corruption to the notice of appropriate authorities and the general public. Users can also report on things that needs government intervention.
The Api servers to create, edit, patch, retrive and delete redflag records
An online version of the api is available at https://andelaireporterapp.herokuapp.com/
Feel free to check it out at your own convenience
Endpoint | Role |
---|---|
GET /api/v1/red-flags | Retrieves all red-flag records in the database |
GET /api/v1/red-flags/<red_flag_id> | Retrieves a red-flag specified by its id |
POST /api/v1/red-flags | Adds a red-flag to the database |
PATCH /api/v1/red-flags/<red_flag_id>/location | Edits the location of a specified red-flag |
PATCH /api/v1/red-flags/<red_flag_id>/comment | Edits a the comment of a specific red-flag |
DELETE /api/v1/red-flags/<red_flag_id> | Deletes a red-flag specified by Id |
Note that all API endpoints use json formatted data. An example is given below for the POST endpoint:
{
"location": {"lat": "0.96", "long": "1.23"},
"type": "red-flag",
"comment": "I am the greatest"
}
The request above will return the following json data:
{
"data": [
{
"id": 7278781,
"message": "Created red-flag record"
}
],
"status": 201
}
(I've not seen an installation this easy)
- Clone this repo onto your machine
- Make sure to install python3 and postman(to test the endpoints)
- Navigate to the repository route and creata a virtual environment
$ cd ireporter-challenge-2
$ python3 -m venv venv
- Activate the virtual environment and install dependencies in the requirements.txt file
$ . venv/bin/activate
$ pip install -r requirements.txt
- Fire Up the API
$ flask run
- Play around with the API
The api tests are run with pytest
To run the tests simply run the following commands while in the project root
$ python -m pytest
To run the tests with coverage, run:
$ python -m pytest --cov
- v1b3m - vibenjamin6@gmail.com