From 9a2e0c233696dd469da0b8ae58d8e027cad249a4 Mon Sep 17 00:00:00 2001 From: alonso-cadenas Date: Thu, 3 Aug 2023 18:16:36 +0000 Subject: [PATCH] =?UTF-8?q?Deploy=20preview=20for=20PR=20145=20?= =?UTF-8?q?=F0=9F=9B=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr-preview/pr-145/demo-minimal-js.bundle.js | 2 +- pr-preview/pr-145/demo-minimal-js.html | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pr-preview/pr-145/demo-minimal-js.bundle.js b/pr-preview/pr-145/demo-minimal-js.bundle.js index 19e5d195..28197d7e 100644 --- a/pr-preview/pr-145/demo-minimal-js.bundle.js +++ b/pr-preview/pr-145/demo-minimal-js.bundle.js @@ -26,7 +26,7 @@ return /******/ (() => { // webpackBootstrap \******************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"answerCall\": () => (/* binding */ answerCall),\n/* harmony export */ \"completeCall\": () => (/* binding */ completeCall),\n/* harmony export */ \"endCall\": () => (/* binding */ endCall),\n/* harmony export */ \"incomingCall\": () => (/* binding */ incomingCall),\n/* harmony export */ \"initialize\": () => (/* binding */ initialize),\n/* harmony export */ \"logIn\": () => (/* binding */ logIn),\n/* harmony export */ \"logOut\": () => (/* binding */ logOut),\n/* harmony export */ \"outgoingCall\": () => (/* binding */ outgoingCall),\n/* harmony export */ \"resizeWidget\": () => (/* binding */ resizeWidget),\n/* harmony export */ \"sendError\": () => (/* binding */ sendError),\n/* harmony export */ \"userAvailable\": () => (/* binding */ userAvailable),\n/* harmony export */ \"userUnavailable\": () => (/* binding */ userUnavailable)\n/* harmony export */ });\n/* harmony import */ var _src_CallingExtensions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../src/CallingExtensions */ \"../../src/CallingExtensions.js\");\n/* harmony import */ var _src_Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../src/Constants */ \"../../src/Constants.js\");\n\n\n// import CallingExtensions, { Constants } from \"@hubspot/calling-extensions-sdk\";\n// const { errorType, callEndStatus } = Constants;\n\nconst state = {\n engagementId: 0,\n phoneNumber: \"+1234\",\n userAvailable: false,\n};\n\nconst sizeInfo = {\n width: 400,\n height: 600,\n};\n\n/** Button IDs */\nconst ANSWER_CALL = \"answercall\";\nconst COMPLETE_CALL = \"completecall\";\nconst END_CALL = \"endcall\";\nconst INCOMING_CALL = \"incomingcall\";\nconst INITIALIZE = \"initialize\";\nconst LOG_IN = \"login\";\nconst LOG_OUT = \"logout\";\nconst OUTGOING_CALL = \"outgoingcall\";\nconst RESIZE_WIDGET = \"resizewidget\";\nconst SEND_ERROR = \"senderror\";\nconst USER_AVAILABLE = \"useravailable\";\nconst USER_UNAVAILABLE = \"userunavailable\";\n\nfunction disableButtons(ids) {\n ids.forEach(id => {\n document.querySelector(`#${id}`).setAttribute(\"disabled\", true);\n });\n}\n\nfunction enableButtons(ids) {\n ids.forEach(id => {\n document.querySelector(`#${id}`).removeAttribute(\"disabled\");\n });\n}\n\nconst cti = new _src_CallingExtensions__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n debugMode: true,\n eventHandlers: {\n onReady: () => {\n cti.initialized({\n isLoggedIn: false,\n sizeInfo,\n });\n disableButtons([INITIALIZE]);\n enableButtons([LOG_IN, SEND_ERROR, RESIZE_WIDGET]);\n },\n onDialNumber: (data, rawEvent) => {\n const { phoneNumber } = data;\n state.phoneNumber = phoneNumber;\n },\n onEngagementCreated: (data, rawEvent) => {\n const { engagementId } = data;\n state.engagementId = engagementId;\n },\n onEndCall: () => {\n window.setTimeout(() => {\n cti.callEnded();\n }, 500);\n },\n onVisibilityChanged: (data, rawEvent) => {},\n onCreateEngagementSucceeded: (data, rawEvent) => {\n const { engagementId } = data;\n state.engagementId = engagementId;\n },\n onCreateEngagementFailed: (data, rawEvent) => {},\n },\n});\n\nfunction initialize() {\n cti.initialized({\n isLoggedIn: false,\n });\n disableButtons([INITIALIZE]);\n enableButtons([LOG_IN, SEND_ERROR, RESIZE_WIDGET]);\n}\n\nfunction logIn() {\n cti.userLoggedIn();\n disableButtons([LOG_IN, INITIALIZE]);\n enableButtons([LOG_OUT, OUTGOING_CALL]);\n if (state.userAvailable) {\n disableButtons([USER_AVAILABLE]);\n enableButtons([INCOMING_CALL, USER_UNAVAILABLE]);\n } else {\n disableButtons([INCOMING_CALL, USER_UNAVAILABLE]);\n enableButtons([USER_AVAILABLE]);\n }\n}\n\nfunction logOut() {\n cti.userLoggedOut();\n disableButtons([\n LOG_OUT,\n OUTGOING_CALL,\n INCOMING_CALL,\n ANSWER_CALL,\n END_CALL,\n COMPLETE_CALL,\n USER_AVAILABLE,\n USER_UNAVAILABLE,\n ]);\n enableButtons([LOG_IN]);\n}\n\nfunction userAvailable() {\n cti.userAvailable();\n state.userAvailable = true;\n disableButtons([USER_AVAILABLE]);\n enableButtons([INCOMING_CALL, USER_UNAVAILABLE]);\n}\n\nfunction userUnavailable() {\n cti.userUnavailable();\n state.userAvailable = false;\n disableButtons([INCOMING_CALL, USER_UNAVAILABLE]);\n enableButtons([USER_AVAILABLE]);\n}\n\nfunction incomingCall() {\n window.setTimeout(() => {\n cti.incomingCall({\n createEngagement: \"true\",\n fromNumber: \"+123\",\n toNumber: state.phoneNumber,\n });\n }, 500);\n disableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]);\n enableButtons([ANSWER_CALL, END_CALL]);\n}\n\nfunction outgoingCall() {\n window.setTimeout(() => {\n cti.outgoingCall({\n createEngagement: \"true\",\n phoneNumber: state.phoneNumber,\n });\n }, 500);\n disableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]);\n enableButtons([ANSWER_CALL, END_CALL]);\n}\n\nfunction answerCall() {\n cti.callAnswered();\n disableButtons([ANSWER_CALL]);\n}\n\nfunction endCall() {\n cti.callEnded({\n callEndStatus: _src_Constants__WEBPACK_IMPORTED_MODULE_1__.callEndStatus.INTERNAL_COMPLETED,\n });\n disableButtons([ANSWER_CALL, END_CALL]);\n enableButtons([COMPLETE_CALL]);\n}\n\nfunction completeCall() {\n cti.callCompleted({\n engagementId: state.engagementId,\n hideWidget: false,\n });\n disableButtons([COMPLETE_CALL]);\n enableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]);\n}\n\nfunction sendError() {\n cti.sendError({\n type: _src_Constants__WEBPACK_IMPORTED_MODULE_1__.errorType.GENERIC,\n message: \"This is an error alert shown in the Hubspot UI\",\n });\n}\n\nfunction resizeWidget() {\n sizeInfo.width += 20;\n sizeInfo.height += 20;\n cti.resizeWidget({\n width: sizeInfo.width,\n height: sizeInfo.height,\n });\n}\n\n\n//# sourceURL=webpack://calling-extensions-sdk-demo-minimal-js/./index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"answerCall\": () => (/* binding */ answerCall),\n/* harmony export */ \"completeCall\": () => (/* binding */ completeCall),\n/* harmony export */ \"endCall\": () => (/* binding */ endCall),\n/* harmony export */ \"incomingCall\": () => (/* binding */ incomingCall),\n/* harmony export */ \"incomingCallAsync\": () => (/* binding */ incomingCallAsync),\n/* harmony export */ \"initialize\": () => (/* binding */ initialize),\n/* harmony export */ \"logIn\": () => (/* binding */ logIn),\n/* harmony export */ \"logOut\": () => (/* binding */ logOut),\n/* harmony export */ \"outgoingCall\": () => (/* binding */ outgoingCall),\n/* harmony export */ \"resizeWidget\": () => (/* binding */ resizeWidget),\n/* harmony export */ \"sendError\": () => (/* binding */ sendError),\n/* harmony export */ \"userAvailable\": () => (/* binding */ userAvailable),\n/* harmony export */ \"userUnavailable\": () => (/* binding */ userUnavailable)\n/* harmony export */ });\n/* harmony import */ var _src_CallingExtensions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../src/CallingExtensions */ \"../../src/CallingExtensions.js\");\n/* harmony import */ var _src_Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../src/Constants */ \"../../src/Constants.js\");\n\n\n// import CallingExtensions, { Constants } from \"@hubspot/calling-extensions-sdk\";\n// const { errorType, callEndStatus } = Constants;\n\nconst state = {\n engagementId: 0,\n phoneNumber: \"+1234\",\n userAvailable: false,\n};\n\nconst sizeInfo = {\n width: 400,\n height: 600,\n};\n\n/** Button IDs */\nconst ANSWER_CALL = \"answercall\";\nconst COMPLETE_CALL = \"completecall\";\nconst END_CALL = \"endcall\";\nconst INCOMING_CALL = \"incomingcall\";\nconst INCOMING_CALL_ASYNC = \"incomingcallasync\";\nconst INITIALIZE = \"initialize\";\nconst LOG_IN = \"login\";\nconst LOG_OUT = \"logout\";\nconst OUTGOING_CALL = \"outgoingcall\";\nconst RESIZE_WIDGET = \"resizewidget\";\nconst SEND_ERROR = \"senderror\";\nconst USER_AVAILABLE = \"useravailable\";\nconst USER_UNAVAILABLE = \"userunavailable\";\n\nfunction disableButtons(ids) {\n ids.forEach(id => {\n document.querySelector(`#${id}`).setAttribute(\"disabled\", true);\n });\n}\n\nfunction enableButtons(ids) {\n ids.forEach(id => {\n document.querySelector(`#${id}`).removeAttribute(\"disabled\");\n });\n}\n\nconst cti = new _src_CallingExtensions__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n debugMode: true,\n eventHandlers: {\n onReady: () => {\n cti.initialized({\n isLoggedIn: false,\n sizeInfo,\n });\n disableButtons([INITIALIZE]);\n enableButtons([LOG_IN, SEND_ERROR, RESIZE_WIDGET]);\n },\n onDialNumber: (data, rawEvent) => {\n const { phoneNumber } = data;\n state.phoneNumber = phoneNumber;\n },\n onEngagementCreated: (data, rawEvent) => {\n const { engagementId } = data;\n state.engagementId = engagementId;\n },\n onEndCall: () => {\n window.setTimeout(() => {\n cti.callEnded();\n }, 500);\n },\n onVisibilityChanged: (data, rawEvent) => {},\n onCreateEngagementSucceeded: (data, rawEvent) => {\n const { engagementId } = data;\n state.engagementId = engagementId;\n },\n onCreateEngagementFailed: (data, rawEvent) => {},\n },\n});\n\nfunction initialize() {\n cti.initialized({\n isLoggedIn: false,\n });\n disableButtons([INITIALIZE]);\n enableButtons([LOG_IN, SEND_ERROR, RESIZE_WIDGET]);\n}\n\nfunction logIn() {\n cti.userLoggedIn();\n disableButtons([LOG_IN, INITIALIZE]);\n enableButtons([LOG_OUT, OUTGOING_CALL]);\n if (state.userAvailable) {\n disableButtons([USER_AVAILABLE]);\n enableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);\n } else {\n disableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);\n enableButtons([USER_AVAILABLE]);\n }\n}\n\nfunction logOut() {\n cti.userLoggedOut();\n disableButtons([\n LOG_OUT,\n OUTGOING_CALL,\n INCOMING_CALL,\n ANSWER_CALL,\n END_CALL,\n COMPLETE_CALL,\n USER_AVAILABLE,\n USER_UNAVAILABLE,\n ]);\n enableButtons([LOG_IN]);\n}\n\nfunction userAvailable() {\n cti.userAvailable();\n state.userAvailable = true;\n disableButtons([USER_AVAILABLE]);\n enableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);\n}\n\nfunction userUnavailable() {\n cti.userUnavailable();\n state.userAvailable = false;\n disableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);\n enableButtons([USER_AVAILABLE]);\n}\n\nfunction incomingCall() {\n window.setTimeout(() => {\n cti.incomingCall({\n createEngagement: \"true\",\n fromNumber: \"+123\",\n toNumber: state.phoneNumber,\n });\n enableButtons([ANSWER_CALL, END_CALL]);\n }, 500);\n disableButtons([OUTGOING_CALL, INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);\n}\n\nfunction incomingCallAsync(time) {\n window.setTimeout(() => {\n cti.incomingCall({\n createEngagement: \"true\",\n fromNumber: \"+123\",\n toNumber: state.phoneNumber,\n });\n enableButtons([ANSWER_CALL, END_CALL]);\n }, time);\n disableButtons([OUTGOING_CALL, INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);\n}\n\nfunction outgoingCall() {\n window.setTimeout(() => {\n cti.outgoingCall({\n createEngagement: \"true\",\n phoneNumber: state.phoneNumber,\n });\n enableButtons([ANSWER_CALL, END_CALL]);\n }, 500);\n disableButtons([\n OUTGOING_CALL, INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE, USER_UNAVAILABLE,\n ]);\n}\n\nfunction answerCall() {\n cti.callAnswered();\n disableButtons([ANSWER_CALL]);\n}\n\nfunction endCall() {\n cti.callEnded({\n callEndStatus: _src_Constants__WEBPACK_IMPORTED_MODULE_1__.callEndStatus.INTERNAL_COMPLETED,\n });\n disableButtons([ANSWER_CALL, END_CALL]);\n enableButtons([COMPLETE_CALL]);\n}\n\nfunction completeCall() {\n cti.callCompleted({\n engagementId: state.engagementId,\n hideWidget: false,\n });\n disableButtons([COMPLETE_CALL]);\n enableButtons([OUTGOING_CALL, INCOMING_CALL,INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);\n}\n\nfunction sendError() {\n cti.sendError({\n type: _src_Constants__WEBPACK_IMPORTED_MODULE_1__.errorType.GENERIC,\n message: \"This is an error alert shown in the Hubspot UI\",\n });\n}\n\nfunction resizeWidget() {\n sizeInfo.width += 20;\n sizeInfo.height += 20;\n cti.resizeWidget({\n width: sizeInfo.width,\n height: sizeInfo.height,\n });\n}\n\n\n//# sourceURL=webpack://calling-extensions-sdk-demo-minimal-js/./index.js?"); /***/ }), diff --git a/pr-preview/pr-145/demo-minimal-js.html b/pr-preview/pr-145/demo-minimal-js.html index 909ec4c6..ec374bc1 100644 --- a/pr-preview/pr-145/demo-minimal-js.html +++ b/pr-preview/pr-145/demo-minimal-js.html @@ -140,6 +140,13 @@ value="user unavailable" />

4. Start a call

+