Project

General

Profile

API - Schedule Read

API Schedule Read se foloseste pentru a citi programul (orarul) elementelor din centrala: proiecte, rute Inbound, IVR-uri, cozi, useri, contacte.

API URL

https://[YOUR-PBX-URL]/api/schedule

Datele se transmit prin POST sau GET si trebuie sa fie de forma:

Array
(
    [action] => read
    [data] => Array
        (
            [type] => weekdays
        )

    [api_hash] => 07112231a9c89f5b108af08608a97b07
)

Parametrul action trebuie sa aiba valoarea read.
Parametrul data trebuie sa contina type cu valoarea weekdays (programul saptamanal) sau custom (programul pe date calendaristice, ex: sarbatori).

Raspunsul contine toate elementele care au program de tipul cerut. Pentru fiecare element: element_type (project, inbound_route, contact, user, ivr_menu, pbx_queue), element_id, name, project_id, wdays (zilele cu program, 0 = duminica ... 6 = sambata), dates (pentru custom) si intervals (intervalele, cu weekday sau date, key - numarul intervalului in zi, start / end si mesajele asociate). Un interval 00:00:00 - 00:00:00 inseamna inchis toata ziua.

Headere HTTP:

Content-Type: application/json
Authorization: Bearer <token>

Exemplu generare parametri:

$params = array(
    'action' => 'read',
    'data' => array(
        'type' => 'weekdays', // custom
    )
);

Exemplu generare hash:

$params['api_hash'] = md5(json_encode($params) . 'your_api_key'); // make hash

Exemplu trimitere date:

$url = 'https://[YOUR-PBX-URL]/api/schedule';
$token = 'your_api_token';
echo curlPost($url, json_encode($params), array("Authorization: Bearer {$token}", "Content-Type: application/json"));

Date trimise JSON

{
   "action":"read",
   "data":{
      "type":"weekdays" 
   },
   "api_hash":"de1b56d49bf027503ef3ecee05b9c59d" 
}

Raspuns

In caz de succes:

{

    "has_error": false,
    "messages": [ ],
    "results": [
        {
            "element_id": 1,
            "element_type": "project",
            "cnt": 7,
            "wdays": [0, 1, 2, 3, 4, 5, 6],
            "dates": [ ],
            "name": "Test project",
            "project_id": 1,
            "intervals": [
                {
                    "id": 1,
                    "element_type": "project",
                    "element_id": 1,
                    "weekday": 0,
                    "date": null,
                    "key": 1,
                    "start": "00:00:00",
                    "end": "00:00:00",
                    "break_interval": null,
                    "welcome_message": null,
                    "ns_welcome_message": null,
                    "closed_message": null,
                    "closed_gosub": null,
                    "break_message": null,
                    "status": "active" 
                },
                {
                    "id": 2,
                    "element_type": "project",
                    "element_id": 1,
                    "weekday": 1,
                    "date": null,
                    "key": 1,
                    "start": "09:00:00",
                    "end": "18:00:00",
                    "break_interval": "13:00-14:00",
                    "welcome_message": null,
                    "ns_welcome_message": null,
                    "closed_message": null,
                    "closed_gosub": null,
                    "break_message": "lunch-break",
                    "status": "active" 
                }
            ]
        }
    ]

}

Sau in caz de eroare:

{

    "has_error": true,
    "messages": [
        "Invalid schedule type: xxx" 
    ],
    "results": [ ]

}

Disponibil si in alte limbi: EN