Skip to content

Latest commit

 

History

History
80 lines (72 loc) · 3.16 KB

README.md

File metadata and controls

80 lines (72 loc) · 3.16 KB

ireporter-challenge-2

A simple api endpoints to the Andela iReporter

Coverage Status Build Status Maintainability

Overview

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

Heroku

An online version of the api is available at https://andelaireporterapp.herokuapp.com/
Feel free to check it out at your own convenience

Endpoints description

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
}

Installation guidelines

(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

Running the tests

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

Contributors