PBX Features (PBXOperator)
The PBXOperator is used to implement PBX-related features, such as querying CDR records and logging out. This topic describes the attributes, methods, and events related to PBX features (PBXOperator object).
Attributes
Attribute | Type | Description |
---|---|---|
username | string | Username (extension number or email address) |
secret | string | Login signature requested from PBX. |
token | string | The access token requested from PBX. |
url | URL | The URL for accessing your PBX system. |
socket | WebSocket | The socket instance for monitoring PBX status changes and receiving notifications in real-time. |
extensionNumber | string | Extension number. |
extensionId | string | Extension ID. |
extensionName | string | Extension name. |
Methods
- Methods overview
- Initialization
- The initialization method is used within Linkus SDK Core.Note: After successful initialization, any subsequent calls to this method will be invalid and a response
Promise.reject
will be returned.
- Listen for events
-
Method on(eventName, listener)
Parameters eventName
: The event name.listener
: Callback function.
Return value Null. Note: For more information about the events that you can listen for, see Events.
- Query CDR records
-
Method cdrQuery(params)
Parameters params: { page: number; //Required, define which page is displayed. size: number; //Required, define how many records per page. status?: number; // Optional, specify the call type. 0: All; 1: Inbound call; 2: Missed call; 3: Outbound call sortBy: 'time' | 'id'; //Required, define the sorting field. orderBy?: 'desc' | 'asc'; //Optional, define the display order. filter?: string | null; //Optional, define the filtering criteria. }
Return value Promise
Return value description { errcode: 0, errmsg: "SUCCESS", personal_cdr_list: [ //CDR list { id: 2546, //The sequence number of the record. date: "Today", //The date when the call was made or received. time: "17:21:39", //The time when the call was made or received. timestamp: 1686561699, //The timestamp of the time when the call was made or received. number: "1011", // Caller number number_type: "extension", extension: { //Extension information ext_id: 25, //Extension ID ext_num: "1011", //Extension number caller_id_name: "cwt1011", //Extension name photo: "", // Profile image ID status: 0, // Online status of the extension endpoints. 0: Offline; 1: Online presence_status: "available", //Extension presence status presence_information: "", first_name: "wt1011", //First name last_name: "c", //Last name email_addr: "", //Email address mobile_number: "", //Mobile number enb_vm: 0, //Whether the voicemail is enabled. vm_total_count: 0, //The total number of voicemail messages vm_unread_count: 0, //The total number of unread voicemail messages visable: 0, im_id: "xxxxx", org_list_info: "", is_favorite: 0, title: "" //Job title }, status: 3, //Call type. 0: All; 1: Inbound call; 2: Missed call; 3: Outbound call talk_duration: 3, //The time between the call answered and the call ended. call_type: "Internal", // Communication type: 'Internal' or 'External' uniqueid: "1686561699.137", // The unique ID of the CDR. disposition: "ANSWERED", // Call status: 'ANSWERED', 'NO ANSWER', 'BUSY', 'FAILED', and 'VOICEMAIL' dcontext: "DLPN_DialPlan1010", caller_id: "1011", // Caller number clid: "\"cwt1010\" <1010>" } ], total_number: 63, //The total number of the queried CDR. }
- Log out
-
Method logout()
Parameters Null. Return value Promise
- Destroy the PBXOperator object
-
Method destroy()
Parameters Null. Return value Null.
Events
- Example code
-
pbx.on('eventName', (data) => {})
- Runtime error event
-
Event name runtimeError
Data PBXResult
Report parameters { code: '', msg: '', }
Note: Refer to the following table for reporting parameter descriptions of the event.
- CDR changes event
- When this event is triggered, you need to manually call the method to query CDR records.