Skip to content

Commit

Permalink
added the participant level recording support
Browse files Browse the repository at this point in the history
  • Loading branch information
PuneetAgrawal-plivo committed May 21, 2024
1 parent 6522df0 commit 2296584
Show file tree
Hide file tree
Showing 7 changed files with 3,630 additions and 2,135 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [v4.67.0](https://github.com/plivo/plivo-node/tree/v4.67.0) (2024-05-22)
**Feature - Adding support for participant level recording**
- Added new param `recordParticipantTrack` to [add participant API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) to support `participant` level recording
- Added new param `recordTrackType` in start/stop/pause/resume to support participant level recording

## [v4.66.0](https://github.com/plivo/plivo-node/tree/v4.66.0) (2024-05-17)
**Feature - Adding support for location whatsapp messages**
- Added new param `location` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) to support location `whatsapp` messages
Expand Down
58 changes: 49 additions & 9 deletions lib/resources/multiPartyCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,14 @@ export class MultiPartyCall extends PlivoResource{
if(params.to && (String(params.delayDial).split('<').length > params.to.split('<').length)){
throw new MPCError("DelayDial:number of delay_dial(s) should be same as number of destination(s)")
}

if(params.recordParticipantTrack){
validParam('recordParticipantTrack', params.recordParticipantTrack, [Boolean, String], false)
}
else {
params.recordParticipantTrack = 'false'
}

params.isVoiceRequest = 'true';
params.callerName = params.callerName || params.from;
return super.executeAction(this.id + '/Participant/', 'POST', params)
Expand Down Expand Up @@ -462,20 +470,52 @@ export class MultiPartyCallParticipant extends PlivoSecondaryResource{
else {
params.recordingCallbackMethod = 'POST'
}

if(params.recordTrackType){
validParam('recordTrackType', params.recordTrackType.toUpperCase(), [String], false, ['PARTICIPANT', 'BOTH', 'ALL'])
}
else {
params.recordTrackType = 'all'
}

params.isVoiceRequest = 'true';
return super.executeAction(this.id , this.secondaryId + '/Record', 'POST', params)
}

stopParticipantRecording(){
return super.executeAction(this.id , this.secondaryId +'/Record', 'DELETE',{'isVoiceRequest' : 'true'})
stopParticipantRecording(params = {}){
if(params.recordTrackType){
validParam('recordTrackType', params.recordTrackType.toUpperCase(), [String], false, ['PARTICIPANT', 'BOTH', 'ALL'])
}
else {
params.recordTrackType = 'all'
}

params.isVoiceRequest = 'true';
return super.executeAction(this.id , this.secondaryId +'/Record', 'DELETE', params)
}

pauseParticipantRecording(){
return super.executeAction(this.id , this.secondaryId + '/Record/Pause', 'POST',{'isVoiceRequest' : 'true'})
pauseParticipantRecording(params = {}){
if(params.recordTrackType){
validParam('recordTrackType', params.recordTrackType.toUpperCase(), [String], false, ['PARTICIPANT', 'BOTH', 'ALL'])
}
else {
params.recordTrackType = 'all'
}

params.isVoiceRequest = 'true';
return super.executeAction(this.id , this.secondaryId + '/Record/Pause', 'POST', params)
}

resumeParticipantRecording(){
return super.executeAction(this.id , this.secondaryId + '/Record/Resume', 'POST',{'isVoiceRequest' : 'true'})
resumeParticipantRecording(params = {}){
if(params.recordTrackType){
validParam('recordTrackType', params.recordTrackType.toUpperCase(), [String], false, ['PARTICIPANT', 'BOTH', 'ALL'])
}
else {
params.recordTrackType = 'all'
}

params.isVoiceRequest = 'true';
return super.executeAction(this.id , this.secondaryId + '/Record/Resume', 'POST', params)
}

}
Expand Down Expand Up @@ -708,7 +748,7 @@ export class MultiPartyCallInterface extends PlivoResourceInterface{
let mpcId = this.makeMpcId(params.uuid, params.friendlyName)
delete params.uuid
delete params.friendlyName
return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).stopParticipantRecording()
return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).stopParticipantRecording(params)
}

pauseParticipantRecording(participantId, params={}){
Expand All @@ -722,7 +762,7 @@ export class MultiPartyCallInterface extends PlivoResourceInterface{
let mpcId = this.makeMpcId(params.uuid, params.friendlyName)
delete params.uuid
delete params.friendlyName
return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).pauseParticipantRecording()
return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).pauseParticipantRecording(params)
}

