@unblu/floating-js-api 7.37.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +184 -0
- package/README.md +26 -0
- package/dist/lib/index.d.ts +93 -0
- package/dist/lib/index.js +49 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/internal/internal-api.d.ts +18 -0
- package/dist/lib/internal/internal-api.js +20 -0
- package/dist/lib/internal/internal-api.js.map +1 -0
- package/dist/lib/internal/module/general-lazy-module.d.ts +17 -0
- package/dist/lib/internal/module/general-lazy-module.js +16 -0
- package/dist/lib/internal/module/general-lazy-module.js.map +1 -0
- package/dist/lib/internal/module/general-module.d.ts +31 -0
- package/dist/lib/internal/module/general-module.js +37 -0
- package/dist/lib/internal/module/general-module.js.map +1 -0
- package/dist/lib/internal/module/meta-module.d.ts +17 -0
- package/dist/lib/internal/module/meta-module.js +19 -0
- package/dist/lib/internal/module/meta-module.js.map +1 -0
- package/dist/lib/model/individualui_component.d.ts +29 -0
- package/dist/lib/model/individualui_component.js +2 -0
- package/dist/lib/model/individualui_component.js.map +1 -0
- package/dist/lib/model/individualui_state.d.ts +14 -0
- package/dist/lib/model/individualui_state.js +2 -0
- package/dist/lib/model/individualui_state.js.map +1 -0
- package/dist/lib/shared/api-state.d.ts +8 -0
- package/dist/lib/shared/api-state.js +10 -0
- package/dist/lib/shared/api-state.js.map +1 -0
- package/dist/lib/shared/conversation.d.ts +320 -0
- package/dist/lib/shared/conversation.js +384 -0
- package/dist/lib/shared/conversation.js.map +1 -0
- package/dist/lib/shared/internal/api-bridge.d.ts +36 -0
- package/dist/lib/shared/internal/api-bridge.js +97 -0
- package/dist/lib/shared/internal/api-bridge.js.map +1 -0
- package/dist/lib/shared/internal/event.d.ts +6 -0
- package/dist/lib/shared/internal/event.js +2 -0
- package/dist/lib/shared/internal/event.js.map +1 -0
- package/dist/lib/shared/internal/initialized-unblu-api.d.ts +6 -0
- package/dist/lib/shared/internal/initialized-unblu-api.js +2 -0
- package/dist/lib/shared/internal/initialized-unblu-api.js.map +1 -0
- package/dist/lib/shared/internal/initialized-unblu-element.d.ts +6 -0
- package/dist/lib/shared/internal/initialized-unblu-element.js +2 -0
- package/dist/lib/shared/internal/initialized-unblu-element.js.map +1 -0
- package/dist/lib/shared/internal/java-error-codes.d.ts +5 -0
- package/dist/lib/shared/internal/java-error-codes.js +6 -0
- package/dist/lib/shared/internal/java-error-codes.js.map +1 -0
- package/dist/lib/shared/internal/module/agent-availability-module.d.ts +14 -0
- package/dist/lib/shared/internal/module/agent-availability-module.js +13 -0
- package/dist/lib/shared/internal/module/agent-availability-module.js.map +1 -0
- package/dist/lib/shared/internal/module/base-general-module.d.ts +31 -0
- package/dist/lib/shared/internal/module/base-general-module.js +46 -0
- package/dist/lib/shared/internal/module/base-general-module.js.map +1 -0
- package/dist/lib/shared/internal/module/conversation-module.d.ts +57 -0
- package/dist/lib/shared/internal/module/conversation-module.js +49 -0
- package/dist/lib/shared/internal/module/conversation-module.js.map +1 -0
- package/dist/lib/shared/internal/module/module.d.ts +10 -0
- package/dist/lib/shared/internal/module/module.js +16 -0
- package/dist/lib/shared/internal/module/module.js.map +1 -0
- package/dist/lib/shared/internal/unblu-api-factory.d.ts +9 -0
- package/dist/lib/shared/internal/unblu-api-factory.js +2 -0
- package/dist/lib/shared/internal/unblu-api-factory.js.map +1 -0
- package/dist/lib/shared/internal/unblu-util.d.ts +63 -0
- package/dist/lib/shared/internal/unblu-util.js +220 -0
- package/dist/lib/shared/internal/unblu-util.js.map +1 -0
- package/dist/lib/shared/internal/util/event-emitter.d.ts +44 -0
- package/dist/lib/shared/internal/util/event-emitter.js +85 -0
- package/dist/lib/shared/internal/util/event-emitter.js.map +1 -0
- package/dist/lib/shared/model/agent-availability-state.d.ts +18 -0
- package/dist/lib/shared/model/agent-availability-state.js +20 -0
- package/dist/lib/shared/model/agent-availability-state.js.map +1 -0
- package/dist/lib/shared/model/call-state.d.ts +26 -0
- package/dist/lib/shared/model/call-state.js +28 -0
- package/dist/lib/shared/model/call-state.js.map +1 -0
- package/dist/lib/shared/model/configuration.d.ts +46 -0
- package/dist/lib/shared/model/configuration.js +2 -0
- package/dist/lib/shared/model/configuration.js.map +1 -0
- package/dist/lib/shared/model/connection-state.d.ts +27 -0
- package/dist/lib/shared/model/connection-state.js +29 -0
- package/dist/lib/shared/model/connection-state.js.map +1 -0
- package/dist/lib/shared/model/conversation-info.d.ts +34 -0
- package/dist/lib/shared/model/conversation-info.js +2 -0
- package/dist/lib/shared/model/conversation-info.js.map +1 -0
- package/dist/lib/shared/model/conversation-message-info.d.ts +14 -0
- package/dist/lib/shared/model/conversation-message-info.js +2 -0
- package/dist/lib/shared/model/conversation-message-info.js.map +1 -0
- package/dist/lib/shared/model/conversation-recipient-type.d.ts +10 -0
- package/dist/lib/shared/model/conversation-recipient-type.js +12 -0
- package/dist/lib/shared/model/conversation-recipient-type.js.map +1 -0
- package/dist/lib/shared/model/conversation-recipient.d.ts +14 -0
- package/dist/lib/shared/model/conversation-recipient.js +2 -0
- package/dist/lib/shared/model/conversation-recipient.js.map +1 -0
- package/dist/lib/shared/model/conversation-state.d.ts +37 -0
- package/dist/lib/shared/model/conversation-state.js +39 -0
- package/dist/lib/shared/model/conversation-state.js.map +1 -0
- package/dist/lib/shared/model/conversation-type.d.ts +43 -0
- package/dist/lib/shared/model/conversation-type.js +45 -0
- package/dist/lib/shared/model/conversation-type.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-action-invocation.d.ts +27 -0
- package/dist/lib/shared/model/customaction/custom-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.d.ts +6 -0
- package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-message-action-invocation.d.ts +16 -0
- package/dist/lib/shared/model/customaction/custom-message-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-message-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-person-action-invocation.d.ts +11 -0
- package/dist/lib/shared/model/customaction/custom-person-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-person-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/invitation-status.d.ts +14 -0
- package/dist/lib/shared/model/invitation-status.js +16 -0
- package/dist/lib/shared/model/invitation-status.js.map +1 -0
- package/dist/lib/shared/model/invitation.d.ts +24 -0
- package/dist/lib/shared/model/invitation.js +2 -0
- package/dist/lib/shared/model/invitation.js.map +1 -0
- package/dist/lib/shared/model/new-conversation-interceptor-result.d.ts +14 -0
- package/dist/lib/shared/model/new-conversation-interceptor-result.js +2 -0
- package/dist/lib/shared/model/new-conversation-interceptor-result.js.map +1 -0
- package/dist/lib/shared/model/person-info.d.ts +4 -0
- package/dist/lib/shared/model/person-info.js +2 -0
- package/dist/lib/shared/model/person-info.js.map +1 -0
- package/dist/lib/shared/new-conversation-interceptor.d.ts +24 -0
- package/dist/lib/shared/new-conversation-interceptor.js +2 -0
- package/dist/lib/shared/new-conversation-interceptor.js.map +1 -0
- package/dist/lib/shared/unblu-api-error.d.ts +117 -0
- package/dist/lib/shared/unblu-api-error.js +122 -0
- package/dist/lib/shared/unblu-api-error.js.map +1 -0
- package/dist/lib/unblu-api-ui.d.ts +137 -0
- package/dist/lib/unblu-api-ui.js +199 -0
- package/dist/lib/unblu-api-ui.js.map +1 -0
- package/dist/lib/unblu-api.d.ts +363 -0
- package/dist/lib/unblu-api.js +433 -0
- package/dist/lib/unblu-api.js.map +1 -0
- package/dist/lib/unblu-static-api.d.ts +237 -0
- package/dist/lib/unblu-static-api.js +318 -0
- package/dist/lib/unblu-static-api.js.map +1 -0
- package/package.json +23 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { UnbluApiError, UnbluErrorType } from './unblu-api-error';
|
|
2
|
+
import { EventEmitter } from './internal/util/event-emitter';
|
|
3
|
+
/**
|
|
4
|
+
* #### This class gives API access to the currently active conversation.
|
|
5
|
+
*
|
|
6
|
+
* As long as a conversation is active one can register and receive the events provided by this class and call the methods.
|
|
7
|
+
* Once the conversation is closed this API object will be destroyed and no more event callbacks will be called.
|
|
8
|
+
* Any subsequent calls will fail.
|
|
9
|
+
*
|
|
10
|
+
* Use the {@link CLOSE} event to de-init any code connected to this conversation.
|
|
11
|
+
*/
|
|
12
|
+
export class Conversation {
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
constructor(conversationModule, conversationId) {
|
|
17
|
+
this.conversationModule = conversationModule;
|
|
18
|
+
this.conversationId = conversationId;
|
|
19
|
+
this.eventEmitter = new EventEmitter();
|
|
20
|
+
this.internalListeners = {};
|
|
21
|
+
this.destroyed = false;
|
|
22
|
+
// clean up all listeners when the conversation disconnects.
|
|
23
|
+
this.on(Conversation.CLOSE, () => this.destroy());
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Adds a listener.
|
|
27
|
+
* @param event The event to register.
|
|
28
|
+
* @param listener The listener to register.
|
|
29
|
+
*/
|
|
30
|
+
on(event, listener) {
|
|
31
|
+
this.checkNotDestroyed();
|
|
32
|
+
const needsInternalSubscription = !this.eventEmitter.hasListeners(event);
|
|
33
|
+
this.eventEmitter.on(event, listener);
|
|
34
|
+
if (needsInternalSubscription)
|
|
35
|
+
this.onInternal(event);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Removes a previously registered listener.
|
|
39
|
+
* @param event The event to unregister from.
|
|
40
|
+
* @param listener The listener to remove.
|
|
41
|
+
*/
|
|
42
|
+
off(event, listener) {
|
|
43
|
+
this.checkNotDestroyed();
|
|
44
|
+
const removed = this.eventEmitter.off(event, listener);
|
|
45
|
+
if (!this.eventEmitter.hasListeners(event))
|
|
46
|
+
this.offInternal(event);
|
|
47
|
+
return removed;
|
|
48
|
+
}
|
|
49
|
+
onInternal(eventName) {
|
|
50
|
+
let internalListener;
|
|
51
|
+
switch (eventName) {
|
|
52
|
+
case Conversation.CONNECTION_STATE_CHANGE:
|
|
53
|
+
internalListener = (event) => {
|
|
54
|
+
if (event.data.conversationId == this.conversationId)
|
|
55
|
+
this.eventEmitter.emit(event.name, event.data.connectionState);
|
|
56
|
+
};
|
|
57
|
+
break;
|
|
58
|
+
case Conversation.CONVERSATION_STATE_CHANGE:
|
|
59
|
+
internalListener = (event) => {
|
|
60
|
+
if (event.data.conversationId == this.conversationId)
|
|
61
|
+
this.eventEmitter.emit(event.name, event.data.conversationState);
|
|
62
|
+
};
|
|
63
|
+
break;
|
|
64
|
+
case Conversation.CALL_STATE_CHANGE:
|
|
65
|
+
internalListener = (event) => {
|
|
66
|
+
if (event.data.conversationId == this.conversationId)
|
|
67
|
+
this.eventEmitter.emit(event.name, event.data.callState);
|
|
68
|
+
};
|
|
69
|
+
break;
|
|
70
|
+
case Conversation.INVITATIONS_CHANGE:
|
|
71
|
+
internalListener = (event) => {
|
|
72
|
+
if (event.data.conversationId == this.conversationId)
|
|
73
|
+
this.eventEmitter.emit(event.name, event.data.invitations);
|
|
74
|
+
};
|
|
75
|
+
break;
|
|
76
|
+
case Conversation.CUSTOM_ACTION_INVOCATION:
|
|
77
|
+
internalListener = (event) => {
|
|
78
|
+
if (event.data.conversation.id == this.conversationId)
|
|
79
|
+
this.eventEmitter.emit(event.name, event.data);
|
|
80
|
+
};
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
internalListener = (event) => {
|
|
84
|
+
if (event.data == this.conversationId) {
|
|
85
|
+
this.eventEmitter.emit(event.name);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
this.internalListeners[eventName] = internalListener;
|
|
91
|
+
this.conversationModule.on(eventName, internalListener).catch(e => console.warn('Error registering internal listener for event:', eventName, 'error:' + e, e));
|
|
92
|
+
}
|
|
93
|
+
offInternal(eventName) {
|
|
94
|
+
const listener = this.internalListeners[eventName];
|
|
95
|
+
if (listener == null)
|
|
96
|
+
return;
|
|
97
|
+
delete this.internalListeners[eventName];
|
|
98
|
+
this.conversationModule.off(eventName, listener).catch(e => console.warn('Error removing internal listener for event:', eventName, 'error:' + e, e));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns the ID of this conversation.
|
|
102
|
+
*/
|
|
103
|
+
getConversationId() {
|
|
104
|
+
return this.conversationId;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns the current connection state the conversation is in.
|
|
108
|
+
*
|
|
109
|
+
* If the connection is lost, the conversation will automatically try to reconnect using an exponential back-off strategy.
|
|
110
|
+
* If a fatal error is detected, the state will change to {@link ConnectionState.ERROR}.
|
|
111
|
+
*
|
|
112
|
+
* If this happens, the conversation is in it's terminal state. A dialog or other UI will be displayed to the user with details on the failure.
|
|
113
|
+
* The conversation is not automatically closed in this case.
|
|
114
|
+
* It may either be closed through a manual action by the visitor (confirming the error) or via the API.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link CONNECTION_STATE_CHANGE} if you need to listen to changes.
|
|
117
|
+
* @return A promise that resolves to the current connection state of the conversation
|
|
118
|
+
* or is rejected with a {@link UnbluApiError} if the call fails.
|
|
119
|
+
*/
|
|
120
|
+
async getConnectionState() {
|
|
121
|
+
this.checkNotDestroyed();
|
|
122
|
+
return this.conversationModule.getConnectionState(this.conversationId);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns the current state the conversation is in.
|
|
126
|
+
* @return A promise that resolves to the current state of the conversation
|
|
127
|
+
* or is rejected with a {@link UnbluApiError} if the call fails.
|
|
128
|
+
*/
|
|
129
|
+
async getConversationState() {
|
|
130
|
+
this.checkNotDestroyed();
|
|
131
|
+
return this.conversationModule.getConversationState(this.conversationId);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @see {@link CALL_STATE_CHANGE} if you need to listen to changes.
|
|
135
|
+
* @return A promise that resolves to the current call state of the local user
|
|
136
|
+
* or is rejected with a {@link UnbluApiError} if the call fails.
|
|
137
|
+
*/
|
|
138
|
+
async getCallState() {
|
|
139
|
+
this.checkNotDestroyed();
|
|
140
|
+
return this.conversationModule.getCallState(this.conversationId);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Creates a new PIN invitation for this conversation.
|
|
144
|
+
*
|
|
145
|
+
* - If the local person doesn't have the right to invite a visitor,
|
|
146
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
147
|
+
* @see {@link INVITATIONS_CHANGE} if you need to listen to changes for new invitations on this conversation.
|
|
148
|
+
* @return A promise that resolves to a new {@link Invitation} object with all relevant metadata.
|
|
149
|
+
* or is rejected with a {@link UnbluApiError} if the call fails.
|
|
150
|
+
*/
|
|
151
|
+
async createAnonymousPinInvitation() {
|
|
152
|
+
this.checkNotDestroyed();
|
|
153
|
+
return this.conversationModule.createAnonymousPinInvitation(this.conversationId);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Creates a new EMail invitation for this conversation.
|
|
157
|
+
*
|
|
158
|
+
* - If the local person doesn't have the right to invite a visitor,
|
|
159
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
160
|
+
* - If a non valid email address is provided,
|
|
161
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.INVALID_FUNCTION_ARGUMENTS}.
|
|
162
|
+
* @param email The email which the invitation should be send. It must be a valid email address.
|
|
163
|
+
* @see {@link INVITATIONS_CHANGE} If you need to listen to changes for new invitations on this conversation.
|
|
164
|
+
* @return A promise that resolves to a new {@link Invitation} object with all relevant metadata.
|
|
165
|
+
* or is rejected with a {@link UnbluApiError} if the call fails.
|
|
166
|
+
*/
|
|
167
|
+
async createAnonymousEmailInvitation(email) {
|
|
168
|
+
this.checkNotDestroyed();
|
|
169
|
+
return this.conversationModule.createAnonymousEmailInvitation(this.conversationId, email);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Revoke an invitation.
|
|
173
|
+
*
|
|
174
|
+
* - If the local person doesn't have the right to invite a visitor,
|
|
175
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
176
|
+
* @param invitationId The invitation id.
|
|
177
|
+
* @return A Promise that resolves to null or is rejected with a {@link UnbluApiError} if the call fails.
|
|
178
|
+
*/
|
|
179
|
+
async revokeInvitation(invitationId) {
|
|
180
|
+
this.checkNotDestroyed();
|
|
181
|
+
return this.conversationModule.revokeInvitation(this.conversationId, invitationId);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Renews an invitation PIN if the invitation is expired.
|
|
185
|
+
*
|
|
186
|
+
* - If the local person doesn't have the right to invite a visitor,
|
|
187
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
188
|
+
* @param invitationId The invitation id.
|
|
189
|
+
* @return A promise that resolves to a new {@link Invitation} object with all relevant metadata.
|
|
190
|
+
*/
|
|
191
|
+
async renewInvitationPin(invitationId) {
|
|
192
|
+
this.checkNotDestroyed();
|
|
193
|
+
return this.conversationModule.renewInvitationPin(this.conversationId, invitationId);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Set custom visitor data on the conversation.
|
|
197
|
+
*
|
|
198
|
+
* @param visitorData Custom data for the visitor in any format.
|
|
199
|
+
*/
|
|
200
|
+
async setVisitorData(visitorData) {
|
|
201
|
+
this.checkNotDestroyed();
|
|
202
|
+
return this.conversationModule.setVisitorData(visitorData);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get all visitor invitations created by the local person for this conversation.
|
|
206
|
+
* @return A promise that resolves to a new {@link Invitation} array with all relevant metadata.
|
|
207
|
+
* or is rejected with a {@link UnbluApiError} if the call fails.
|
|
208
|
+
*/
|
|
209
|
+
async getInvitations() {
|
|
210
|
+
this.checkNotDestroyed();
|
|
211
|
+
return this.conversationModule.getInvitations(this.conversationId);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Starts a voice call in this conversation.
|
|
215
|
+
*
|
|
216
|
+
* - If a call is already active, this call will be ignored.
|
|
217
|
+
* - If the local person doesn't have the right to start a voice call,
|
|
218
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
219
|
+
* @see {@link CALL_STATE_CHANGE} If you need to listen to changes.
|
|
220
|
+
* @return A Promise that resolves to null or is rejected with a {@link UnbluApiError} if the call fails.
|
|
221
|
+
*/
|
|
222
|
+
async startAudioCall() {
|
|
223
|
+
this.checkNotDestroyed();
|
|
224
|
+
return this.conversationModule.startAudioCall(this.conversationId);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Starts a video call in this conversation.
|
|
228
|
+
*
|
|
229
|
+
* - If a call is already active, this call will be ignored.
|
|
230
|
+
* - If the local person doesn't have the right to start a video call,
|
|
231
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
232
|
+
* @see {@link CALL_STATE_CHANGE} If you need to listen to changes.
|
|
233
|
+
* @return A Promise that resolves to null or is rejected with a {@link UnbluApiError} if the call fails.
|
|
234
|
+
*/
|
|
235
|
+
async startVideoCall() {
|
|
236
|
+
this.checkNotDestroyed();
|
|
237
|
+
return this.conversationModule.startVideoCall(this.conversationId);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Ends and closes this conversation.
|
|
241
|
+
*
|
|
242
|
+
* If the local person doesn't have the right to end the conversation,
|
|
243
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
244
|
+
* @see {@link END} fired after this call.
|
|
245
|
+
* @see {@link closeConversation} for details on closing a conversation.
|
|
246
|
+
* @return A Promise that resolves to null or is rejected with a {@link UnbluApiError} if the call fails.
|
|
247
|
+
*/
|
|
248
|
+
async endConversation() {
|
|
249
|
+
this.checkNotDestroyed();
|
|
250
|
+
return this.conversationModule.endConversation(this.conversationId);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Leaves and closes this conversation.
|
|
254
|
+
*
|
|
255
|
+
* By leaving, the visitor is removed from the active participant list of the conversation.
|
|
256
|
+
* Once a conversation is left, the visitor can not re-open it. It will not be visible in the conversation history either.
|
|
257
|
+
*
|
|
258
|
+
* If the local person doesn't have the right to leave the conversation,
|
|
259
|
+
* the returned promise will be rejected with the unblu error type {@link UnbluErrorType.ACTION_NOT_GRANTED}.
|
|
260
|
+
* @see {@link CLOSE} fired after this call.
|
|
261
|
+
* @see {@link closeConversation} for details on closing a conversation without leaving.
|
|
262
|
+
* @return A Promise that resolves to null or is rejected with a {@link UnbluApiError} if the call fails.
|
|
263
|
+
*/
|
|
264
|
+
async leaveConversation() {
|
|
265
|
+
this.checkNotDestroyed();
|
|
266
|
+
return this.conversationModule.leaveConversation(this.conversationId);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Closes this conversation locally.
|
|
270
|
+
*
|
|
271
|
+
* When called, the connection to this conversation is closed and the overview is displayed.
|
|
272
|
+
*
|
|
273
|
+
* **Note that:**
|
|
274
|
+
* - Closing does NOT end the conversation.
|
|
275
|
+
* - The person does NOT leave the conversation.
|
|
276
|
+
* - All Conversation api instances for this conversation will be destroyed.
|
|
277
|
+
*
|
|
278
|
+
* The conversation can be joined again either via the UI or using {@link UnbluApi.openConversation}.
|
|
279
|
+
* @see {@link CLOSE} fired after this call.
|
|
280
|
+
* @see {@link endConversation} for details on ending a conversation.
|
|
281
|
+
* @see {@link leavingConversation} for details on leaving a conversation.
|
|
282
|
+
* @see {@link destroy} for details on destroying a conversation.
|
|
283
|
+
* @return A Promise that resolves to null or is rejected with a {@link UnbluApiError} if the call fails.
|
|
284
|
+
*/
|
|
285
|
+
async closeConversation() {
|
|
286
|
+
this.checkNotDestroyed();
|
|
287
|
+
return this.conversationModule.closeConversation(this.conversationId);
|
|
288
|
+
}
|
|
289
|
+
checkNotDestroyed() {
|
|
290
|
+
if (this.destroyed)
|
|
291
|
+
throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Error: trying to execute method on destroyed conversation object.');
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Returns weather this conversation is destroyed or not.
|
|
295
|
+
*
|
|
296
|
+
* Conversations are destroyed if {@link destroy} is called or the conversation is closed.
|
|
297
|
+
* This usually happens when the user navigates back to an overview or into an other conversation.
|
|
298
|
+
* @see {@link destroy}
|
|
299
|
+
* @see {@link CLOSE}
|
|
300
|
+
* @return Weather this conversation is destroyed or not.
|
|
301
|
+
*/
|
|
302
|
+
isDestroyed() {
|
|
303
|
+
return this.destroyed;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Destroys this conversation API instance.
|
|
307
|
+
*
|
|
308
|
+
* Calling destroy will unregister all event listeners and prohibit any further calls to this object.
|
|
309
|
+
* Once the conversation is destroyed, any subsequent calls will reject the returned promise with {@link UnbluErrorType.ILLEGAL_STATE} as the reason.
|
|
310
|
+
*
|
|
311
|
+
* **Note that:**
|
|
312
|
+
* - Destroying does NOT close the conversation .
|
|
313
|
+
* - Destroying does NOT end the conversation.
|
|
314
|
+
* - Destroying does NOT leave the conversation.
|
|
315
|
+
* - Other instances of the same Conversation will NOT be destroyed.
|
|
316
|
+
*
|
|
317
|
+
* This call simply destroys this local API instance to the conversation.
|
|
318
|
+
*
|
|
319
|
+
* A destroyed but still open conversation can be accessed again using {@link UnbluApi.getActiveConversation}.
|
|
320
|
+
*
|
|
321
|
+
* @see {@link isDestroyed}
|
|
322
|
+
* @see {@link closeConversation} for details on how to close a conversation
|
|
323
|
+
* @see {@link endConversation} for details on how to end a conversation
|
|
324
|
+
*/
|
|
325
|
+
destroy() {
|
|
326
|
+
if (this.destroyed)
|
|
327
|
+
return;
|
|
328
|
+
this.destroyed = true;
|
|
329
|
+
this.eventEmitter.reset();
|
|
330
|
+
for (let event in this.internalListeners) {
|
|
331
|
+
this.offInternal(event);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Event emitted when the {@link ConnectionState} of this conversation changes.
|
|
337
|
+
* @event connectionStateChange
|
|
338
|
+
* @see {@link on} for listener registration
|
|
339
|
+
*/
|
|
340
|
+
Conversation.CONNECTION_STATE_CHANGE = 'connectionStateChange';
|
|
341
|
+
/**
|
|
342
|
+
* Event emitted when the {@link ConversationState} of this conversation changes.
|
|
343
|
+
* @event conversationStateChange
|
|
344
|
+
* @see {@link on} for listener registration
|
|
345
|
+
*/
|
|
346
|
+
Conversation.CONVERSATION_STATE_CHANGE = 'conversationStateChange';
|
|
347
|
+
/**
|
|
348
|
+
* Event emitted when the {@link CallState} of this conversation changes.
|
|
349
|
+
* @event callStateChange
|
|
350
|
+
* @see {@link on} for listener registration
|
|
351
|
+
*/
|
|
352
|
+
Conversation.CALL_STATE_CHANGE = 'callStateChange';
|
|
353
|
+
/**
|
|
354
|
+
* Event emitted when the conversation ends.
|
|
355
|
+
* @deprecated The end event is not always available, depending on the configuration. Use the {@link CONVERSATION_STATE_CHANGE} event instead.
|
|
356
|
+
* @event end
|
|
357
|
+
* @see {@link on} for listener registration
|
|
358
|
+
*/
|
|
359
|
+
Conversation.END = 'end';
|
|
360
|
+
/**
|
|
361
|
+
* Event emitted when the conversation is closed.
|
|
362
|
+
*
|
|
363
|
+
* This may happen due to a UI-navigation or an API-call.
|
|
364
|
+
*
|
|
365
|
+
* @event close
|
|
366
|
+
* @see {@link on} for listener registration
|
|
367
|
+
*/
|
|
368
|
+
Conversation.CLOSE = 'close';
|
|
369
|
+
/**
|
|
370
|
+
* Event emitted when an {@link Invitation} is added to or removed from this conversation, or if an existing invitation changes.
|
|
371
|
+
* The event emits an array of all visitor invitations created by the local person, all other invitations will not be present.
|
|
372
|
+
* @event invitationsChange
|
|
373
|
+
* @see {@link on} for listener registration
|
|
374
|
+
*/
|
|
375
|
+
Conversation.INVITATIONS_CHANGE = 'invitationsChange';
|
|
376
|
+
/**
|
|
377
|
+
* Event emitted every time a custom action is configured to trigger a JS API event for the current client when a custom action is invoked
|
|
378
|
+
*
|
|
379
|
+
* @event customActionInvocation
|
|
380
|
+
* @see {@link CustomActionInvocationListener}
|
|
381
|
+
* @see {@link on} for listener registration
|
|
382
|
+
*/
|
|
383
|
+
Conversation.CUSTOM_ACTION_INVOCATION = 'customActionInvocation';
|
|
384
|
+
//# sourceMappingURL=conversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/shared/conversation.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAC,YAAY,EAAW,MAAM,+BAA+B,CAAA;AAgBpE;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IA8DrB;;OAEG;IACH,YAAoB,kBAAsC,EAAU,cAAsB;QAAtE,uBAAkB,GAAlB,kBAAkB,CAAoB;QAAU,mBAAc,GAAd,cAAc,CAAQ;QAPlF,iBAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QACjC,sBAAiB,GAAqC,EAAE,CAAA;QACxD,cAAS,GAAG,KAAK,CAAA;QAMrB,4DAA4D;QAC5D,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACrD,CAAC;IA4DD;;;;OAIG;IACI,EAAE,CAAC,KAA4B,EAAE,QAAkB;QACtD,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxB,MAAM,yBAAyB,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QACxE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,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G;AACoB,8BAAiB,GAAsB,iBAAiB,AAAvC,CAAuC;AAE/E;;;;;GAKG;AACoB,gBAAG,GAAU,KAAK,AAAf,CAAe;AAEzC;;;;;;;GAOG;AACoB,kBAAK,GAAY,OAAO,AAAnB,CAAmB;AAE/C;;;;;GAKG;AACoB,+BAAkB,GAAwB,mBAAmB,AAA3C,CAA2C;AAEpF;;;;;;GAMG;AACoB,qCAAwB,GAA6B,wBAAwB,AAArD,CAAqD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EventCallback } from './event';
|
|
2
|
+
export declare class ApiBridge {
|
|
3
|
+
private mountPoint;
|
|
4
|
+
private mountName;
|
|
5
|
+
private internal;
|
|
6
|
+
private readonly eventHandler;
|
|
7
|
+
/**
|
|
8
|
+
* instantiates the bridge that links the UNBLU internal API provided by the collaboration server with the UNBLU JS-API
|
|
9
|
+
* @param mountPoint the global unblu object under which the internal API is registered.
|
|
10
|
+
*/
|
|
11
|
+
constructor(mountPoint: any, mountName: string);
|
|
12
|
+
waitUntilLoaded(timeout: number, promise?: Promise<void>): Promise<void>;
|
|
13
|
+
private checkLoaded;
|
|
14
|
+
checkCompatibility(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Calls an API function of the internal unblu collaboration server API.
|
|
17
|
+
* @param moduleName The module to which the function belongs.
|
|
18
|
+
* @param functionName The function to call.
|
|
19
|
+
* @param args The arguments to pass to the function.
|
|
20
|
+
*/
|
|
21
|
+
callApiFunction(moduleName: string, functionName: string, args: any[]): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Registers a callback for an event emitted by the internal unblu collaboration server API.
|
|
24
|
+
* @param module The module that emits the event.
|
|
25
|
+
* @param event The event name.
|
|
26
|
+
* @param callback The callback which will be called every time the event is emitted.
|
|
27
|
+
*/
|
|
28
|
+
on(module: string, event: string, callback: EventCallback): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Unregisters a callback for an event emitted by the internal unblu collaboration server API.
|
|
31
|
+
* @param module The module that emits the event.
|
|
32
|
+
* @param event The event name.
|
|
33
|
+
* @param callback Optionally callback which will be removed, if none is provided all listeners of the event will be removed.
|
|
34
|
+
*/
|
|
35
|
+
off(module: string, event: string, callback?: EventCallback): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { UnbluApiError, UnbluErrorType } from '../unblu-api-error';
|
|
2
|
+
import { CATEGORY_ACTION_NOT_GRANTED, CATEGORY_EXECUTION_EXCEPTION, CATEGORY_INVALID_FUNCTION_ARGUMENTS, CATEGORY_INVALID_FUNCTION_CALL, CATEGORY_TIMEOUT } from './java-error-codes';
|
|
3
|
+
const SUPPORTED_MAJOR_VERSION = 2;
|
|
4
|
+
export class ApiBridge {
|
|
5
|
+
/**
|
|
6
|
+
* instantiates the bridge that links the UNBLU internal API provided by the collaboration server with the UNBLU JS-API
|
|
7
|
+
* @param mountPoint the global unblu object under which the internal API is registered.
|
|
8
|
+
*/
|
|
9
|
+
constructor(mountPoint, mountName) {
|
|
10
|
+
this.mountPoint = mountPoint;
|
|
11
|
+
this.mountName = mountName;
|
|
12
|
+
}
|
|
13
|
+
async waitUntilLoaded(timeout, promise) {
|
|
14
|
+
const timeoutTimestamp = Date.now() + timeout;
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const waitForLoaded = () => {
|
|
17
|
+
if (timeoutTimestamp - Date.now() > 0) {
|
|
18
|
+
if (this.checkLoaded())
|
|
19
|
+
return resolve();
|
|
20
|
+
setTimeout(waitForLoaded, 50);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
reject(new UnbluApiError(UnbluErrorType.INITIALIZATION_TIMEOUT, 'Timeout while waiting for collaboration server API to be loaded.'));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
waitForLoaded();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
checkLoaded() {
|
|
30
|
+
const error = this.mountPoint['loadError'];
|
|
31
|
+
if (error) {
|
|
32
|
+
throw new UnbluApiError(error.type, error.detail);
|
|
33
|
+
}
|
|
34
|
+
this.internal = this.mountPoint[this.mountName];
|
|
35
|
+
return this.internal != null;
|
|
36
|
+
}
|
|
37
|
+
checkCompatibility() {
|
|
38
|
+
if (!this.internal) {
|
|
39
|
+
throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, 'Incompatible unblu collaboration server, no API bridge provided.');
|
|
40
|
+
}
|
|
41
|
+
else if (typeof this.internal.getApiVersion !== 'function') {
|
|
42
|
+
throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, 'Incompatible unblu collaboration server, incompatible API bridge.');
|
|
43
|
+
}
|
|
44
|
+
const version = this.internal.getApiVersion();
|
|
45
|
+
if (+version[0] != SUPPORTED_MAJOR_VERSION) {
|
|
46
|
+
throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, `Incompatible collaboration server version.
|
|
47
|
+
Supported API version: ${SUPPORTED_MAJOR_VERSION}.x.x.
|
|
48
|
+
collaboration server API version: ${version}.`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Calls an API function of the internal unblu collaboration server API.
|
|
53
|
+
* @param moduleName The module to which the function belongs.
|
|
54
|
+
* @param functionName The function to call.
|
|
55
|
+
* @param args The arguments to pass to the function.
|
|
56
|
+
*/
|
|
57
|
+
async callApiFunction(moduleName, functionName, args) {
|
|
58
|
+
try {
|
|
59
|
+
return await this.internal.execute(moduleName, functionName, args);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
switch (e.type) {
|
|
63
|
+
case CATEGORY_INVALID_FUNCTION_CALL:
|
|
64
|
+
throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_CALL, e.message);
|
|
65
|
+
case CATEGORY_INVALID_FUNCTION_ARGUMENTS:
|
|
66
|
+
throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, e.message);
|
|
67
|
+
case CATEGORY_ACTION_NOT_GRANTED:
|
|
68
|
+
throw new UnbluApiError(UnbluErrorType.ACTION_NOT_GRANTED, e.message);
|
|
69
|
+
case CATEGORY_EXECUTION_EXCEPTION:
|
|
70
|
+
throw new UnbluApiError(UnbluErrorType.EXECUTION_EXCEPTION, e.message);
|
|
71
|
+
case CATEGORY_TIMEOUT:
|
|
72
|
+
throw new UnbluApiError(UnbluErrorType.TIMEOUT, e.message);
|
|
73
|
+
default:
|
|
74
|
+
throw new UnbluApiError(UnbluErrorType.EXECUTION_EXCEPTION, '' + e);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Registers a callback for an event emitted by the internal unblu collaboration server API.
|
|
80
|
+
* @param module The module that emits the event.
|
|
81
|
+
* @param event The event name.
|
|
82
|
+
* @param callback The callback which will be called every time the event is emitted.
|
|
83
|
+
*/
|
|
84
|
+
on(module, event, callback) {
|
|
85
|
+
return this.internal.registerEventListener(module, event, callback);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Unregisters a callback for an event emitted by the internal unblu collaboration server API.
|
|
89
|
+
* @param module The module that emits the event.
|
|
90
|
+
* @param event The event name.
|
|
91
|
+
* @param callback Optionally callback which will be removed, if none is provided all listeners of the event will be removed.
|
|
92
|
+
*/
|
|
93
|
+
off(module, event, callback) {
|
|
94
|
+
return this.internal.removeEventListener(module, event, callback);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=api-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-bridge.js","sourceRoot":"","sources":["../../../../src/shared/internal/api-bridge.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAA;AAChE,OAAO,EACH,2BAA2B,EAC3B,4BAA4B,EAC5B,mCAAmC,EACnC,8BAA8B,EAC9B,gBAAgB,EACnB,MAAM,o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,OAAO,CAAC,CAAA;gBAC9D;oBACI,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,mBAAmB,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;aAC1E;SACJ;IACL,CAAC;IAED;;;;;OAKG;IACI,EAAE,CAAC,MAAc,EAAE,KAAa,EAAE,QAAuB;QAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACvE,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,MAAc,EAAE,KAAa,EAAE,QAAwB;QAC9D,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACrE,CAAC;CAEJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../src/shared/internal/event.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialized-unblu-api.js","sourceRoot":"","sources":["../../../../src/shared/internal/initialized-unblu-api.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialized-unblu-element.js","sourceRoot":"","sources":["../../../../src/shared/internal/initialized-unblu-element.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CATEGORY_INVALID_FUNCTION_CALL = 1;
|
|
2
|
+
export declare const CATEGORY_INVALID_FUNCTION_ARGUMENTS = 2;
|
|
3
|
+
export declare const CATEGORY_EXECUTION_EXCEPTION = 3;
|
|
4
|
+
export declare const CATEGORY_ACTION_NOT_GRANTED = 4;
|
|
5
|
+
export declare const CATEGORY_TIMEOUT = 5;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const CATEGORY_INVALID_FUNCTION_CALL = 1;
|
|
2
|
+
export const CATEGORY_INVALID_FUNCTION_ARGUMENTS = 2;
|
|
3
|
+
export const CATEGORY_EXECUTION_EXCEPTION = 3;
|
|
4
|
+
export const CATEGORY_ACTION_NOT_GRANTED = 4;
|
|
5
|
+
export const CATEGORY_TIMEOUT = 5;
|
|
6
|
+
//# sourceMappingURL=java-error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-error-codes.js","sourceRoot":"","sources":["../../../../src/shared/internal/java-error-codes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAA;AAC/C,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAA;AACpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAA;AAC7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InternalModule } from './module';
|
|
2
|
+
import { ApiBridge } from '../api-bridge';
|
|
3
|
+
import { AgentAvailabilityState } from '../../model/agent-availability-state';
|
|
4
|
+
export type AgentAvailabilityEventType = 'availableChange' | 'availabilityChange';
|
|
5
|
+
declare const enum AgentAvailabilityFunction {
|
|
6
|
+
isAgentAvailable = "isAgentAvailable",
|
|
7
|
+
getAgentAvailabilityState = "getAgentAvailabilityState"
|
|
8
|
+
}
|
|
9
|
+
export declare class AgentAvailabilityModule extends InternalModule<AgentAvailabilityFunction, AgentAvailabilityEventType> {
|
|
10
|
+
constructor(bridge: ApiBridge);
|
|
11
|
+
isAgentAvailable(): Promise<boolean>;
|
|
12
|
+
getAgentAvailabilityState(): Promise<AgentAvailabilityState>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InternalModule } from './module';
|
|
2
|
+
export class AgentAvailabilityModule extends InternalModule {
|
|
3
|
+
constructor(bridge) {
|
|
4
|
+
super(bridge, 'agentavailability');
|
|
5
|
+
}
|
|
6
|
+
isAgentAvailable() {
|
|
7
|
+
return this.callApiFunction("isAgentAvailable" /* AgentAvailabilityFunction.isAgentAvailable */, []);
|
|
8
|
+
}
|
|
9
|
+
getAgentAvailabilityState() {
|
|
10
|
+
return this.callApiFunction("getAgentAvailabilityState" /* AgentAvailabilityFunction.getAgentAvailabilityState */, []);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=agent-availability-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-availability-module.js","sourceRoot":"","sources":["../../../../../src/shared/internal/module/agent-availability-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAA;AAcvC,MAAM,OAAO,uBAAwB,SAAQ,cAAqE;IAC9G,YAAY,MAAiB;QACzB,KAAK,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;IACtC,CAAC;IAEM,gBAAgB;QACnB,OAAO,IAAI,CAAC,eAAe,sEAA6C,EAAE,CAAC,CAAA;IAC/E,CAAC;IAEM,yBAAyB;QAC5B,OAAO,IAAI,CAAC,eAAe,wFAAsD,EAAE,CAAC,CAAA;IACxF,CAAC;CACJ"}
|