@wildix/xbees-connect
TypeScript icon, indicating that this package has built-in type declarations

1.2.6 • Public • Published

x-bees-connect client

This package is the Community plan edition of the client for UI integration applications.

Installation

Install the package in your project directory with:

yarn add @wildix/xbees-connect
npm install @wildix/xbees-connect

Usage

import Client from "@wildix/xbees-connect";

const xBeesClient = Client.getInstance();

console.log(xBeesClient.version());

API

Initialization

ready()

Sends the signal to x-bees that iFrame is ready to be shown. iFrame should send it when the application starts and is ready.

isAuthorized: (payload: string) => Promise<ResponseFromChannel>

Sends the message to x-bees that the user is authorized and no more actions are required.

isNotAuthorized: (payload: string) => Promise<ResponseFromChannel>

Sends the message to x-bees that user actions are required:

Contacts search

onSuggestContacts: ((query: string, resolve: Resolve, reject: Reject) => void) => RemoveEventListener

Starts listen for the events of searching contacts and handle autosuggestion with the provided callback */

Client.getInstance().onSuggestContacts(async (query, resolve) => {
    try {
        const contacts = await fetchContacts(query);
        resolve(contacts);
    } catch (error) {
        console.log('catch', error);
    }
});

onLookupAndMatchContact: ((query: ContactQuery, resolve: Resolve, reject: Reject) => void) => RemoveEventListener

Starts listen for the events of searching contact info and handle match with the provided callback

Client.getInstance().onLookupAndMatchContact(async (query, resolve) => {
    try {
        const contact = await fetchContactAndMatch(query);
        resolve(contact);
    } catch (error) {
        console.log('catch', error);
    }
});

Context

getContext(): Promise<Response>

Retrieves current x-bees context data. The data may be different depending on context.

getCurrentContact(): Promise<Response>

Retrieves contact data currently opened in x-bees.

getCurrentConversation(): Promise<Response>

Retrieves conversation data ({id, type}) currently opened in x-bees. If the conversation is temporary - retrieves undefined

getThemeMode(): Promise<Response>

Retrieves current theme mode (light or dark)

getTheme(): Promise<Response>

Retrieves current theme mode and theme options

onThemeChange: (callback: ThemeChangeListenerCallback) => void;

Starts to listen for the events of changing theme and returns the provided callback

onPbxTokenChange: (callback: ListenerCallback) => void;

Starts to listen for the events of changing PBX token and returns the provided callback

onCallStarted: (callback: ListenerCallback) => void;

Starts to listen for the events of starting the call and returns the provided callback

onCallEnded: (callback: ListenerCallback) => void;

Starts to listen for the events of ending the call and returns the provided callback

off: (callback: ListenerCallback) => void;

Removes particular callback from handling events

Other

version(): string

Retrieves the version of xBeesConnect

startCall(phoneNumber: string)

Sends a request to x-bees to start a call with a number

reboot()

Sends a request to x-bees to restart the iFrame, reload with actual parameters and token

setViewport({height: number; width: number})

Sends a request to x-bees about changes of the current frame size

toClipboard(payload: string)

Sends a request to x-bees to put a string to the user's clipboard

addEventListener()

Starts listening for one of the x-bees events and returns the provided callback

removeEventListener()

Stops listening for one of the x-bees events with the particular callback

onLogout()

Starts listen on logout event and send event to the xbees about logout able

sendAnalytics()

Sends analytics data to xbees for track into analytics data

Known issues

The below function can fix cases when String.replaceAll() does not work in the mobile version. Most likely, this is some kind of WebView bug.

function replaceAll(str: string, search: string, replace: string) {
    return str.split(search).join(replace);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @wildix/xbees-connect

Weekly Downloads

245

Version

1.2.6

License

MIT

Unpacked Size

61.4 kB

Total Files

58

Last publish

Collaborators

  • gennadiy.ganchev
  • mike.lozinsky
  • dmytro.renkas
  • alex_dubovskiy
  • vladimir.gorobets.wildix
  • sergey.dartchuk
  • marina.tsymbal
  • xbeesdcoder
  • vruban.wildix
  • vitaliy.negrichuk