API Docs for:
Show:

plugin_rest_phonebook Class

Module: plugins_rest
Parent Module: com_phonebook_rest

REST plugin that provides phonebook functions through the following REST API:

GET requests

  1. phonebook/search/:term[?view=company&limit=n&offset=n]
  2. phonebook/speeddials
  3. phonebook/contact/:id
  4. phonebook/cticontact/:id
  5. phonebook/searchstartswith/:term[?view=company&limit=n&offset=n]
  6. phonebook/searchstartswith_digit/:view[?limit=n&offset=n]

phonebook/search/:term[?view=company&limit=n&offset=n]

The client receives all phonebook contacts found in the centralized or NethCTI phonebooks. It supports pagination with limit and offset. It offers a view where results are grouped by company.

It returns all database entries that contain the specified term in the fields name, company, workphone, homephone and cellphone.

Example JSON response:

  • phonebook/search/net?view=company&offset=0&limit=5
{
   "count": 353,
   "rows": [
       {
           "id": 5946,
           "company": "",
           "workstreet": "",
           "workcity": "",
           "workprovince": "",
           "workcountry": "",
           "url": "",
           "contacts": "[{\"id\": 5946,\"name\": \"\", \"source\": \"centralized\"}]"
       },
       ...
   ]
}
  • phonebook/search/net?offset=0&limit=5
{
   "count": 5,
   "rows": [
       {
           "id": 4846,
           "owner_id": "",
           "type": "",
           "homeemail": "",
           "workemail": "",
           "homephone": "",
           "workphone": "",
           "cellphone": "",
           "fax": "",
           "title": "",
           "company": "",
           "notes": "",
           "name": "",
           "homestreet": "",
           "homepob": "",
           "homecity": "",
           "homeprovince": "",
           "homepostalcode": "",
           "homecountry": "",
           "workstreet": "",
           "workpob": "",
           "workcity": "",
           "workprovince": "",
           "workpostalcode": "",
           "workcountry": "",
           "url": "",
           "extension": "",
           "speeddial_num": "",
           "source": "centralized"
       },
       ...
   ]
}

phonebook/speeddials

The client receives all speeddial contacts owned by him. The contacts are in the NethCTI phonebook. It returns all database entries that have the field type equal to "speeddial".

Example JSON response:

[
       {
             "id": 1
             "owner_id": "alessandro"
             "type": "speeddial"
             "homeemail": ""
             "workemail": ""
             "homephone": ""
             "workphone": ""
             "cellphone": "123456"
             "fax": ""
             "title": ""
             "company": ""
             "notes": ""
             "name": "ale"
             "homestreet": ""
             "homepob": ""
             "homecity": ""
             "homeprovince": ""
             "homepostalcode": ""
             "homecountry": ""
             "workstreet": ""
             "workpob": ""
             "workcity": ""
             "workprovince": ""
             "workpostalcode": ""
             "workcountry": ""
             "url": ""
             "extension": ""
             "speeddial_num": "123456"
       }
 ]

phonebook/contact/:id

The client receives the details of the contact that is in the phonebook phonebook. The parameter id is the database identifier of the contact.

Example JSON response:

{
   "id": 1,
   "owner_id": "alessandro",
   "type": "source",
   "homeemail": "",
   "workemail": "",
   "homephone": "",
   "workphone": "",
   "cellphone": "123456",
   "fax": "",
   "title": "",
   "company": "",
   "notes": "",
   "name": "ale",
   "homestreet": "",
   "homepob": "",
   "homecity": "",
   "homeprovince": "",
   "homepostalcode": "",
   "homecountry": "",
   "workstreet": "",
   "workpob": "",
   "workcity": "",
   "workprovince": "",
   "workpostalcode": "",
   "workcountry": "",
   "url": "",
   "extension": "",
   "speeddial_num": "123456"
}

phonebook/cticontact/:id

The client receives the details of the contact that is in the NethCTI phonebook. The parameter id is the database identifier of the contact.

Example JSON response:

{
   "id": 1,
   "owner_id": "",
   "type": "speeddial",
   "homeemail": "",
   "workemail": "",
   "homephone": "",
   "workphone": "",
   "cellphone": "123456",
   "fax": "",
   "title": "",
   "company": "",
   "notes": "",
   "name": "ale",
   "homestreet": "",
   "homepob": "",
   "homecity": "",
   "homeprovince": "",
   "homepostalcode": "",
   "homecountry": "",
   "workstreet": "",
   "workpob": "",
   "workcity": "",
   "workprovince": "",
   "workpostalcode": "",
   "workcountry": "",
   "url": "",
   "extension": "",
   "speeddial_num": "123456"
}

phonebook/searchstartswith/:term[?view=company&limit=n&offset=n]

The client receives all phonebook contacts found in the centralized or NethCTI phonebooks. It returns all database entries whose name and company fields starts with the specified term. It offers a view where results are grouped by company.

