Welcome to the Customer & Purchases API, a Django REST Framework-based application for managing customers and their purchase records.
This API provides endpoints for:
- Creating and listing customers
- Submitting and retrieving purchase data
- Customer: Represents a client in the system
- Purchase: Represents a transaction made by a customer
CustomerCreateListViewSet: Handles customer creation and listing
| Endpoint Type | URL |
|---|---|
| Base URL | https://yourhostname.com/v1/ |
| Production (Customer) | https://yourhostname.com/v1/customers/ |
| Local (Customer) | http://127.0.0.1:8000/v1/customers/ |
For testing locally, use the local endpoint.
-
Navigate to project directory
cd dutyfree_api/ -
Create and activate a virtual environment
python3 -m venv .venv source .venv/bin/activate # or .env/Scripts/activate on Windows
-
Install dependencies
pip install -r requirements.txt
-
Start the development server
cd src/dutyfree_api/ python manage.py runserver
python purchase_api_cli data/customers.csv data/purchases.csv "http://127.0.0.1:8000/v1/customers/"- Edit or use the existing file:
data/payload.json - Execute:
./post_json_payload.sh
All logs are saved in:
dutyfree_api/debug.log
Run unit tests using pytest:
cd dutyfree_api/src/dutyfree_api/
pytest testspython manage.py generate_purchases- All records:
python manage.py list_all - Customers:
python manage.py list_customers - Purchases:
python manage.py list_purchases
- All records:
python manage.py delete_all - Customers:
python manage.py delete_customers - Purchases:
python manage.py delete_purchases