Running the app
Run the app:
docker compose up
The API documentation is available at http://127.0.0.1:8000/docs.
Prerequisites:
- Python 3.10 or later
Setting up the environment:
Create a virtual environment:
python3 -m venv venv
Activate the virtual environment:
-
Linux / MacOS:
source .venv/bin/activate
Install the dependencies:
pip install -r dev-requirements.txt
Running the app:
uvicorn app.main:app
The API documentation is available at http://127.0.0.1:8000/docs.
Tests
pytest
URL | Method | Functionality |
---|---|---|
api/v1/fees/calculate_fee |
POST |
Calculate the delivery fee |
-
-
Example request:
Request body:
{ "cart_value": 790, "delivery_distance": 2235, "number_of_items": 4, "time": "2024-01-15T13:00:00Z" }
Using curl:
curl -X "POST" \ "http://127.0.0.1:8000/api/v1/fees/calculate_fee" \ -H "accept: application/json" \ -H "Content-Type: application/json" \ -d "{\"cart_value\": 790, \"delivery_distance\": 2235, \"number_of_items\": 4, \"time\": \"2024-01-15T13:00:00Z\"}"
Example response:
{"delivery_fee": 710}
-