This is a simple API to view and manage the contact list of the Django User default. These are the minimum requirements:
- A single user might have one or multiple contacts on their contact list
- A single contact might have one or multiple phone numbers
- A single user might have one or multiple groups on their contact list
- A single contact group can have one or multiple contacts
Figure 1 - Contact-to-Contact relationship
Figure 2 - Contact-to-Phone relationship
Figure 3 - Contact-to-Group Relationship
- Open your terminal.
- Navigate to the
django-contact
directory. - Setup python virtual environment and then activate it.
- Copy-paste
/scripts/.env.sh.template
in the same directory, and then rename it as.env.sh
. - Modify the IP Address of your local
SERVER
and itsPORT
number when necessary. - Run
./scripts/run-project.sh
This section describes endpoint designs that are applicable for users with a specific access level.
POST /contacts/
: Create a new contact.
Request Body{ "user": 1, "nickname": "", "company": "", "title": "", "address": "" }
GET /contacts/<int:id>/
: Retrieve contact with specific ID.UPDATE /contacts/<int:id>/
: Update contact with specific ID.
Request Body{ "nickname": "", "company": "", "title": "", "address": "" }
DELETE /contacts/<int:id>/
: Delete contact with specific ID.
POST /contacts/<int:contact_id>/phone-numbers/
: Create a new phone number for the given contact ID.
Request Body{ "phone_number": "+6281222333444", "phone_type": "cellphone" | "telephone" | "telefax", "is_primary": true }
UPDATE /contacts/<int:contact_id>/phone-numbers/<int:id>/
: Update phone number of the given contact ID.
Request Body{ "phone_number": "+6281222333444", "phone_type": "cellphone" | "telephone" | "telefax", "is_primary": true }
DELETE /contacts/<int:contact_id>/phone-numbers/<int:id>/
: Delete phone number of the given contact ID.
GET /contacts/
: Get all contacts.
Response[ { "id": 1, "first_name": "User", "last_name": "One", "nickname": "", "email": "user1@mail.com", "company": "", "title": "", "phone_numbers": [ { "id": 1, "phone_number": { "value": 81222333444, "country_code": 62, "country_code_source": 1 }, "type": "cellphone", "is_primary": true, "created_at": "2022-06-08T07:18:28.477549Z", "updated_at": "2022-06-08T07:18:28.477581Z" } ], "address": "", "created_at": "2022-06-08T07:17:11.255513Z", "updated_at": "2022-06-08T07:17:11.255548Z" } ]
GET /contacts/me/contacts/
: Get contact list belongs to the requester's contact list.
Response[ { "id": 1, "first_name": "User", "last_name": "One", "nickname": "", "email": "user1@mail.com", "company": "", "title": "", "phone_numbers": [ { "id": 1, "phone_number": { "value": 81222333444, "country_code": 62, "country_code_source": 1 }, "type": "cellphone", "is_primary": true, "created_at": "2022-06-08T07:18:28.477549Z", "updated_at": "2022-06-08T07:18:28.477581Z" } ], "address": "", "starred": false, "created_at": "2022-06-08T07:17:11.255513Z", "updated_at": "2022-06-08T07:17:11.255548Z" } ]
POST /contacts/me/contacts/
: Create a new contact in the requester's contact list.
Request Body{ "contact": 1, "starred": true | false }
GET /contacts/me/contacts/<int:contact_id>/
: Retrieve contact from the requester's contact list.DELETE /contacts/me/contacts/<int:contact_id>/
: Delete new contact from the requester's contact list.
GET /groups/
: Get contact groups that are accessible to the requester.
Response[ { "id": 1, "name": "Test Group", "description": "Description update", "created_by": 1, "created_at": "2022-06-08T07:21:16.195551Z", "updated_by": 1, "updated_at": "2022-06-10T02:50:08.397982Z" } ]
POST /groups/
: Create a new contact group.
Request Body{ "name": "", "description": "" }
GET /groups/<int:id>/
: Retrieve contact group with specific ID.UPDATE /groups/<int:id>/
: Update contact group with specific ID.
Request Body{ "name": "", "description": "" }
DELETE /groups/<int:id>/
: Delete contact group with specific ID.
GET /groups/<int:group_id>/contacts/
: Get contact list in the given group ID.
Response[ { "id": 1, "first_name": "User", "last_name": "One", "nickname": "", "email": "user1@mail.com", "company": "", "title": "", "phone_numbers": [ { "id": 1, "phone_number": { "value": 81222333444, "country_code": 62, "country_code_source": 1 }, "type": "cellphone", "is_primary": true, "created_at": "2022-06-08T07:18:28.477549Z", "updated_at": "2022-06-08T07:18:28.477581Z" } ], "address": "", "created_at": "2022-06-08T07:17:11.255513Z", "updated_at": "2022-06-08T07:17:11.255548Z" } ]
POST /groups/<int:group_id>/contacts/
: Add contact to the given contact group ID.
Request Body{ "contact": 1, "role": "admin" | "member", "inviter": 1 }
GET /groups/<int:group_id>/contacts/<int:id>/
: Retrieve contact from the given contact group ID.PUT /groups/<int:group_id>/contacts/<int:id>/
: Update contact in the given contact group ID.
Request Body{ "role": "admin" | "member" }
DELETE /groups/<int:group_id>/contacts/<int:id>/
: Delete contact from the given contact group ID.