Set of API endpoints to be consumed by a courier service application
Set of API endpoints to be consumed by a courier service application
The API offers the following set of endpoints:
REQUEST | ROUTE | FUNCTIONALITY | PROTECTED |
---|---|---|---|
POST | /auth/signup | Register a user | NO |
POST | /auth/login | Login a user | NO |
POST | /parcels | Create a parcel delivery order | YES |
GET | /parcels | Fetch all parcel delivery orders | YES |
GET | /parcels/[parcelId] | Fetch a specific parcel delivery order | YES |
GET | /users/[userId]/parcels | Fetch all parcel delivery orders by a specific user | YES |
PUT | /parcels/[parcelId]/destination | Change the destination of a specific parcel delivery order | YES |
PUT | /parcels/[parcelId]/present_location | Change the present location of a specific parcel delivery order | YES |
PUT | /parcels/[parcelId]/status | Change the status of a specific parcel delivery order | YES |
GET | /users | Fetch all registered users | YES |
These instructions will get you a copy of the program on your local machine for development and testing purposes. The instructions are tailored for uses of LINUX OS
particularly UBUNTU
What things you will need to run the application
Python3
version: 3.6
Pip for python3
$ sudo apt-get install python3-pip
Flask to build the application
version: 1.0.2
$ pip install flask
Virtualenv to create a virtual environment
version: 16.0.0
Pytest to perform tests
version: 3.9.1
$ pip install pytest -U
Alternatively, run pip install -r requirements.txt
to install all the necessary tools
To have a copy of the project on your machine, run the command below in your preferred directory:
git clone https://github.com/dxania/Send_IT_APIs.git
After cloning, you will have a folder named Send_IT_APIs
Send_IT_APIs
python3 -m venv <name of virtualenvironment>
source <name of virtualenvironment>/bin/activate
DATABASE_URL=$(heroku config:get DATABASE_URL -a send-it-api-app)
export FLASK_APP=app.py
thenflask run
pytest
or pytest tests/<test_file_name>
in the directory of the project to run unit testsEndpoint /api/v1/auth/signup
Input
{
"user_name":"Dee",
"email": "[email protected]",
"password":"warmups"
}
Output
{"message":"User Dee successfully created"}
Endpoint /api/v1/auth/login
Input
{
"user_name":"Dee",
"password":"warmups"
}
Output
{
"access_token" : some access token,
"message":"You have sucessfully been logged in as Dee"
}
Endpoint /api/v1/parcels
Input
{
"recipient_name":"leonne",
"recipient_mobile": 1234567890,
"pickup_location":"Entebbe",
"destination":"Mombasa",
"weight": 900
}
Output
{"message":"Parcel successfully created"}
Endpoint /api/v1/parcels/1
Output
{
"parcel": {
"created_by": "Dee",
"destination": "Mombasa",
"parcel_id": 1,
"pickup_location": "Entebbe",
"present_location": "Entebbe",
"recipient_mobile": "1234567890",
"recipient_name": "leonne",
"status": "pending",
"total_price": 100000,
"weight": 900
}
}
Endpoint /api/v1/parcels/1/destination
Input
{"destination":"Nairobi"}
Output
{"message":"Destination of parcel 1 changed to Nairobi"}
Deployed on heroku