This repository holds the API endpoints for politico application. Politico enables citizens give their mandate to politicians running for different government offices while building trust in the process through transparency.
Installation
- clone the git repo
$ git clone --branch develop https://github.com/wainainad60/politico-api.git
- cd into the project directory
$ cd politico-api
- create the virtual environment and activate it
(Linux and Mac OS X)
$ python3 -m venv env
$ source env/bin/activate
(Windows)
> python -m venv env
> env\Scripts\activate
- install dependencies
$ pip install -r requirements.txt
- set the enviroment settings
FLASK_APP="run.py"
SECRET="jwt-secret-string"
APP_SETTINGS='development'
DATABASE_URL="your db url"
TEST_DATABASE_URL="your test db url"
- Run the app
$ flask run
On your terminal execute the following command
$ pytest --cov=api -v
Use any API Test Client of choice
I used Postman, get it here => Postman
API Endpoint | Function | URL Route |
---|---|---|
POST /auth/signup | Allows a user to signup | api/v2/auth/signin |
POST /auth/login | Allows a user to login | api/v2/auth/login |
POST /auth/reset | Allows a user to reset password | api/v2/auth/reset |
POST /offices | Create a political office. | /api/v2/offices/ |
GET /offices/<office-id> |
Get a specific political office record | api/v2/offices/<int:office_id> |
GET /offices | Gets all political offices records | api/v2/offices/ |
DELETE /offices/<office-id> |
Delete a political office | /api/v2/offices/<int:office-id> |
PATCH /offices/<office-id> /name |
Edit the name of a specific political office. | /api/v2/offices/<int:office-id>/name |
POST /parties | Creates a political party | /api/v2/parties/ |
DELETE /parties/<party-id> |
Delete a political party | /api/v2/parties/<int:party-id> |
PATCH /parties/<party-id> /name |
Edit the name of a specific political party. | /api/v2/parties/<int:party-id>/name |
GET /parties | Gets all political parties | /api/v2/parties/ |
GET /parties/<int:party-id> |
Gets a specific political party | /api/v2/parties/<int:party_id> |
POST /office/1/register | Registers a candidate to a political office. | /api/v2/offices/<int:office-id>/register |
POST /votes/ | Votes for a candidate. | /api/v2/votes/ |
GET /office/1/result | View the votes results of an office. | /api/v2/offices/<int:office-id>/result |
POST /petitions/ | Create a petition. | /api/v2/petitions/ |
API Endpoint | Function | URL Route |
---|---|---|
GET /offices | Get a specific political office record | api/v1/offices/<int:office_id> |
GET /offices | Gets all political offices records | api/v1/offices/ |
POST /offices | Create a political office. | /api/v1/offices/ |
POST /parties | Creates a political party | /api/v1/parties/ |
DELETE /parties/<party-id> |
Delete a political party | /api/v1/parties/<int:party-id> |
PATCH /parties/<party-id> /name |
Edit the name of a specific political party. | /api/v1/parties/<int:party-id>/name |
GET /parties | Gets all political parties | /api/v1/parties/ |
GET /parties/<int:party-id> |
Gets a specific political party | /api/v1/parties/<int:party_id> |
Wainaina Gichuhi, wainainad60 @pcf26535