This is a Django REST API for identifying and managing contacts based on email and phone numbers. It determines the primary and secondary contacts linked to a given email or phone number.
- Identify contacts based on email or phone number.
- Maintain primary and secondary contact relationships.
- Provide a structured response with all associated contact details.
- Python (Django, Django REST Framework)
- PostgreSQL (or SQLite for local development)
- drf-yasg (Swagger API Documentation)
git clone https://github.com/PragatiVerma18/BiteSpeed.git
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
DEBUG=
DATABASE_URL=
SECRET_KEY=
python manage.py runserver
The API will be available at http://127.0.0.1:8000/
pytest identity_reconciliation/tests/test_identify.py -v
POST /identify/
Identifies primary and secondary contacts based on email or phone number. If no contact exists, a new primary contact is created.
{
"email": "[email protected]",
"phoneNumber": "+1234567890"
}
- Case 1: New primary contact created
{
"contact": {
"primaryContactId": 23,
"emails": ["[email protected]"],
"phoneNumbers": ["+1234567890"],
"secondaryContactIds": []
}
}
- Case 2: Existing contacts found, linked as secondary
{
"contact": {
"primaryContactId": 1,
"emails": ["[email protected]", "[email protected]"],
"phoneNumbers": ["+1234567890", "+9876543210"],
"secondaryContactIds": [2, 3]
}
}
- Case 3: Existing primary contact converted to secondary
{
"contact": {
"primaryContactId": 1,
"emails": ["[email protected]", "[email protected]"],
"phoneNumbers": ["+1234567890", "+1122334455"],
"secondaryContactIds": [2, 3, 4]
}
}
Status Code | Error Message |
---|---|
400 | {"error": "At least one of email or phoneNumber is required."} |
Username: admin
Password: admin123