Example JSON response:

  • phonebook/searchstartswith/A?offset=40&limit=5&view=company
{
   "count": 353,
   "rows": [
       {
           "id": 5946,
           "company": "",
           "workstreet": "",
           "workcity": "",
           "workprovince": "",
           "workcountry": "",
           "url": "",
           "contacts": "[{\"id\": 5946,\"name\": \"\", \"source\": \"centralized\"}]"
       },
       ...
   ]
}
  • phonebook/searchstartswith/A?offset=40&limit=5
{
   "count": 869,
   "rows": [
       {
           "id": 4846,
           "owner_id": "",
           "type": "",
           "homeemail": "",
           "workemail": "",
           "homephone": "",
           "workphone": "",
           "cellphone": "",
           "fax": "",
           "title": "",
           "company": "",
           "notes": "",
           "name": "",
           "homestreet": "",
           "homepob": "",
           "homecity": "",
           "homeprovince": "",
           "homepostalcode": "",
           "homecountry": "",
           "workstreet": "",
           "workpob": "",
           "workcity": "",
           "workprovince": "",
           "workpostalcode": "",
           "workcountry": "",
           "url": "",
           "extension": "",
           "speeddial_num": "",
           "source": "centralized"
       },
       ...
   ]
}

phonebook/searchstartswith_digit/:view[?limit=n&offset=n]

The client receives all phonebook contacts found in the centralized or NethCTI phonebooks. It returns all database entries whose name and company fields starts with a digit. It offers results grouped by view. View can be "company" or "contacts".

Example JSON response:

  • phonebook/searchstartswith_digit/company?offset=0&limit=5
{
   "count": 353,
   "rows": [
       {
           "id": 5946,
           "company": "",
           "workstreet": "",
           "workcity": "",
           "workprovince": "",
           "workcountry": "",
           "url": "",
           "contacts": "[{\"id\": 5946,\"name\": \"\", \"source\": \"centralized\"}]"
       },
       ...
   ]
}
  • phonebook/searchstartswith_digit/contacts?offset=0&limit=5
{
   "count": 5,
   "rows": [
       {
           "id": 4846,
           "owner_id": "",
           "type": "",
           "homeemail": "",
           "workemail": "",
           "homephone": "",
           "workphone": "",
           "cellphone": "",
           "fax": "",
           "title": "",
           "company": "",
           "notes": "",
           "name": "",
           "homestreet": "",
           "homepob": "",
           "homecity": "",
           "homeprovince": "",
           "homepostalcode": "",
           "homecountry": "",
           "workstreet": "",
           "workpob": "",
           "workcity": "",
           "workprovince": "",
           "workpostalcode": "",
           "workcountry": "",
           "url": "",
           "extension": "",
           "speeddial_num": "",
           "source": "centralized"
       },
       ...
   ]
}

POST requests

  1. phonebook/create
  2. phonebook/delete_cticontact
  3. phonebook/modify_cticontact
  4. phonebook/import_csv_speeddial

phonebook/create

