Required by the stricter server-side call_sid requirements from the previous commit. Without this, agents would fail to join or leave calls because the client side still sent only conversation_id. - TwilioVoiceClient.joinClientCall now forwards callSid as a Device.connect param, which becomes params[:call_sid] on the TwiML webhook. - VoiceAPI.leaveConference takes callSid and passes it as a query param so the DELETE /conference endpoint can resolve the exact call. - useCallSession and FloatingCallWidget pass callSid through.
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
/* global axios */
|
|
import ApiClient from '../../ApiClient';
|
|
import ContactsAPI from '../../contacts';
|
|
|
|
class VoiceAPI extends ApiClient {
|
|
constructor() {
|
|
super('voice', { accountScoped: true });
|
|
}
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
initiateCall(contactId, inboxId) {
|
|
return ContactsAPI.initiateCall(contactId, inboxId).then(r => r.data);
|
|
}
|
|
|
|
leaveConference({ inboxId, conversationId, callSid }) {
|
|
return axios
|
|
.delete(`${this.baseUrl()}/inboxes/${inboxId}/conference`, {
|
|
params: { conversation_id: conversationId, call_sid: callSid },
|
|
})
|
|
.then(r => r.data);
|
|
}
|
|
|
|
joinConference({ conversationId, inboxId, callSid }) {
|
|
return axios
|
|
.post(`${this.baseUrl()}/inboxes/${inboxId}/conference`, {
|
|
conversation_id: conversationId,
|
|
call_sid: callSid,
|
|
})
|
|
.then(r => r.data);
|
|
}
|
|
|
|
getToken(inboxId) {
|
|
if (!inboxId) return Promise.reject(new Error('Inbox ID is required'));
|
|
return axios
|
|
.get(`${this.baseUrl()}/inboxes/${inboxId}/conference/token`)
|
|
.then(r => r.data);
|
|
}
|
|
}
|
|
|
|
export default new VoiceAPI();
|