# Call processing for the period

## Call processing for the period

## Itgrix module API request

If for some reason the Itgrix module has been disabled, or if during the first installation there is a desire to process already passed calls, you can use a special request `/pbx/read_call` in the API of the **Itgrix** module. It can be used to trigger the processing of certain calls.

For example, you can make a query using `curl` (here \<Asterisk> is the address of the server where the **Itgrix** module is installed, login:password is the login:password for the integration module's admin panel):

```
curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call?<parameters>"
```

The method has two options for using parameters:

* specify one or more call identifiers `id`;
* specify the `start_date` and (optionally) `end_date` (in this case the module finds all CEL records in the specified dates and processes calls by ID) (in this case the module finds all CEL **records** in the specified dates, takes `linkedid` from them and processes **calls** by ID).

## Using the call ID

If you need to process a single call, the easiest thing to do is to make GET-query with parameter `id`:

```
curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call?id=1234567890.1"
```

If you need to process several calls, you can pass a JSON-object with an `id` array via POST request :

```
curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call" \
-H "Content-Type: application/json" \
-d '{"id":["1111111111.1", "2222222222.2"]}'
```

#### Использование границ периода

Границы периода определяются параметрами `start_date` и `end_date` . При этом параметр `end_date` опциональный, т.е. его можно не указывать, и в таком случае модуль обработает все звонки, начиная с `start_date`.

Параметры могут быть указаны в трёх видах:

* **Дата-время в формате `ГГГГ-ММ-ДД чч:мм:сс`**.\
  При отправке GET-запроса с таким параметром нужно заменить пробел на специальную последовательность `%20`, при отправке POST-запроса с параметрами в формате JSON это не требуется.\
  Например, обработаем звонки за 25 мая 2021 с 10:30 до 22:00:

  ```
  curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call?\
  start_date=2021-05-25%2010:30:00&\
  end_date=2021-05-25%2022:00:00"
  ```
* **Метка времени в формате UNIX-time** (можно получить [из ID звонка, - это число до точки](https://wiki.asterisk.org/wiki/display/AST/Using+the+CONTEXT%2C+EXTEN%2C+PRIORITY%2C+UNIQUEID%2C+and+CHANNEL+Variables); например, в звонке 1267568856.11 число 1267568856 является меткой времени).\
  Например, обработаем звонки с 27 мая 2021 06:01:59 GMT, т.е. UNIX-time 1622138519:

  ```
  curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call?start_date=1622138519"
  ```
* **Количество дней назад (отрицательное целое число).**\
  Например, обработать звонки за позавчера:

  ```
  curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call?start_date=-2&end_date=-1"
  ```

  Пример обработки звонков за неделю:

  ```
  curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call?start_date=-7"
  ```

  Также есть специальный вариант `start_date=-0` - обработка звонков за сегодня (с полуночи по местному времени):

  ```
  curl --digest -u login:password "<Asterisk IP>:8077/pbx/read_call?start_date=-0"
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.itgrix.com/for-admins/call-processing-for-the-period.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
