From 3c9f2d0d611d22ab46f79432b038feae0d4e45d6 Mon Sep 17 00:00:00 2001 From: Bharath Balan <62698609+bhabalan@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:38:10 +0530 Subject: [PATCH 1/2] feat(cc): getBuddyAgents() implementation --- docs/samples/contact-center/app.js | 26 +++++++++- docs/samples/contact-center/index.html | 11 +++-- packages/@webex/plugin-cc/src/cc.ts | 35 +++++++++++++- .../@webex/plugin-cc/src/features/Agent.ts | 25 +++++++++- .../plugin-cc/src/services/AgentService.ts | 45 ++++++++++++++++- .../plugin-cc/src/services/HttpRequest.ts | 14 +++++- .../plugin-cc/src/services/constants.ts | 7 +++ .../@webex/plugin-cc/src/services/types.ts | 30 ++++++++++++ packages/@webex/plugin-cc/src/types.ts | 22 +++++++++ .../test/unit/spec/features/Agent.ts | 48 ++++++++++++++++++- 10 files changed, 249 insertions(+), 14 deletions(-) diff --git a/docs/samples/contact-center/app.js b/docs/samples/contact-center/app.js index 5776f561046..5edeed138bf 100644 --- a/docs/samples/contact-center/app.js +++ b/docs/samples/contact-center/app.js @@ -148,11 +148,33 @@ async function handleAgentLogin(e) { } } +async function fetchBuddyAgents() { + try { + const buddyAgents = await webex.cc.getBuddyAgents({mediaType:'telephony', state: 'Available'}); + const buddyAgentsList = document.getElementById('buddyAgentsList'); + buddyAgentsList.innerHTML = ''; // Clear previous list + + if( buddyAgents.length === 0 ){ + buddyAgentsList.innerHTML = 'No buddy agents available'; + return; + } + + buddyAgents.forEach((agent) => { + const listItem = document.createElement('li'); + listItem.textContent = `${agent.agentName} - ${agent.state}`; + listItem.setAttribute('data-agent-id', agent.agentId); + buddyAgentsList.appendChild(listItem); + }); + } catch (error) { + buddyAgentsList.innerHTML = `Failed to fetch buddy agents, ${error}`; // Clear previous list + console.log('Failed to fetch buddy agents', error); + } +} + function doAgentLogin() { webex.cc.stationLogin({teamId: teamsDropdown.value, loginOption: agentDeviceType, dialNumber: dialNumber.value}).then((response) => { console.log('Agent Logged in successfully', response); - } - ).catch((error) => { + }).catch((error) => { console.log('Agent Login failed', error); }); } diff --git a/docs/samples/contact-center/index.html b/docs/samples/contact-center/index.html index f6a2cdbf6e1..8cbef2498b4 100644 --- a/docs/samples/contact-center/index.html +++ b/docs/samples/contact-center/index.html @@ -80,7 +80,7 @@