---
# System prepended metadata

title: Henrique Gonçalves

---

# Henrique Gonçalves

## Calls API
A new product requirement states that all Talkdesk calls should be registered in a centralized system. A call has always two participants, a **customer** and an **agent**, and it can be either **inbound** (started by the customer) or outbound (started by the agent). The system must fulfill the following use cases:

* Ability to **register a new** call
* Ability to mark a call as **finished**
* Ability to **retrieve** the data associated with a given call
* Ability to list calls matching a given criteria. It should be possible to filter by:
    * Start and end dates
    * Status (in progress / finished)
    * Contact number

Clients should be able to interact with this system through a REST API. Each call pertains to a specific **tenant** (and a tenant can only access calls belonging to it), it must have an **unique identifier** and a new record must include the following information:
* Start date
* Source number
* Destination number
* Direction (inbound/outbound)

When a call is marked as finished, the record must also include the corresponding end date.

## Solution design
*:video_game: Go Henrique :muscle:*

Registar Chamada:
Request body: {
    "direction": "",
    "source_number": "",
    "destination_number": "",
    "start_date": "",
}

[POST] /calls
CREATED 201
{
    "response": {
        "status": "",
        "direction": "",
        "source_number": "",
        "destination_number": "",
        "call_id": "",
        "start_date": "",
        "end_date": ""
    }
    "details": {}
}


Obter Chamada:
[GET] /calls/:id/
OK 200

Marcar chamada como terminada:
[PUT] /calls/:id/
no body {'state': 'end'}

Listar chamadas:
[GET] /calls?start_date=...&end_date=...

{
    "results": [
        {"status": "",
        "direction": "",
        "source_number": "",
        "destination_number": "",
        "call_id": "",
        "start_date": "",
        "end_date": ""},
        {...},
    ],
    "details": {
        "total": ...
        "pag": 0,
    }
}