Created | By |
---|---|
2024-03-06 |
Adi Nugraha Putra |
Endpoint: POST
/api/contacts
Request Header:
- X-API-TOKEN: token(uuid)
Request Body:
{
"first_name": "Adi",
"last_name": "Nugraha Putra",
"email": "[email protected]",
"phone": "081234567890"
}
Response Body (Success):
{
"data": {
"id": 1,
"first_name": "Adi",
"last_name": "Nugraha Putra",
"email": "[email protected]",
"phone": "081234567890"
}
}
Response Body (Failed):
{
"error": "First name must not blank, Last name must not blank, Email must not blank, Phone must not blank..."
}
Endpoint: GET
/api/contacts/:id
Request Header:
- X-API-TOKEN: token(uuid)
Response Body (Success):
{
"data": {
"id": 1,
"first_name": "Adi",
"last_name": "Nugraha Putra",
"email": "[email protected]",
"phone": "081234567890"
}
}
Response Body (Failed):
{
"error": "Contact not found..."
}
Endpoint: PUT
/api/contacts/:id
Request Header:
- X-API-TOKEN: token(uuid)
Request Body:
{
"first_name": "Adi",
"last_name": "Nugraha Putra",
"email": "[email protected]",
"phone": "0999999999999" // updated phone number
}
Response Body (Success):
{
"data": {
"first_name": "Adi",
"last_name": "Nugraha Putra",
"email": "[email protected]",
"phone": "081234567890"
}
}
Response Body (Failed):
{
"errors": "Contact not found..."
}
Endpoint: DELETE
/api/contacts/:id
Request Header:
- X-API-TOKEN: token(uuid)
Response Body (Success):
{
"data": "OK"
}
Response Body (Failed):
{
"errors": "Contact not found..."
}
Endpoint: GET
/api/contacts
Query Parameter:
- name: string, contact first name or contact last name, optional
- phone: string, contact phone, optional
- email: string, contact email, optional
- page: number, default 1
- size: number, default 10
Request Header:
- X-API-TOKEN: token(uuid)
Response Body (Success):
{
"data": [
{
"id": 1,
"first_name": "Adi",
"last_name": "Nugraha Putra",
"email": "[email protected]",
"phone": "081234567890"
},
{
"id": 2,
"first_name": "Adi",
"last_name": "Nugraha Putra",
"email": "[email protected]",
"phone": "081234567890"
}
],
"paging": {
"current_page": 1,
"total_page": 10,
"size": 10
}
}
Response Body (Failed):
{
"errors": "Unauthorized, ..."
}