# com.innovaphone.calllist

This API is used for communication with call-list apps.

## consumeApi

The client consumeApi function is used to access the Api:

    var calllistApi = start.consumeApi("com.innovaphone.calllist");
    calllistApi.onmessage.attach(onmessage); // onmessage is called for responses from the API

## Messages

Subscribe
Update
Clear
GetCallFlow
GetCallFlowResult

### Subscribe

Used to declare that it is interested in call list entries. The Call List App will provide the requested amount of available call list entries. The App wil also provide new entries at runtime.

#### Parameters

string count | Number of currently available entries that are to be returned immediately. Up to 100 entries are possible.

    calllistApi.send({ "mt": "Subscribe", "count": 20 });

### Update

The result message for the Subscribe request.

#### Parameters

array entries | Array of call list entries.

#### Details:

- dir: "i" (inbound call) or "o" (outbound call)
- time: UTC timestamp
- cause: the decimal disconnect reason of the call (see Reference:ISDN_Cause_Codes)
- call: "int" (internal call) or "ext" (external call)
- status: "co" (connected), "al" (alert), "er" (error) or "bu" (busy)

    {
        "mt": "Update",
        "entries": [
        {
        "cdr": 21173,
        "sip": "tac",
        "id": "c06ab5ee-cc1c-5c01-8a68-009033420759",
        "dir": "o",
        "node": "root",
        "phys": "",
        "cause": 0,
        "time": 1545391345000,
        "alert-duration": 12,
        "call-duration": 0,
        "conn-duration": 0,
        "billing-duration": 0,
        "call": "int",
        "remote": {
        "number": "40",
        "sip": "rh",
        "dn": "Ralf Hütter"
        },
        "status": "al"
        },
        {
        "cdr": 20713,
        "sip": "tac",
        "id": "2d61b691-9c1b-5c01-ed7a-009033420759",
        "dir": "i",
        "node": "root",
        "phys": "berlin",
        "cause": 0,
        "time": 1545313426000,
        "alert-duration": 7,
        "call-duration": 2814,
        "conn-duration": 2814,
        "billing-duration": 0,
        "call": "int",
        "remote": {
        "number": "683",
        "sip": "fs",
        "dn": "Florian Schneider"
        },
        "status": "co"
        },
        ]
    }

### Clear

The Call List App sends this message to subscriber when ever the call list (database) have been cleared.

#### Parameters

string count | Number of currently available entries that are to be returned immediately.

    calllistApi.send({ "mt": "Clear" });

### GetCallFlow

Used to get the complete callflow of a call.

#### Parameters

string id | The cdr of the call entry.

    calllistApi.send({ "mt": "GetCallFlow", "id": 12 });

### GetCallFlowResult

Response message to GetCallFlow containing the callflow information of an entry.

#### Parameters

string id | The cdr of the call entry.
string flow | The callflow of the call entry.

    {"mt":"GetCallFlowResult","id":12,"flow":[
            {"caller":"ep2","ep1_number":"302","ep1_sip":"waiting2","ep1_dn":"Waiting2","ep2_number":"201","ep2_sip":"endeavour","ep2_dn":"Endeavour","status":"al"},
            {"ep1_number":"200","ep1_sip":"atlantis","status":"co","type":"cf","entry":"true"}
     ],"src":"src0"}