Wazo's JavaScript Software Development Kit
The Wazo JavaScript Software Development Kit is an API wrapper making it easy for you to communicate with your Wazo server. It allows you to add Wazo functionalities to any JavaScript application you are developing.
Usage
Install / Add
You may install the Wazo JavaScript Software Development Kit to your project one of the following ways:
npm install @wazo/sdk
yarn add @wazo/sdk
Content Delivery Networks
Alternatively, you may load the Wazo SDK from a CDN. Use one of the following Content Delivery Networks:
UNPKG
<script src="https://unpkg.com/@wazo/sdk"></script>
jsDelivr
<script src="https://cdn.jsdelivr.net/npm/@wazo/sdk"></script>
Require / Import
Depending on your preference, you may require or add the Wazo SDK to your own client application one of the following ways:
const { WazoApiClient } = require('@wazo/sdk');
import { WazoApiClient } from '@wazo/sdk';
Init
const client = new WazoApiClient({
server: 'demo.wazo.community',
agent: null
});
Log In
client.auth.logIn({
expiration,
username,
password,
backend,
}).then({
metadata: {
username,
uuid_tenant_uuid,
xivo_user_uuid,
groups,
xivo_uuid,
tenants: [{ uuid }],
auth_id
},
token,
acls,
utc_expires_at,
xivo_uuid,
issued_at,
utc_issued_at,
auth_id,
expires_at,
xivo_user_uuid
});
const result = await client.auth.login();
Log Out
client.auth.logOut(token).then();
await client.auth.logOut(token);
Check token
client.auth.checkToken(token).then(valid);
// or
const valid = await client.auth.checkToken(token);
Other auth methods
client.auth.listTenants(token);
client.auth.createTenant(token, name);
client.auth.deleteTenant(token, uuid);
client.auth.listUsers(token);
client.auth.listGroups(token);
client.auth.listPolicies(token);
Application
client.application.calls(token, applicationUuid);
client.application.hangupCall(token, applicationUuid, callId);
client.application.answerCall(token, applicationUuid, callId, context, exten, autoanswer);
client.application.listNodes(token, applicationUuid);
client.application.listCallsNodes(token, applicationUuid, nodeUuid);
client.application.removeCallNodes(token, applicationUuid, nodeUuid, callId);
client.application.addCallNodes(token, applicationUuid, nodeUuid, callId);
client.application.playCall(token, applicationUuid, callId, language, uri);
Confd
client.confd.listUsers(token);
client.confd.getUser(token, userUuid);
client.confd.getUserLineSip(token, userUuid, lineId);
client.confd.listApplications(token);
Accessd
client.accessd.listSubscriptions(token);
client.accessd.createSubscription(token, { productSku, name, startDate, contractDate, autoRenew, term });
client.accessd.getSubscription(token, uuid);
client.accessd.listAuthorizations(token);
client.accessd.getAuthorization(token, uuid);
WebRTCPhone
import { WazoWebRTCClient } from '@wazo/sdk';
const config = {
wsServer: 'wss://path.to/asterisk/ws',
displayName: 'My Display Name',
authorizationUser: 'line username',
password: 'line password',
uri: 'user@server.com',
media: {
audio: document.getElementById('audio'),
video: document.getElementById('video'),
localVideo: document.getElementById('local-video')
}
};
const phone = new WazoWebRTCClient(config, callback);
phone.on('eventName', (event) => {
});
phone.call('1234');
Wazo Websocket
import { WazoWebSocketClient } from '@wazo/sdk';
const ws = new WazoWebSocket({
host,
token,
});
ws.on('eventName', (event) => {
});
ws.connect();