Creates a contact in the NethCTI phonebook. The contact information must be specified in the POST request in JSON format and must contain at least the following parameters:

  • type: ("speeddial | "private" | "public"): the visibility of the contact
  • name: the name of the contact
  • [homeemail]
  • [workemail]
  • [homephone]
  • [workphone]
  • [cellphone]
  • [fax]
  • [title]
  • [company]
  • [notes]
  • [homestreet]
  • [homepob]
  • [homecity]
  • [homeprovince]
  • [homepostalcode]
  • [homecountry]
  • [workstreet]
  • [workpob]
  • [workcity]
  • [workprovince]
  • [workpostalcode]
  • [workcountry]
  • [url]
  • [extension]
  • [speeddial_num]

Example JSON request parameters:

{ "creator": "alessandro", "type": "type", ... }

phonebook/delete_cticontact

Deletes a contact from the NethCTI phonebook. The request must contains the following parameter:

  • id: the contact identifier in the NethCTI phonebook database

Example JSON request parameters:

{ "id": "74" }

The NethCTI phonebook is the nethcti.cti_phonebook database table.


phonebook/modify_cticontact

Modify a contact in the NethCTI phonebook. The request must contains the following parameters:

  • id: the contact identifier in the NethCTI phonebook database
  • [type]: ("speeddial | "private" | "public"): the visibility of the contact
  • [name]: the name of the contact
  • [homeemail]
  • [workemail]
  • [homephone]
  • [workphone]
  • [cellphone]
  • [fax]
  • [title]
  • [company]
  • [notes]
  • [homestreet]
  • [homepob]
  • [homecity]
  • [homeprovince]
  • [homepostalcode]
  • [homecountry]
  • [workstreet]
  • [workpob]
  • [workcity]
  • [workprovince]
  • [workpostalcode]
  • [workcountry]
  • [url]
  • [extension]
  • [speeddial_num]

Example JSON request parameters:

{ "creator": "alessandro", "type": "type", ... }

The NethCTI phonebook is the nethcti.cti_phonebook database table.


phonebook/import_csv_speeddial

Import Speed Dial contacts from a csv file into the NethCTI phonebook. The request must contains the following parameters:

  • file64: the csv file content base64 encoded

Example JSON request parameters:

{ "file64": "data:text/csv;base64,aWQsb3duZXJfa..." }

The csv file format must be like this:

id,owner_id,type,homeemail,workemail,homephone,workphone,cellphone,fax,title,company,notes,name,homestreet,homepob,homecity,homeprovince,homepostalcode,homecountry,workstreet,workpob,workcity,workprovince,workpostalcode,workcountry,url,extension,speeddial_num

The field "speeddial_num" is the number to be called when click the contact from cti client app: it can be equal to extension or workphone or homephone or cellphone.

The NethCTI phonebook is the nethcti.cti_phonebook database table.


DELETE requests

  1. phonebook/speeddials

phonebook/speeddials

Delete all speed dial contacts of the user.

Methods

create

(
  • req
  • res
  • next
)

Create a contact in the NethCTI phonebook with the following REST API:

create

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

delete_cticontact

(
  • req
  • res
  • next
)

Deletes a contact from the NethCTI phonebook.

delete_cticontact

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

import_csv_speeddial

(
  • req
  • res
  • next
)

Import speed dial contacts from a csv file into the NethCTI phonebook.

import_csv_speeddial

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

modify_cticontact

(
  • req
  • res
  • next
)

Modify a contact in the NethCTI phonebook.

modify_cticontact

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

searchstartswith

(
  • req
  • res
  • next
)

Searches all phonebook contacts found in the centralized and NethCTI phonebooks. It returns all database entries whose name and company fields starts with the specified term. It offers a view where results are grouped by company.

searchstartswith/:term[?view=company&limit=n&offset=n]

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

searchstartswith_digit

(
  • req
  • res
  • next
)

Searches all phonebook contacts found in the centralized and NethCTI phonebooks. It returns all database entries whose name and company fields starts with a digit. It offers a view where results are grouped by company.

searchstartswith_digit/view=[?limit=n&offset=n]

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

setCompAuthorization

(
  • comp
)
static

Set the authorization architect component.

Parameters:

  • comp Object

    The architect authorization component

setCompPhonebook

(
  • cp
)

Set phonebook architect component used by phonebook functions.

Parameters:

  • cp Object

    The phonebook architect component.

setCompUtil

(
  • comp
)

Sets the utility architect component.

Parameters:

  • comp Object

    The utility architect component.

setLogger

(
  • log
)
static

Set the logger to be used.

Parameters:

  • log Object

    The logger object. It must have at least three methods: info, warn and error as console object.

speeddials

(
  • req
  • res
  • next
)

Get/Delete all speed dial contacts of the user by the following REST API:

GET speeddials
DELETE speeddials

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

speeddials

(
  • req
  • res
  • next
)

Returns all the speeddial contacts of the user. The contacts are in the NethCTI phonebook. It returns all database entries that have the field type equal to "speeddial".

speeddialsGet

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

speeddialsDelete

(
  • req
  • res
  • next
)

Delete all speeddial contacts of the user. The contacts are in the NethCTI phonebook.

speeddialsDelete

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

Properties

compAuthorization

Object private

The architect component to be used for authorization.

compPhonebook

Object private

The phonebook architect component used for phonebook functions.

compUtil

Object private

The utility architect component.

del

Array

REST API to be requested using HTTP DELETE request.

Sub-properties:

  • speeddials String

    Delete all speed dial contacts of the user

get

Array

REST API to be requested using HTTP GET request.

Sub-properties:

  • speeddials String

    To get all the speeddial contacts of the user from the NethCTI phonebook

  • search/:term[?view=company&limit=n&offset=n] String

    To get the centralized and cti phonebook contacts that contains the term

  • contact/:id String

    To get the the details of the contact that is in the centralized phonebook

  • cticontact/:id String

    To get the the details of the contact that is in the cti phonebook

  • searchstartswith/:term[?view=company&limit=n&offset=n] String

    To get the centralized and cti phonebook contacts whose name starts with the specified term

  • searchstartswith_digit/:view[?limit=n&offset=n] String

    To get the centralized and cti phonebook contacts whose name starts with a digit

IDLOG

String private final

The module identifier used by the logger.

Default: [plugins_rest/phonebook]

logger

Object private

The logger. It must have at least three methods: info, warn and error.

Default: console

post

Array

REST API to be requested using HTTP POST request.

Sub-properties:

  • create String

    Creates a contact in the NethCTI phonebook

  • delete_cticontact String

    Deletes a contact from the NethCTI phonebook

  • modify_cticontact String

    Modify a contact in the NethCTI phonebook

  • import_csv_speeddial String

    Import speed dial contacts from a csv file into the NethCTI phonebook