kod-temp
Version:
Workano Communications SDK
29 lines (28 loc) • 961 B
JavaScript
import WorkanoApiClient from '../../api-client';
export default {
name: 'List of AOR',
check: async (server, session) => {
const apiClient = new WorkanoApiClient({
server,
});
apiClient.setToken(session.token);
apiClient.disableErrorLogging();
const line = session.primaryWebRtcLine();
if (!line) {
return 'No WebRTC line for this user';
}
const { username, } = line;
try {
const aors = await apiClient.amid.getAors(username);
const nbAors = aors.length;
const availableAors = aors.filter(aor => aor.status === 'Reachable');
return `Number of AOR: ${nbAors} (${availableAors.length} Avail, ${nbAors - availableAors.length} Unavail)`;
}
catch (e) {
if (e.status === 401) {
return 'Not available for this user';
}
throw e;
}
},
};