resumeParticipantRecording(participantId, params={}){
Expand All @@ -736,7 +776,7 @@ export class MultiPartyCallInterface extends PlivoResourceInterface{
let mpcId = this.makeMpcId(params.uuid, params.friendlyName)
delete params.uuid
delete params.friendlyName
return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).resumeParticipantRecording()
return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).resumeParticipantRecording(params)
}

listParticipants(params={}){
Expand Down
12 changes: 12 additions & 0 deletions lib/rest/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ export function Axios(config) {
405: Exceptions.InvalidRequestError,
406: Exceptions.NotAcceptableError,
500: Exceptions.ServerError,
409: Exceptions.InvalidRequestError,
422: Exceptions.InvalidRequestError,
207: Exceptions.InvalidRequestError,
} [response.status] || Error;

if (!_.inRange(response.status, 200, 300)) {
Expand Down Expand Up @@ -226,6 +229,9 @@ export function Axios(config) {
405: Exceptions.InvalidRequestError,
406: Exceptions.NotAcceptableError,
500: Exceptions.ServerError,
409: Exceptions.InvalidRequestError,
422: Exceptions.InvalidRequestError,
207: Exceptions.InvalidRequestError,
} [error.response.status] || Error;
if (!_.inRange(error.response.status, 200, 300)) {
let body = error.response.data;
Expand All @@ -250,6 +256,9 @@ export function Axios(config) {
405: Exceptions.InvalidRequestError,
406: Exceptions.NotAcceptableError,
500: Exceptions.ServerError,
409: Exceptions.InvalidRequestError,
422: Exceptions.InvalidRequestError,
207: Exceptions.InvalidRequestError,
} [response.status] || Error;

if (!_.inRange(response.status, 200, 300)) {
Expand Down Expand Up @@ -284,6 +293,9 @@ export function Axios(config) {
405: Exceptions.InvalidRequestError,
406: Exceptions.NotAcceptableError,
500: Exceptions.ServerError,
409: Exceptions.InvalidRequestError,
422: Exceptions.InvalidRequestError,
207: Exceptions.InvalidRequestError,
} [error.response.status] || Error;
if (!_.inRange(error.response.status, 200, 300)) {
let body = error.response.data;
Expand Down
19 changes: 18 additions & 1 deletion lib/utils/plivoxml.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ Response.prototype = {
* @param {string} [attributes.stopRecordingAudio]
* @param {string} [attributes.startRecordingAudioMethod]
* @param {string} [attributes.stopRecordingAudioMethod]
* @param {boolean} [attributes.recordParticipantTrack]
* @param {string} [attributes.recordTrackType]
*/
addMultiPartyCall: function (body, attributes){
const VALID_ROLE_VALUES = ['agent', 'supervisor', 'customer']
Expand Down Expand Up @@ -712,6 +714,21 @@ Response.prototype = {
else if (!attributes.stopRecordingAudioMethod){
attributes.stopRecordingAudioMethod = 'GET'
}

if(attributes.recordParticipantTrack && VALID_BOOL_VALUES.indexOf(attributes.recordParticipantTrack)===-1){
throw new PlivoXMLError('Invalid attribute value ' + attributes.recordParticipantTrack + ' for record participant track')
}
else if (!attributes.recordParticipantTrack){
attributes.recordParticipantTrack = false
}

if(attributes.recordTrackType && !plivoUtils.isOneAmongStringUrl('recordTrackType', attributes.recordTrackType, false, ['all', 'both', 'participant'])){
throw new PlivoXMLError('Invalid attribute value ' + attributes.recordTrackType + ' for recordTrackType')
}
else if(!attributes.recordTrackType){
attributes.recordTrackType = 'all'
}

return this.add(new MultiPartyCall(Response), body, attributes);
},

Expand Down Expand Up @@ -1033,7 +1050,7 @@ function MultiPartyCall(Response){
'stayAlone', 'coachMode', 'mute', 'hold', 'startMpcOnEnter', 'endMpcOnExit',
'enterSound', 'enterSoundMethod', 'exitSound', 'exitSoundMethod',
'onExitActionUrl', 'onExitActionMethod', 'relayDTMFInputs',
'startRecordingAudio', 'startRecordingAudioMethod', 'stopRecordingAudio', 'stopRecordingAudioMethod'];
'startRecordingAudio', 'startRecordingAudioMethod', 'stopRecordingAudio', 'stopRecordingAudioMethod', 'recordTrackType', 'recordParticipantTrack'];
}
util.inherits(MultiPartyCall, Response);

Expand Down
Loading

0 comments on commit 2296584

Please sign in to comment.