From 6828527eca70709f93cdf4d80020154f177bc106 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Thu, 13 Jul 2023 19:52:54 +0530 Subject: [PATCH 01/12] create and get session --- lib/resources/call.js | 92 +++++++++++++++++++++++++++++++++++++++ types/resources/call.d.ts | 45 +++++++++++++++++++ 2 files changed, 137 insertions(+) diff --git a/lib/resources/call.js b/lib/resources/call.js index b9166db6..df80d7c0 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -46,6 +46,25 @@ export class CreateCallResponse { } } +export class CreateMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.sessionUuid = params.sessionUuid; + this.virtualNumber = params.virtualNumber; + this.message = params.message; + this.session = params.session; + + + } +} +export class GetMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.response = params.response; + } +} export class GetQueuedCallResponse { constructor(params) { @@ -504,6 +523,10 @@ export class Call extends PlivoResource { params.isVoiceRequest = 'true'; return super.executeAction('Request/' + this.id + '/', 'DELETE', params, ''); } + getMaskingSession(params={}) { + params.isVoiceRequest = 'true'; + return super.executeAction('Masking/Session/' + this.id, 'GET', params); + } } const liveCallInterfaceKey = Symbol('liveCallInterface'); @@ -658,6 +681,75 @@ export class CallInterface extends PlivoResourceInterface { }); } + /** + * Create a masking session + * @method + * @param {string} firstParty - The phone number or SIP endpoint of the first party. + * @param {string} secondParty - The phone number or SIP endpoint of the second party. + * @param {object} params - optional params to make a call + * @param {number} [params.sessionExpiry]- The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {boolean} [params.initiateCallToFirstParty] - Indicates whether the call to the first party should be initiated automatically. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + createMaskingSession(firstParty, secondParty, params = {}) { + let errors = validate([{ + field: 'first_party', + value: firstParty, + validators: ['isRequired'] + }, + { + field: 'second_party', + value: secondParty, + validators: ['isRequired'] + } + ]); + params.firstParty = firstParty; + params.secondParty = secondParty + params.isVoiceRequest = 'true'; + + let client = this[clientKey]; + return new Promise((resolve, reject) => { + client('POST', 'Masking/Session/', params) + .then(response => { + resolve(new CreateMaskingSessionResponse(response.body, idField)); + }) + .catch(error => { + reject(error); + }); + }); + } + /** + * Get a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + getMaskingSession(sessionUuid){ + let errors = validate([{ + field: 'sessionUuid', + value: sessionUuid, + validators: ['isRequired'] + } + ]); + if (errors) { + return errors; + } + return new Call(this[clientKey], { + id: sessionUuid, + }).getMaskingSession(); + } /** * Hangup A Specific Call * @method diff --git a/types/resources/call.d.ts b/types/resources/call.d.ts index 0e2dc0ff..a491dd39 100644 --- a/types/resources/call.d.ts +++ b/types/resources/call.d.ts @@ -20,6 +20,19 @@ export class CreateCallResponse { message: string; requestUuid: Array | string; } +export class CreateMaskingSessionResponse { + constructor(params: object); + apiId: string; + sessionUuid:string; + virtualNumber:string; + message: string; + session: object; +} +export class GetMaskingSessionResponse { + constructor(params: object); + apiId: string; + response: object; +} export class GetQueuedCallResponse { constructor(params: object); apiId: string; @@ -318,6 +331,38 @@ export class CallInterface extends PlivoResourceInterface { */ create(from: string, to: string, answerUrl: string, params ? : {}): Promise < CreateCallResponse > ; + /** + * Create a masking session + * @method + * @param {string} firstParty - The phone number or SIP endpoint of the first party. + * @param {string} secondParty - The phone number or SIP endpoint of the second party. + * @param {object} params - optional params to make a call + * @param {number} [params.sessionExpiry]- The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {boolean} [params.initiateCallToFirstParty] - Indicates whether the call to the first party should be initiated automatically. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + createMaskingSession(firstParty: string, secondParty: string, params ? : {}): Promise < CreateMaskingSessionResponse > ; + + /** + * Get a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + getMaskingSession(sessionUuid: string): Promise < GetMaskingSessionResponse > ; + /** * Hangup A Specific Call * @method From 07bd2a573f646733628502f96be692984e675964 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Fri, 14 Jul 2023 18:04:57 +0530 Subject: [PATCH 02/12] update,delete and list session --- lib/resources/call.js | 162 +++++++++++++++++++++++++++++++++++++- types/resources/call.d.ts | 100 +++++++++++++++++++++++ 2 files changed, 261 insertions(+), 1 deletion(-) diff --git a/lib/resources/call.js b/lib/resources/call.js index df80d7c0..e4e1f3ff 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -65,7 +65,55 @@ export class GetMaskingSessionResponse { this.response = params.response; } } - +export class DeleteMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.message = params.message; + } +} +export class UpdateMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.message = params.message; + this.session = params.session; + } +} +export class ListMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.response = params.response; + this.firstParty= params.firstParty; + this.secondParty= params.secondParty; + this.virtualNumber= params.virtualNumber; + this.status= params.status; + this.initiateCallToFirstParty= params.initiateCallToFirstParty; + this.sessionUuid= params.sessionUuid; + this.callbackUrl= params.callbackUrl; + this.callbackMethod= params.callbackMethod; + this.createdAt= params.createdTime; + this.updatedAt= params.modifiedTime; + this.expiryAt= params.expiryTime; + this.duration= params.duration; + this.sessionCreationAmount= params.amount; + this.callTimeLimit= params.callTimeLimit; + this.ringTimeout= params.ringTimeout; + this.firstPartyPlayUrl= params.firstPartyPlayUrl; + this.secondPartyPlayUrl= params.secondPartyPlayUrl; + this.record= params.record; + this.recordFileFormat= params.recordFileFormat; + this.recordingCallbackUrl= params.recordingCallbackUrl; + this.recordingCallbackMethod= params.recordingCallbackMethod; + this.interaction= params.interaction; + this.totalCallAmount= params.totalCallAmount; + this.totalCallCount= params.totalCallCount; + this.totalCallBilledDuration= params.totalCallBilledDuration; + this.totalSessionAmount= params.totalSessionAmount; + this.lastInteractionTime= params.lastInteractionTime; + } +} export class GetQueuedCallResponse { constructor(params) { params = params || {}; @@ -527,6 +575,10 @@ export class Call extends PlivoResource { params.isVoiceRequest = 'true'; return super.executeAction('Masking/Session/' + this.id, 'GET', params); } + deleteMaskingSession(params={}) { + params.isVoiceRequest = 'true'; + return super.executeAction('Masking/Session/' + this.id, 'DELETE', params); + } } const liveCallInterfaceKey = Symbol('liveCallInterface'); @@ -729,6 +781,93 @@ export class CallInterface extends PlivoResourceInterface { }); }); } + + /** + * Update a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @param {object} params - optional params to update a session + * @param {number} [params.sessionExpiry] - The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the update masking session request fails + */ + updateMaskingSession(sessionUuid, params = {}) { + let errors = validate([{ + field: 'session_uuid', + value: sessionUuid, + validators: ['isRequired'] + } + ]); + params.sessionUuid = sessionUuid; + params.isVoiceRequest = 'true'; + + if (errors) { + return errors; + } + return new Call(this[clientKey], { + id: sessionUuid, + }).updateMaskingSession(params); + } + /** + * List masking sessions with optional filters + * @method + * @param {object} filterParams - Optional filter parameters to list masking sessions + * @param {string} [filterParams.firstParty] - The phone number or SIP endpoint of the first party. + * @param {string} [filterParams.secondParty] - The phone number or SIP endpoint of the second party. + * @param {string} [filterParams.virtualNumber] - The virtual number associated with the masking session. + * @param {string} [filterParams.status] - The status of the masking session. + * @param {string} [filterParams.createdTimeEquals] - The specific created time to filter sessions. + * @param {string} [filterParams.createdTimeLessThan] - Filter sessions created before this time. + * @param {string} [filterParams.createdTimeGreaterThan] - Filter sessions created after this time. + * @param {string} [filterParams.createdTimeLessOrEqual] - Filter sessions created before or at this time. + * @param {string} [filterParams.createdTimeGreaterOrEqual] - Filter sessions created after or at this time. + * @param {string} [filterParams.expiryTimeEquals] - The specific expiry time to filter sessions. + * @param {string} [filterParams.expiryTimeLessThan] - Filter sessions expiring before this time. + * @param {string} [filterParams.expiryTimeGreaterThan] - Filter sessions expiring after this time. + * @param {string} [filterParams.expiryTimeLessOrEqual] - Filter sessions expiring before or at this time. + * @param {string} [filterParams.expiryTimeGreaterOrEqual] - Filter sessions expiring after or at this time. + * @param {number} [filterParams.durationEquals] - The duration in seconds to filter sessions. + * @param {number} [filterParams.durationLessThan] - Filter sessions with duration less than this value. + * @param {number} [filterParams.durationGreaterThan] - Filter sessions with duration greater than this value. + * @param {number} [filterParams.durationLessOrEqual] - Filter sessions with duration less than or equal to this value. + * @param {number} [filterParams.durationGreaterOrEqual] - Filter sessions with duration greater than or equal to this value. + * @param {number} [filterParams.limit] - The maximum number of sessions to retrieve. + * @param {number} [filterParams.offset] - The offset for paginated results. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the list masking sessions request fails + */ + listMaskingSession(params) { + let client = this[clientKey]; + if (params === undefined) { + params = {} + } + params.isVoiceRequest = 'true'; + return new Promise(function (resolve, reject) { + client('GET', 'Masking/Session/', params).then(function (response) { + var objects = []; + Object.defineProperty(objects, 'meta', { + value: response.body.response.meta, + enumerable: true + }); + response.body.response.objects.forEach(function (item) { + objects.push(new ListMaskingSessionResponse(item, client)); + }); + resolve(objects); + }).catch(function (error) { + reject(error); + }); + }); + } /** * Get a masking session * @method @@ -750,6 +889,27 @@ export class CallInterface extends PlivoResourceInterface { id: sessionUuid, }).getMaskingSession(); } + /** + * Delete a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + deleteMaskingSession(sessionUuid){ + let errors = validate([{ + field: 'sessionUuid', + value: sessionUuid, + validators: ['isRequired'] + } + ]); + if (errors) { + return errors; + } + return new Call(this[clientKey], { + id: sessionUuid, + }).deleteMaskingSession(); + } /** * Hangup A Specific Call * @method diff --git a/types/resources/call.d.ts b/types/resources/call.d.ts index a491dd39..b77c5245 100644 --- a/types/resources/call.d.ts +++ b/types/resources/call.d.ts @@ -33,6 +33,49 @@ export class GetMaskingSessionResponse { apiId: string; response: object; } +export class DeleteMaskingSessionResponse { + constructor(params: object); + apiId: string; + message: string; +} +export class UpdateMaskingSessionResponse { + constructor(params: object); + apiId: string; + message: string; + session: object; +} +export class ListMaskingSessionResponse { + constructor(params: object); + apiId: string; + response: object; + firstParty: string; + secondParty: string; + virtualNumber: string; + status: string; + initiateCallToFirstParty: string; + sessionUuid: string; + callbackUrl: string; + callbackMethod: string; + createdAt: string; + updatedAt: string; + expiryAt: string; + duration: string; + sessionCreationAmount: string; + callTimeLimit: string + ringTimeout: string; + firstPartyPlayUrl: string; + secondPartyPlayUrl: string; + record: string; + recordFileFormat: string; + recordingCallbackUrl: string; + recordingCallbackMethod: string; + interaction: object; + totalCallAmount: string; + totalCallCount: string; + totalCallBilledDuration: string; + totalSessionAmount: string; + lastInteractionTime: string; +} export class GetQueuedCallResponse { constructor(params: object); apiId: string; @@ -353,6 +396,55 @@ export class CallInterface extends PlivoResourceInterface { * @fail {Error} returns Error */ createMaskingSession(firstParty: string, secondParty: string, params ? : {}): Promise < CreateMaskingSessionResponse > ; + /** + * Update a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @param {object} params - optional params to update a session + * @param {number} [params.sessionExpiry] - The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the update masking session request fails + */ + updateMaskingSession(sessionUuid: string, params ? : {}): Promise < UpdateMaskingSessionResponse > ; + /** + * List masking sessions with optional filters + * @method + * @param {object} filterParams - Optional filter parameters to list masking sessions + * @param {string} [filterParams.firstParty] - The phone number or SIP endpoint of the first party. + * @param {string} [filterParams.secondParty] - The phone number or SIP endpoint of the second party. + * @param {string} [filterParams.virtualNumber] - The virtual number associated with the masking session. + * @param {string} [filterParams.status] - The status of the masking session. + * @param {string} [filterParams.createdTimeEquals] - The specific created time to filter sessions. + * @param {string} [filterParams.createdTimeLessThan] - Filter sessions created before this time. + * @param {string} [filterParams.createdTimeGreaterThan] - Filter sessions created after this time. + * @param {string} [filterParams.createdTimeLessOrEqual] - Filter sessions created before or at this time. + * @param {string} [filterParams.createdTimeGreaterOrEqual] - Filter sessions created after or at this time. + * @param {string} [filterParams.expiryTimeEquals] - The specific expiry time to filter sessions. + * @param {string} [filterParams.expiryTimeLessThan] - Filter sessions expiring before this time. + * @param {string} [filterParams.expiryTimeGreaterThan] - Filter sessions expiring after this time. + * @param {string} [filterParams.expiryTimeLessOrEqual] - Filter sessions expiring before or at this time. + * @param {string} [filterParams.expiryTimeGreaterOrEqual] - Filter sessions expiring after or at this time. + * @param {number} [filterParams.durationEquals] - The duration in seconds to filter sessions. + * @param {number} [filterParams.durationLessThan] - Filter sessions with duration less than this value. + * @param {number} [filterParams.durationGreaterThan] - Filter sessions with duration greater than this value. + * @param {number} [filterParams.durationLessOrEqual] - Filter sessions with duration less than or equal to this value. + * @param {number} [filterParams.durationGreaterOrEqual] - Filter sessions with duration greater than or equal to this value. + * @param {number} [filterParams.limit] - The maximum number of sessions to retrieve. + * @param {number} [filterParams.offset] - The offset for paginated results. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the list masking sessions request fails + */ + listMaskingSession(params ? : {}): Promise < ListMaskingSessionResponse > ; /** * Get a masking session @@ -362,6 +454,14 @@ export class CallInterface extends PlivoResourceInterface { * @fail {Error} returns Error */ getMaskingSession(sessionUuid: string): Promise < GetMaskingSessionResponse > ; + /** + * Delete a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + deleteMaskingSession(sessionUuid: string): Promise < DeleteMaskingSessionResponse > ; /** * Hangup A Specific Call From 2c5147b06080b2528442ddf473a9b2ef282f8b90 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Tue, 18 Jul 2023 12:51:20 +0530 Subject: [PATCH 03/12] UTs --- lib/resources/call.js | 39 +------ lib/rest/request-test.js | 213 +++++++++++++++++++++++++++++++++++++- test/calls.js | 35 +++++++ types/resources/call.d.ts | 27 ----- 4 files changed, 249 insertions(+), 65 deletions(-) diff --git a/lib/resources/call.js b/lib/resources/call.js index e4e1f3ff..41c873de 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -84,34 +84,7 @@ export class ListMaskingSessionResponse { constructor(params) { params = params || {}; this.apiId = params.apiId; - this.response = params.response; - this.firstParty= params.firstParty; - this.secondParty= params.secondParty; - this.virtualNumber= params.virtualNumber; - this.status= params.status; - this.initiateCallToFirstParty= params.initiateCallToFirstParty; - this.sessionUuid= params.sessionUuid; - this.callbackUrl= params.callbackUrl; - this.callbackMethod= params.callbackMethod; - this.createdAt= params.createdTime; - this.updatedAt= params.modifiedTime; - this.expiryAt= params.expiryTime; - this.duration= params.duration; - this.sessionCreationAmount= params.amount; - this.callTimeLimit= params.callTimeLimit; - this.ringTimeout= params.ringTimeout; - this.firstPartyPlayUrl= params.firstPartyPlayUrl; - this.secondPartyPlayUrl= params.secondPartyPlayUrl; - this.record= params.record; - this.recordFileFormat= params.recordFileFormat; - this.recordingCallbackUrl= params.recordingCallbackUrl; - this.recordingCallbackMethod= params.recordingCallbackMethod; - this.interaction= params.interaction; - this.totalCallAmount= params.totalCallAmount; - this.totalCallCount= params.totalCallCount; - this.totalCallBilledDuration= params.totalCallBilledDuration; - this.totalSessionAmount= params.totalSessionAmount; - this.lastInteractionTime= params.lastInteractionTime; + this.response = params.response; } } export class GetQueuedCallResponse { @@ -854,15 +827,7 @@ export class CallInterface extends PlivoResourceInterface { params.isVoiceRequest = 'true'; return new Promise(function (resolve, reject) { client('GET', 'Masking/Session/', params).then(function (response) { - var objects = []; - Object.defineProperty(objects, 'meta', { - value: response.body.response.meta, - enumerable: true - }); - response.body.response.objects.forEach(function (item) { - objects.push(new ListMaskingSessionResponse(item, client)); - }); - resolve(objects); + resolve(new ListMaskingSessionResponse(response.body, idField)); }).catch(function (error) { reject(error); }); diff --git a/lib/rest/request-test.js b/lib/rest/request-test.js index eec1f959..a3d1fcc1 100644 --- a/lib/rest/request-test.js +++ b/lib/rest/request-test.js @@ -210,13 +210,224 @@ export function Request(config) { } }); } - else if (action == 'Call/aaa-deeiei3-dfddd/Record/' && method == 'DELETE') { + else if (method === 'POST' && action === 'Masking/Session/') { + resolve({ + response: {}, + body: { + "api_id": "b70bb955-0c85-4b12-9ec4-9640b46c4f61", + "session_uuid": "197aa6e0-1abe-4d1c-b887-2b2406764360", + "virtual_number": "+916361728680", + "message": "Session created", + "session": { + "first_party": "917708772011", + "second_party": "918220568648", + "virtual_number": "916361728680", + "status": "active", + "initiate_call_to_first_party": true, + "session_uuid": "197aa6e0-1abe-4d1c-b887-2b2406764360", + "callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1", + "callback_method": "GET", + "created_time": "2023-07-17 14:26:02.806041 +0000 UTC", + "modified_time": "2023-07-17 14:26:02.806041 +0000 UTC", + "expiry_time": "2023-07-17 16:06:02.806041 +0000 UTC", + "duration": 6000, + "amount": 0, + "call_time_limit": 14400, + "ring_timeout": 120, + "first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "record": false, + "record_file_format": "mp3", + "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_method": "GET", + "interaction": null, + "total_call_amount": 0, + "total_call_count": 0, + "total_call_billed_duration": 0, + "total_session_amount": 0, + "last_interaction_time": "" + } + } + }); + } + else if (method === 'GET' && action === 'Masking/Session/197aa6e0-1abe-4d1c-b887-2b2406764360') { + resolve({ + response: {}, + body: { + "api_id": "2d0c2ca6-01d5-43c0-bb72-038e7d84e3b4", + "response": { + "first_party": "917708772011", + "second_party": "918220568648", + "virtual_number": "916361728680", + "status": "active", + "initiate_call_to_first_party": true, + "session_uuid": "197aa6e0-1abe-4d1c-b887-2b2406764360", + "callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1", + "callback_method": "GET", + "created_time": "2023-07-17 14:26:02.806041 +0000 UTC", + "modified_time": "2023-07-17 14:26:02.806041 +0000 UTC", + "expiry_time": "2023-07-17 16:06:02.806041 +0000 UTC", + "duration": 6000, + "amount": 0, + "call_time_limit": 14400, + "ring_timeout": 120, + "first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "record": false, + "record_file_format": "mp3", + "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_method": "GET", + "interaction": [ + { + "start_time": "2023-07-17 14:26:03 +0000 UTC", + "end_time": "2023-07-17 14:26:03 +0000 UTC", + "first_party_resource_url": "https://api-qa.voice.plivodev.com/v1/Account/MAZTQXZDYWNZBMMJAZZJ/Call/46bca3f0-e9de-4fa9-a0fc-fff28171527c", + "type": "call", + "total_call_count": 1, + "duration": 0 + } + ], + "total_call_amount": 0, + "total_call_count": 1, + "total_call_billed_duration": 0, + "total_session_amount": 0, + "last_interaction_time": "2023-07-17 14:26:03 +0000 UTC" + } + } + }); + } + else if (method === 'DELETE' && action === 'Masking/Session/197aa6e0-1abe-4d1c-b887-2b2406764360') { resolve({ response: {}, body: { + "api_id": "758bf153-a37e-446b-9163-97094bcc0390", + "message": "Session expired" } }); } + else if (method === 'POST' && action === 'Masking/Session/63690013-52bb-43fa-9b0b-bf81c9f4d766') { + resolve({ + response: {}, + body: { + "api_id": "2b95070e-5e67-46d0-ba79-2903d423c5b2", + "message": "Session updated", + "session": { + "first_party": "917708772011", + "second_party": "919976106830", + "virtual_number": "916361728680", + "status": "active", + "initiate_call_to_first_party": false, + "session_uuid": "63690013-52bb-43fa-9b0b-bf81c9f4d766", + "callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1", + "callback_method": "GET", + "created_time": "2023-07-11 04:02:13.820698 +0000 +0000", + "modified_time": "2023-07-11 04:02:32.594296 +0000 UTC", + "expiry_time": "2023-07-11 04:03:32.59429 +0000 UTC", + "duration": 78, + "amount": 0, + "call_time_limit": 14400, + "ring_timeout": 120, + "first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "record": false, + "record_file_format": "mp3", + "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_method": "GET", + "interaction": null, + "total_call_amount": 0, + "total_call_count": 0, + "total_call_billed_duration": 0, + "total_session_amount": 0, + "last_interaction_time": "" + } + } + }); + } + else if (method === 'GET' && action === 'Masking/Session/') { + resolve({ + response: {}, + body: { + "api_id": "e7da96fd-755c-44b7-9557-d267abae5ab0", + "response": { + "meta": { + "limit": 20, + "next": null, + "offset": 0, + "previous": null, + "total_count": 2 + }, + "objects": [ + { + "amount": 0, + "call_time_limit": 14400, + "callback_method": "GET", + "callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1", + "created_time": "2023-07-11 04:02:13.820698 +0000 UTC", + "duration": 78, + "expiry_time": "2023-07-11 04:03:32.59429 +0000 UTC", + "first_party": "917708772011", + "first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", + "initiate_call_to_first_party": false, + "interaction": null, + "last_interaction_time": "", + "modified_time": "2023-07-11 04:02:32.594296 +0000 UTC", + "record": false, + "record_file_format": "mp3", + "recording_callback_method": "GET", + "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "resource_uri": "/v1/Account/MAZTQXZDYWNZBMMJAZZJ/Masking/Session/63690013-52bb-43fa-9b0b-bf81c9f4d766/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "63690013-52bb-43fa-9b0b-bf81c9f4d766", + "status": "expired", + "total_call_amount": 0, + "total_call_billed_duration": 0, + "total_call_count": 0, + "total_session_amount": 0, + "virtual_number": "916361728680" + }, + { + "amount": 0, + "call_time_limit": 14400, + "callback_method": "GET", + "callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1", + "created_time": "2023-07-11 03:38:42.885428 +0000 UTC", + "duration": 109, + "expiry_time": "2023-07-11 03:40:32.408859 +0000 UTC", + "first_party": "917708772011", + "first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", + "initiate_call_to_first_party": false, + "interaction": null, + "last_interaction_time": "", + "modified_time": "2023-07-11 03:39:32.408908 +0000 UTC", + "record": false, + "record_file_format": "mp3", + "recording_callback_method": "GET", + "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "resource_uri": "/v1/Account/MAZTQXZDYWNZBMMJAZZJ/Masking/Session/cc69df7e-eeb0-4fc5-93e9-f01d35ced9e8/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "cc69df7e-eeb0-4fc5-93e9-f01d35ced9e8", + "status": "expired", + "total_call_amount": 0, + "total_call_billed_duration": 0, + "total_call_count": 0, + "total_session_amount": 0, + "virtual_number": "916361728680" + } + ] + } + } + }); + } + else if (action == 'Call/aaa-deeiei3-dfddd/Record/' && method == 'DELETE') { + resolve({ + response: {}, + body: {} + }); + } else if (action == 'Call/aaa-deeiei3-dfddd/Play/' && method == 'POST') { resolve({ response: {}, diff --git a/test/calls.js b/test/calls.js index 5ce80886..d4ec88a9 100644 --- a/test/calls.js +++ b/test/calls.js @@ -293,4 +293,39 @@ describe('calls', function () { }) }); }); + describe('MaskingSession', function () { + it('should create masking session!', function () { + client.calls.createMaskingSession("917708772011", "918220568648", + { + callTimeLimit: 14600, + }, + ).then(function (response) { + assert.equal(response.message, 'session created') + }) + }); + it('should delete a masking session!', function () { + client.calls.deleteMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + .then(function (response) { + assert.equal(response.message, 'session expired') + }) + }); + it('should get masking session by session uuid!', function () { + client.calls.getMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + .then(function (response) { + assert.equal(response.response.sessionUuid, "197aa6e0-1abe-4d1c-b887-2b2406764360") + }) + }); + it('should update masking session using session uuid!', function () { + client.calls.updateMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + .then(function (response) { + assert.equal(response.message, 'session updated') + }) + }); + it('should list masking session!', function () { + client.calls.listMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + .then(function (response) { + assert.equal(response.length, 2) + }) + }); + }); }); diff --git a/types/resources/call.d.ts b/types/resources/call.d.ts index b77c5245..34d802ae 100644 --- a/types/resources/call.d.ts +++ b/types/resources/call.d.ts @@ -48,33 +48,6 @@ export class ListMaskingSessionResponse { constructor(params: object); apiId: string; response: object; - firstParty: string; - secondParty: string; - virtualNumber: string; - status: string; - initiateCallToFirstParty: string; - sessionUuid: string; - callbackUrl: string; - callbackMethod: string; - createdAt: string; - updatedAt: string; - expiryAt: string; - duration: string; - sessionCreationAmount: string; - callTimeLimit: string - ringTimeout: string; - firstPartyPlayUrl: string; - secondPartyPlayUrl: string; - record: string; - recordFileFormat: string; - recordingCallbackUrl: string; - recordingCallbackMethod: string; - interaction: object; - totalCallAmount: string; - totalCallCount: string; - totalCallBilledDuration: string; - totalSessionAmount: string; - lastInteractionTime: string; } export class GetQueuedCallResponse { constructor(params: object); From 73ddd665364b304e20add510146557d6bbf55a0a Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Tue, 18 Jul 2023 12:58:43 +0530 Subject: [PATCH 04/12] UTs --- lib/resources/call.js | 4 ++++ test/calls.js | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/resources/call.js b/lib/resources/call.js index 41c873de..000b4b7b 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -552,6 +552,10 @@ export class Call extends PlivoResource { params.isVoiceRequest = 'true'; return super.executeAction('Masking/Session/' + this.id, 'DELETE', params); } + updateMaskingSession(params) { + params.isVoiceRequest = 'true'; + return super.executeAction('Masking/Session/' + this.id, 'POST', params); + } } const liveCallInterfaceKey = Symbol('liveCallInterface'); diff --git a/test/calls.js b/test/calls.js index d4ec88a9..cbc907dc 100644 --- a/test/calls.js +++ b/test/calls.js @@ -300,13 +300,13 @@ describe('calls', function () { callTimeLimit: 14600, }, ).then(function (response) { - assert.equal(response.message, 'session created') + assert.equal(response.message, 'Session created') }) }); it('should delete a masking session!', function () { client.calls.deleteMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") .then(function (response) { - assert.equal(response.message, 'session expired') + assert.equal(response.message, 'Session expired') }) }); it('should get masking session by session uuid!', function () { @@ -316,9 +316,9 @@ describe('calls', function () { }) }); it('should update masking session using session uuid!', function () { - client.calls.updateMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + client.calls.updateMaskingSession("63690013-52bb-43fa-9b0b-bf81c9f4d766") .then(function (response) { - assert.equal(response.message, 'session updated') + assert.equal(response.message, 'Session updated') }) }); it('should list masking session!', function () { From 06246aacdef662f11886377dea3202fc13a14e9c Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Tue, 18 Jul 2023 13:01:56 +0530 Subject: [PATCH 05/12] UTs fix --- test/calls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/calls.js b/test/calls.js index cbc907dc..c667e194 100644 --- a/test/calls.js +++ b/test/calls.js @@ -322,7 +322,7 @@ describe('calls', function () { }) }); it('should list masking session!', function () { - client.calls.listMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + client.calls.listMaskingSession() .then(function (response) { assert.equal(response.length, 2) }) From cf4b4b1d6fbea384941a19e2ddc93f9014159164 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Fri, 21 Jul 2023 12:11:16 +0530 Subject: [PATCH 06/12] modified node sdk for number masking --- lib/resources/call.js | 210 ---------------------- lib/resources/maskingSession.js | 259 ++++++++++++++++++++++++++++ lib/rest/client-test.js | 2 + lib/rest/client.js | 2 + test/maskingSession.js | 44 +++++ types/resources/call.d.ts | 119 ------------- types/resources/maskingSession.d.ts | 162 +++++++++++++++++ types/rest/client-test.d.ts | 3 + types/rest/client.d.ts | 3 + 9 files changed, 475 insertions(+), 329 deletions(-) create mode 100644 lib/resources/maskingSession.js create mode 100644 test/maskingSession.js create mode 100644 types/resources/maskingSession.d.ts diff --git a/lib/resources/call.js b/lib/resources/call.js index 000b4b7b..ffaea1d0 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -46,47 +46,7 @@ export class CreateCallResponse { } } -export class CreateMaskingSessionResponse { - constructor(params) { - params = params || {}; - this.apiId = params.apiId; - this.sessionUuid = params.sessionUuid; - this.virtualNumber = params.virtualNumber; - this.message = params.message; - this.session = params.session; - - } -} -export class GetMaskingSessionResponse { - constructor(params) { - params = params || {}; - this.apiId = params.apiId; - this.response = params.response; - } -} -export class DeleteMaskingSessionResponse { - constructor(params) { - params = params || {}; - this.apiId = params.apiId; - this.message = params.message; - } -} -export class UpdateMaskingSessionResponse { - constructor(params) { - params = params || {}; - this.apiId = params.apiId; - this.message = params.message; - this.session = params.session; - } -} -export class ListMaskingSessionResponse { - constructor(params) { - params = params || {}; - this.apiId = params.apiId; - this.response = params.response; - } -} export class GetQueuedCallResponse { constructor(params) { params = params || {}; @@ -709,176 +669,6 @@ export class CallInterface extends PlivoResourceInterface { }); }); } - - /** - * Create a masking session - * @method - * @param {string} firstParty - The phone number or SIP endpoint of the first party. - * @param {string} secondParty - The phone number or SIP endpoint of the second party. - * @param {object} params - optional params to make a call - * @param {number} [params.sessionExpiry]- The duration in seconds for which the masking session will be active. - * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. - * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. - * @param {string} [params.recordFileFormat] - The file format for the recorded calls. - * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. - * @param {boolean} [params.initiateCallToFirstParty] - Indicates whether the call to the first party should be initiated automatically. - * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. - * @param {string} [params.callbackMethod] - The HTTP method for the callback request. - * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. - * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. - * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. - * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. - * @promise {object} returns PlivoGenericResponse Object - * @fail {Error} returns Error - */ - createMaskingSession(firstParty, secondParty, params = {}) { - let errors = validate([{ - field: 'first_party', - value: firstParty, - validators: ['isRequired'] - }, - { - field: 'second_party', - value: secondParty, - validators: ['isRequired'] - } - ]); - params.firstParty = firstParty; - params.secondParty = secondParty - params.isVoiceRequest = 'true'; - - let client = this[clientKey]; - return new Promise((resolve, reject) => { - client('POST', 'Masking/Session/', params) - .then(response => { - resolve(new CreateMaskingSessionResponse(response.body, idField)); - }) - .catch(error => { - reject(error); - }); - }); - } - - /** - * Update a masking session - * @method - * @param {string} sessionUuid - unique idenfier of a session - * @param {object} params - optional params to update a session - * @param {number} [params.sessionExpiry] - The duration in seconds for which the masking session will be active. - * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. - * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. - * @param {string} [params.recordFileFormat] - The file format for the recorded calls. - * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. - * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. - * @param {string} [params.callbackMethod] - The HTTP method for the callback request. - * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. - * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. - * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. - * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. - * @returns {Promise} - Resolves to a PlivoGenericResponse object - * @throws {Error} - Throws an error if the update masking session request fails - */ - updateMaskingSession(sessionUuid, params = {}) { - let errors = validate([{ - field: 'session_uuid', - value: sessionUuid, - validators: ['isRequired'] - } - ]); - params.sessionUuid = sessionUuid; - params.isVoiceRequest = 'true'; - - if (errors) { - return errors; - } - return new Call(this[clientKey], { - id: sessionUuid, - }).updateMaskingSession(params); - } - /** - * List masking sessions with optional filters - * @method - * @param {object} filterParams - Optional filter parameters to list masking sessions - * @param {string} [filterParams.firstParty] - The phone number or SIP endpoint of the first party. - * @param {string} [filterParams.secondParty] - The phone number or SIP endpoint of the second party. - * @param {string} [filterParams.virtualNumber] - The virtual number associated with the masking session. - * @param {string} [filterParams.status] - The status of the masking session. - * @param {string} [filterParams.createdTimeEquals] - The specific created time to filter sessions. - * @param {string} [filterParams.createdTimeLessThan] - Filter sessions created before this time. - * @param {string} [filterParams.createdTimeGreaterThan] - Filter sessions created after this time. - * @param {string} [filterParams.createdTimeLessOrEqual] - Filter sessions created before or at this time. - * @param {string} [filterParams.createdTimeGreaterOrEqual] - Filter sessions created after or at this time. - * @param {string} [filterParams.expiryTimeEquals] - The specific expiry time to filter sessions. - * @param {string} [filterParams.expiryTimeLessThan] - Filter sessions expiring before this time. - * @param {string} [filterParams.expiryTimeGreaterThan] - Filter sessions expiring after this time. - * @param {string} [filterParams.expiryTimeLessOrEqual] - Filter sessions expiring before or at this time. - * @param {string} [filterParams.expiryTimeGreaterOrEqual] - Filter sessions expiring after or at this time. - * @param {number} [filterParams.durationEquals] - The duration in seconds to filter sessions. - * @param {number} [filterParams.durationLessThan] - Filter sessions with duration less than this value. - * @param {number} [filterParams.durationGreaterThan] - Filter sessions with duration greater than this value. - * @param {number} [filterParams.durationLessOrEqual] - Filter sessions with duration less than or equal to this value. - * @param {number} [filterParams.durationGreaterOrEqual] - Filter sessions with duration greater than or equal to this value. - * @param {number} [filterParams.limit] - The maximum number of sessions to retrieve. - * @param {number} [filterParams.offset] - The offset for paginated results. - * @returns {Promise} - Resolves to a PlivoGenericResponse object - * @throws {Error} - Throws an error if the list masking sessions request fails - */ - listMaskingSession(params) { - let client = this[clientKey]; - if (params === undefined) { - params = {} - } - params.isVoiceRequest = 'true'; - return new Promise(function (resolve, reject) { - client('GET', 'Masking/Session/', params).then(function (response) { - resolve(new ListMaskingSessionResponse(response.body, idField)); - }).catch(function (error) { - reject(error); - }); - }); - } - /** - * Get a masking session - * @method - * @param {string} sessionUuid - unique idenfier of a session - * @promise {object} returns PlivoGenericResponse Object - * @fail {Error} returns Error - */ - getMaskingSession(sessionUuid){ - let errors = validate([{ - field: 'sessionUuid', - value: sessionUuid, - validators: ['isRequired'] - } - ]); - if (errors) { - return errors; - } - return new Call(this[clientKey], { - id: sessionUuid, - }).getMaskingSession(); - } - /** - * Delete a masking session - * @method - * @param {string} sessionUuid - unique idenfier of a session - * @promise {object} returns PlivoGenericResponse Object - * @fail {Error} returns Error - */ - deleteMaskingSession(sessionUuid){ - let errors = validate([{ - field: 'sessionUuid', - value: sessionUuid, - validators: ['isRequired'] - } - ]); - if (errors) { - return errors; - } - return new Call(this[clientKey], { - id: sessionUuid, - }).deleteMaskingSession(); - } /** * Hangup A Specific Call * @method diff --git a/lib/resources/maskingSession.js b/lib/resources/maskingSession.js new file mode 100644 index 00000000..a471a557 --- /dev/null +++ b/lib/resources/maskingSession.js @@ -0,0 +1,259 @@ +import * as _ from "lodash"; + +import { + PlivoResource, + PlivoResourceInterface +} from '../base'; +import { + extend, + validate +} from '../utils/common.js'; + +const clientKey = Symbol(); +const action = 'Masking/Session/'; +const idField = 'sessionUuid'; + +export class CreateMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.sessionUuid = params.sessionUuid; + this.virtualNumber = params.virtualNumber; + this.message = params.message; + this.session = params.session; + + + } +} +export class GetMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.response = params.response; + } +} +export class DeleteMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.message = params.message; + } +} +export class UpdateMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.message = params.message; + this.session = params.session; + } +} +export class ListMaskingSessionResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + this.response = params.response; + } +} + +export class MaskingSession extends PlivoResource { + constructor(client, data = {}) { + super(action, MaskingSession, idField, client); + + if (idField in data) { + this.id = data[idField]; + } + + extend(this, data); + this[clientKey] = client; + } + getMaskingSession(params={}) { + params.isVoiceRequest = 'true'; + return super.executeAction(action + this.id, 'GET', params); + } + deleteMaskingSession(params={}) { + params.isVoiceRequest = 'true'; + return super.executeAction(action + this.id, 'DELETE', params); + } + updateMaskingSession(params) { + params.isVoiceRequest = 'true'; + return super.executeAction(action + this.id, 'POST', params); + } +} +export class MaskingSessionInterface extends PlivoResourceInterface { + + constructor(client, data = {}) { + super(action, MaskingSession, idField, client); + extend(this, data); + + this[clientKey] = client; + } + /** + * Create a masking session + * @method + * @param {string} firstParty - The phone number or SIP endpoint of the first party. + * @param {string} secondParty - The phone number or SIP endpoint of the second party. + * @param {object} params - optional params to make a call + * @param {number} [params.sessionExpiry]- The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {boolean} [params.initiateCallToFirstParty] - Indicates whether the call to the first party should be initiated automatically. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + createMaskingSession(firstParty, secondParty, params = {}) { + let errors = validate([{ + field: 'first_party', + value: firstParty, + validators: ['isRequired'] + }, + { + field: 'second_party', + value: secondParty, + validators: ['isRequired'] + } + ]); + params.firstParty = firstParty; + params.secondParty = secondParty + params.isVoiceRequest = 'true'; + + let client = this[clientKey]; + return new Promise((resolve, reject) => { + client('POST', 'Masking/Session/', params) + .then(response => { + resolve(new CreateMaskingSessionResponse(response.body, idField)); + }) + .catch(error => { + reject(error); + }); + }); + } + + /** + * Update a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @param {object} params - optional params to update a session + * @param {number} [params.sessionExpiry] - The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the update masking session request fails + */ + updateMaskingSession(sessionUuid, params = {}) { + let errors = validate([{ + field: 'session_uuid', + value: sessionUuid, + validators: ['isRequired'] + } + ]); + params.sessionUuid = sessionUuid; + params.isVoiceRequest = 'true'; + + if (errors) { + return errors; + } + return new MaskingSession(this[clientKey], { + id: sessionUuid, + }).updateMaskingSession(params); + } + /** + * List masking sessions with optional filters + * @method + * @param {object} filterParams - Optional filter parameters to list masking sessions + * @param {string} [filterParams.firstParty] - The phone number or SIP endpoint of the first party. + * @param {string} [filterParams.secondParty] - The phone number or SIP endpoint of the second party. + * @param {string} [filterParams.virtualNumber] - The virtual number associated with the masking session. + * @param {string} [filterParams.status] - The status of the masking session. + * @param {string} [filterParams.createdTimeEquals] - The specific created time to filter sessions. + * @param {string} [filterParams.createdTimeLessThan] - Filter sessions created before this time. + * @param {string} [filterParams.createdTimeGreaterThan] - Filter sessions created after this time. + * @param {string} [filterParams.createdTimeLessOrEqual] - Filter sessions created before or at this time. + * @param {string} [filterParams.createdTimeGreaterOrEqual] - Filter sessions created after or at this time. + * @param {string} [filterParams.expiryTimeEquals] - The specific expiry time to filter sessions. + * @param {string} [filterParams.expiryTimeLessThan] - Filter sessions expiring before this time. + * @param {string} [filterParams.expiryTimeGreaterThan] - Filter sessions expiring after this time. + * @param {string} [filterParams.expiryTimeLessOrEqual] - Filter sessions expiring before or at this time. + * @param {string} [filterParams.expiryTimeGreaterOrEqual] - Filter sessions expiring after or at this time. + * @param {number} [filterParams.durationEquals] - The duration in seconds to filter sessions. + * @param {number} [filterParams.durationLessThan] - Filter sessions with duration less than this value. + * @param {number} [filterParams.durationGreaterThan] - Filter sessions with duration greater than this value. + * @param {number} [filterParams.durationLessOrEqual] - Filter sessions with duration less than or equal to this value. + * @param {number} [filterParams.durationGreaterOrEqual] - Filter sessions with duration greater than or equal to this value. + * @param {number} [filterParams.limit] - The maximum number of sessions to retrieve. + * @param {number} [filterParams.offset] - The offset for paginated results. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the list masking sessions request fails + */ + listMaskingSession(params) { + let client = this[clientKey]; + if (params === undefined) { + params = {} + } + params.isVoiceRequest = 'true'; + return new Promise(function (resolve, reject) { + client('GET', 'Masking/Session/', params).then(function (response) { + resolve(new ListMaskingSessionResponse(response.body, idField)); + }).catch(function (error) { + reject(error); + }); + }); + } + /** + * Get a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + getMaskingSession(sessionUuid){ + let errors = validate([{ + field: 'sessionUuid', + value: sessionUuid, + validators: ['isRequired'] + } + ]); + if (errors) { + return errors; + } + return new MaskingSession(this[clientKey], { + id: sessionUuid, + }).getMaskingSession(); + } + /** + * Delete a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + deleteMaskingSession(sessionUuid){ + let errors = validate([{ + field: 'sessionUuid', + value: sessionUuid, + validators: ['isRequired'] + } + ]); + if (errors) { + return errors; + } + return new MaskingSession(this[clientKey], { + id: sessionUuid, + }).deleteMaskingSession(); + } +} \ No newline at end of file diff --git a/lib/rest/client-test.js b/lib/rest/client-test.js index dcf282c4..2ddc6e32 100644 --- a/lib/rest/client-test.js +++ b/lib/rest/client-test.js @@ -69,6 +69,7 @@ import { ComplianceRequirementInterface } from "../resources/complianceRequireme import { ComplianceApplicationInterface } from "../resources/complianceApplications"; import { LOAInterface } from "../resources/loa"; import { HostedMessagingNumberInterface } from "../resources/hostedMessagingNumber"; +import { MaskingSessionInterface } from '../resources/maskingSession.js'; export class Client { constructor(authId, authToken, proxy) { @@ -123,6 +124,7 @@ export class Client { this.multiPartyCalls = new MultiPartyCallInterface(client); this.loa = new LOAInterface(client); this.hostedMessagingNumber = new HostedMessagingNumberInterface(client); + this.maskingSession = new MaskingSessionInterface(client); } } diff --git a/lib/rest/client.js b/lib/rest/client.js index 5e8c6ca3..5a99038a 100644 --- a/lib/rest/client.js +++ b/lib/rest/client.js @@ -32,6 +32,7 @@ import { ComplianceApplicationInterface } from "../resources/complianceApplicati import { MultiPartyCallInterface } from "../resources/multiPartyCall"; import { LOAInterface } from "../resources/loa"; import { HostedMessagingNumberInterface } from "../resources/hostedMessagingNumber"; +import { MaskingSessionInterface } from "../resources/maskingSession.js"; exports.Response = function() { @@ -111,6 +112,7 @@ export class Client { this.multiPartyCalls = new MultiPartyCallInterface(client); this.loa = new LOAInterface(client); this.hostedMessagingNumber = new HostedMessagingNumberInterface(client); + this.maskingSession = new MaskingSessionInterface(client) } toJSON() { diff --git a/test/maskingSession.js b/test/maskingSession.js new file mode 100644 index 00000000..5c445169 --- /dev/null +++ b/test/maskingSession.js @@ -0,0 +1,44 @@ +import assert from 'assert'; +import {Client} from '../lib/rest/client-test'; + +let client = new Client('sampleid', 'sammpletoken', 'sampleproxy'); + +describe('client', function () { + let authId, authToken + + describe('MaskingSession', function () { + it('should create masking session!', function () { + client.maskingSession.createMaskingSession("917708772011", "918220568648", + { + callTimeLimit: 14600, + }, + ).then(function (response) { + assert.equal(response.message, 'Session created') + }) + }); + it('should delete a masking session!', function () { + client.maskingSession.deleteMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + .then(function (response) { + assert.equal(response.message, 'Session expired') + }) + }); + it('should get masking session by session uuid!', function () { + client.maskingSession.getMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") + .then(function (response) { + assert.equal(response.response.sessionUuid, "197aa6e0-1abe-4d1c-b887-2b2406764360") + }) + }); + it('should update masking session using session uuid!', function () { + client.maskingSession.updateMaskingSession("63690013-52bb-43fa-9b0b-bf81c9f4d766") + .then(function (response) { + assert.equal(response.message, 'Session updated') + }) + }); + it('should list masking session!', function () { + client.maskingSession.listMaskingSession() + .then(function (response) { + assert.equal(response.length, 2) + }) + }); + }); +}) \ No newline at end of file diff --git a/types/resources/call.d.ts b/types/resources/call.d.ts index 34d802ae..3d6c5683 100644 --- a/types/resources/call.d.ts +++ b/types/resources/call.d.ts @@ -20,35 +20,6 @@ export class CreateCallResponse { message: string; requestUuid: Array | string; } -export class CreateMaskingSessionResponse { - constructor(params: object); - apiId: string; - sessionUuid:string; - virtualNumber:string; - message: string; - session: object; -} -export class GetMaskingSessionResponse { - constructor(params: object); - apiId: string; - response: object; -} -export class DeleteMaskingSessionResponse { - constructor(params: object); - apiId: string; - message: string; -} -export class UpdateMaskingSessionResponse { - constructor(params: object); - apiId: string; - message: string; - session: object; -} -export class ListMaskingSessionResponse { - constructor(params: object); - apiId: string; - response: object; -} export class GetQueuedCallResponse { constructor(params: object); apiId: string; @@ -346,96 +317,6 @@ export class CallInterface extends PlivoResourceInterface { * @fail {Error} returns Error */ create(from: string, to: string, answerUrl: string, params ? : {}): Promise < CreateCallResponse > ; - - /** - * Create a masking session - * @method - * @param {string} firstParty - The phone number or SIP endpoint of the first party. - * @param {string} secondParty - The phone number or SIP endpoint of the second party. - * @param {object} params - optional params to make a call - * @param {number} [params.sessionExpiry]- The duration in seconds for which the masking session will be active. - * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. - * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. - * @param {string} [params.recordFileFormat] - The file format for the recorded calls. - * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. - * @param {boolean} [params.initiateCallToFirstParty] - Indicates whether the call to the first party should be initiated automatically. - * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. - * @param {string} [params.callbackMethod] - The HTTP method for the callback request. - * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. - * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. - * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. - * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. - * @promise {object} returns PlivoGenericResponse Object - * @fail {Error} returns Error - */ - createMaskingSession(firstParty: string, secondParty: string, params ? : {}): Promise < CreateMaskingSessionResponse > ; - /** - * Update a masking session - * @method - * @param {string} sessionUuid - unique idenfier of a session - * @param {object} params - optional params to update a session - * @param {number} [params.sessionExpiry] - The duration in seconds for which the masking session will be active. - * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. - * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. - * @param {string} [params.recordFileFormat] - The file format for the recorded calls. - * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. - * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. - * @param {string} [params.callbackMethod] - The HTTP method for the callback request. - * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. - * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. - * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. - * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. - * @returns {Promise} - Resolves to a PlivoGenericResponse object - * @throws {Error} - Throws an error if the update masking session request fails - */ - updateMaskingSession(sessionUuid: string, params ? : {}): Promise < UpdateMaskingSessionResponse > ; - /** - * List masking sessions with optional filters - * @method - * @param {object} filterParams - Optional filter parameters to list masking sessions - * @param {string} [filterParams.firstParty] - The phone number or SIP endpoint of the first party. - * @param {string} [filterParams.secondParty] - The phone number or SIP endpoint of the second party. - * @param {string} [filterParams.virtualNumber] - The virtual number associated with the masking session. - * @param {string} [filterParams.status] - The status of the masking session. - * @param {string} [filterParams.createdTimeEquals] - The specific created time to filter sessions. - * @param {string} [filterParams.createdTimeLessThan] - Filter sessions created before this time. - * @param {string} [filterParams.createdTimeGreaterThan] - Filter sessions created after this time. - * @param {string} [filterParams.createdTimeLessOrEqual] - Filter sessions created before or at this time. - * @param {string} [filterParams.createdTimeGreaterOrEqual] - Filter sessions created after or at this time. - * @param {string} [filterParams.expiryTimeEquals] - The specific expiry time to filter sessions. - * @param {string} [filterParams.expiryTimeLessThan] - Filter sessions expiring before this time. - * @param {string} [filterParams.expiryTimeGreaterThan] - Filter sessions expiring after this time. - * @param {string} [filterParams.expiryTimeLessOrEqual] - Filter sessions expiring before or at this time. - * @param {string} [filterParams.expiryTimeGreaterOrEqual] - Filter sessions expiring after or at this time. - * @param {number} [filterParams.durationEquals] - The duration in seconds to filter sessions. - * @param {number} [filterParams.durationLessThan] - Filter sessions with duration less than this value. - * @param {number} [filterParams.durationGreaterThan] - Filter sessions with duration greater than this value. - * @param {number} [filterParams.durationLessOrEqual] - Filter sessions with duration less than or equal to this value. - * @param {number} [filterParams.durationGreaterOrEqual] - Filter sessions with duration greater than or equal to this value. - * @param {number} [filterParams.limit] - The maximum number of sessions to retrieve. - * @param {number} [filterParams.offset] - The offset for paginated results. - * @returns {Promise} - Resolves to a PlivoGenericResponse object - * @throws {Error} - Throws an error if the list masking sessions request fails - */ - listMaskingSession(params ? : {}): Promise < ListMaskingSessionResponse > ; - - /** - * Get a masking session - * @method - * @param {string} sessionUuid - unique idenfier of a session - * @promise {object} returns PlivoGenericResponse Object - * @fail {Error} returns Error - */ - getMaskingSession(sessionUuid: string): Promise < GetMaskingSessionResponse > ; - /** - * Delete a masking session - * @method - * @param {string} sessionUuid - unique idenfier of a session - * @promise {object} returns PlivoGenericResponse Object - * @fail {Error} returns Error - */ - deleteMaskingSession(sessionUuid: string): Promise < DeleteMaskingSessionResponse > ; - /** * Hangup A Specific Call * @method diff --git a/types/resources/maskingSession.d.ts b/types/resources/maskingSession.d.ts new file mode 100644 index 00000000..c5b277a5 --- /dev/null +++ b/types/resources/maskingSession.d.ts @@ -0,0 +1,162 @@ +export class CreateMaskingSessionResponse { + constructor(params: object); + apiId: string; + sessionUuid:string; + virtualNumber:string; + message: string; + session: object; +} +export class GetMaskingSessionResponse { + constructor(params: object); + apiId: string; + response: object; +} +export class DeleteMaskingSessionResponse { + constructor(params: object); + apiId: string; + message: string; +} +export class UpdateMaskingSessionResponse { + constructor(params: object); + apiId: string; + message: string; + session: object; +} +export class ListMaskingSessionResponse { + constructor(params: object); + apiId: string; + response: object; +} +export class MaskingSession extends PlivoResource { + constructor(client: Function, data ? : {}); + id: string; + /** + * Update a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @param {object} params - optional params to update a session + * @param {number} [params.sessionExpiry] - The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the update masking session request fails + */ + updateMaskingSession(params ? : {}): Promise < UpdateMaskingSessionResponse > ; + /** + * Get a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + getMaskingSession(): Promise < GetMaskingSessionResponse > ; + /** + * Delete a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + deleteMaskingSession(): Promise < DeleteMaskingSessionResponse > ; + +} + +export class MaskingSessionInterface extends PlivoResourceInterface { + constructor(client: Function, data ? : {}); + /** + * Create a masking session + * @method + * @param {string} firstParty - The phone number or SIP endpoint of the first party. + * @param {string} secondParty - The phone number or SIP endpoint of the second party. + * @param {object} params - optional params to make a call + * @param {number} [params.sessionExpiry]- The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {boolean} [params.initiateCallToFirstParty] - Indicates whether the call to the first party should be initiated automatically. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + createMaskingSession(firstParty: string, secondParty: string, params ? : {}): Promise < CreateMaskingSessionResponse > ; + /** + * Update a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @param {object} params - optional params to update a session + * @param {number} [params.sessionExpiry] - The duration in seconds for which the masking session will be active. + * @param {number} [params.callTimeLimit] - The maximum duration in seconds for each call in the masking session. + * @param {boolean} [params.record] - Indicates whether the calls in the masking session should be recorded. + * @param {string} [params.recordFileFormat] - The file format for the recorded calls. + * @param {string} [params.recordingCallbackUrl] - The URL to which the recording callback will be sent. + * @param {string} [params.callbackUrl] - The URL to which the callback for the masking session will be sent. + * @param {string} [params.callbackMethod] - The HTTP method for the callback request. + * @param {number} [params.ringTimeout] - The duration in seconds for which the call will ring before being canceled. + * @param {string} [params.firstPartyPlayUrl] - The URL to play audio to the first party when the call is established. + * @param {string} [params.secondPartyPlayUrl] - The URL to play audio to the second party when the call is established. + * @param {string} [params.recordingCallbackMethod] - The HTTP method for the recording callback request. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the update masking session request fails + */ + updateMaskingSession(sessionUuid: string, params ? : {}): Promise < UpdateMaskingSessionResponse > ; + /** + * List masking sessions with optional filters + * @method + * @param {object} filterParams - Optional filter parameters to list masking sessions + * @param {string} [filterParams.firstParty] - The phone number or SIP endpoint of the first party. + * @param {string} [filterParams.secondParty] - The phone number or SIP endpoint of the second party. + * @param {string} [filterParams.virtualNumber] - The virtual number associated with the masking session. + * @param {string} [filterParams.status] - The status of the masking session. + * @param {string} [filterParams.createdTimeEquals] - The specific created time to filter sessions. + * @param {string} [filterParams.createdTimeLessThan] - Filter sessions created before this time. + * @param {string} [filterParams.createdTimeGreaterThan] - Filter sessions created after this time. + * @param {string} [filterParams.createdTimeLessOrEqual] - Filter sessions created before or at this time. + * @param {string} [filterParams.createdTimeGreaterOrEqual] - Filter sessions created after or at this time. + * @param {string} [filterParams.expiryTimeEquals] - The specific expiry time to filter sessions. + * @param {string} [filterParams.expiryTimeLessThan] - Filter sessions expiring before this time. + * @param {string} [filterParams.expiryTimeGreaterThan] - Filter sessions expiring after this time. + * @param {string} [filterParams.expiryTimeLessOrEqual] - Filter sessions expiring before or at this time. + * @param {string} [filterParams.expiryTimeGreaterOrEqual] - Filter sessions expiring after or at this time. + * @param {number} [filterParams.durationEquals] - The duration in seconds to filter sessions. + * @param {number} [filterParams.durationLessThan] - Filter sessions with duration less than this value. + * @param {number} [filterParams.durationGreaterThan] - Filter sessions with duration greater than this value. + * @param {number} [filterParams.durationLessOrEqual] - Filter sessions with duration less than or equal to this value. + * @param {number} [filterParams.durationGreaterOrEqual] - Filter sessions with duration greater than or equal to this value. + * @param {number} [filterParams.limit] - The maximum number of sessions to retrieve. + * @param {number} [filterParams.offset] - The offset for paginated results. + * @returns {Promise} - Resolves to a PlivoGenericResponse object + * @throws {Error} - Throws an error if the list masking sessions request fails + */ + listMaskingSession(params ? : {}): Promise < ListMaskingSessionResponse > ; + + /** + * Get a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + getMaskingSession(sessionUuid: string): Promise < GetMaskingSessionResponse > ; + /** + * Delete a masking session + * @method + * @param {string} sessionUuid - unique idenfier of a session + * @promise {object} returns PlivoGenericResponse Object + * @fail {Error} returns Error + */ + deleteMaskingSession(sessionUuid: string): Promise < DeleteMaskingSessionResponse > ; +} \ No newline at end of file diff --git a/types/rest/client-test.d.ts b/types/rest/client-test.d.ts index 29572f6b..7b5732d9 100644 --- a/types/rest/client-test.d.ts +++ b/types/rest/client-test.d.ts @@ -16,6 +16,7 @@ export class Client { media: MediaInterface; loa: LOAInterface; hostedMessagingNumber: HostedMessagingNumberInterface; + maskingSession: MaskingSessionInterface; } /** * Plivo API client which can be used to access the Plivo APIs. @@ -43,3 +44,5 @@ import { MediaInterface } from "../resources/media.js"; import { Phlo } from "../resources/phlo.js"; import { LOAInterface } from "../resources/loa.js"; import { HostedMessagingNumberInterface } from "../resources/hostedMessagingNumber.js"; +import { MaskingSessionInterface } from "../resources/maskingSession.js"; + diff --git a/types/rest/client.d.ts b/types/rest/client.d.ts index 261bd4fb..d369e38c 100644 --- a/types/rest/client.d.ts +++ b/types/rest/client.d.ts @@ -31,6 +31,7 @@ export class Client { complianceApplications: ComplianceApplicationInterface; loa: LOAInterface; hostedMessagingNumber: HostedMessagingNumberInterface; + maskingSession:MaskingSessionInterface; toJSON(...args: any[]): any; } /** @@ -65,3 +66,5 @@ import { ComplianceRequirementInterface } from "../resources/complianceRequireme import { ComplianceApplicationInterface } from "../resources/complianceApplications"; import { LOAInterface } from "../resources/loa"; import { HostedMessagingNumberInterface } from "../resources/hostedMessagingNumber"; +import { MaskingSessionInterface } from "../resources/maskingSession.js"; + From c78eb60d738d3579defe89e5d9cb749b3067a582 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Fri, 21 Jul 2023 12:14:01 +0530 Subject: [PATCH 07/12] modified node sdk for number masking --- lib/resources/call.js | 12 ------------ types/resources/call.d.ts | 3 ++- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/resources/call.js b/lib/resources/call.js index ffaea1d0..779a66cb 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -504,18 +504,6 @@ export class Call extends PlivoResource { params.isVoiceRequest = 'true'; return super.executeAction('Request/' + this.id + '/', 'DELETE', params, ''); } - getMaskingSession(params={}) { - params.isVoiceRequest = 'true'; - return super.executeAction('Masking/Session/' + this.id, 'GET', params); - } - deleteMaskingSession(params={}) { - params.isVoiceRequest = 'true'; - return super.executeAction('Masking/Session/' + this.id, 'DELETE', params); - } - updateMaskingSession(params) { - params.isVoiceRequest = 'true'; - return super.executeAction('Masking/Session/' + this.id, 'POST', params); - } } const liveCallInterfaceKey = Symbol('liveCallInterface'); diff --git a/types/resources/call.d.ts b/types/resources/call.d.ts index 3d6c5683..1bab4a86 100644 --- a/types/resources/call.d.ts +++ b/types/resources/call.d.ts @@ -317,7 +317,8 @@ export class CallInterface extends PlivoResourceInterface { * @fail {Error} returns Error */ create(from: string, to: string, answerUrl: string, params ? : {}): Promise < CreateCallResponse > ; - /** + + /** * Hangup A Specific Call * @method * @param {string} callUUID - call uuid to hangup call From 68899e4b30f4a30da715384ea7dd3d5690d95c4c Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Fri, 21 Jul 2023 12:17:28 +0530 Subject: [PATCH 08/12] modified node sdk for number masking --- lib/resources/call.js | 1 + test/calls.js | 35 ----------------------------------- types/resources/call.d.ts | 2 +- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/lib/resources/call.js b/lib/resources/call.js index 779a66cb..9fa9d125 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -657,6 +657,7 @@ export class CallInterface extends PlivoResourceInterface { }); }); } + /** * Hangup A Specific Call * @method diff --git a/test/calls.js b/test/calls.js index c667e194..5ce80886 100644 --- a/test/calls.js +++ b/test/calls.js @@ -293,39 +293,4 @@ describe('calls', function () { }) }); }); - describe('MaskingSession', function () { - it('should create masking session!', function () { - client.calls.createMaskingSession("917708772011", "918220568648", - { - callTimeLimit: 14600, - }, - ).then(function (response) { - assert.equal(response.message, 'Session created') - }) - }); - it('should delete a masking session!', function () { - client.calls.deleteMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") - .then(function (response) { - assert.equal(response.message, 'Session expired') - }) - }); - it('should get masking session by session uuid!', function () { - client.calls.getMaskingSession("197aa6e0-1abe-4d1c-b887-2b2406764360") - .then(function (response) { - assert.equal(response.response.sessionUuid, "197aa6e0-1abe-4d1c-b887-2b2406764360") - }) - }); - it('should update masking session using session uuid!', function () { - client.calls.updateMaskingSession("63690013-52bb-43fa-9b0b-bf81c9f4d766") - .then(function (response) { - assert.equal(response.message, 'Session updated') - }) - }); - it('should list masking session!', function () { - client.calls.listMaskingSession() - .then(function (response) { - assert.equal(response.length, 2) - }) - }); - }); }); diff --git a/types/resources/call.d.ts b/types/resources/call.d.ts index 1bab4a86..0e2dc0ff 100644 --- a/types/resources/call.d.ts +++ b/types/resources/call.d.ts @@ -318,7 +318,7 @@ export class CallInterface extends PlivoResourceInterface { */ create(from: string, to: string, answerUrl: string, params ? : {}): Promise < CreateCallResponse > ; - /** + /** * Hangup A Specific Call * @method * @param {string} callUUID - call uuid to hangup call From af2509710ff10f224889eaf22f90d2f101ea7e35 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Mon, 31 Jul 2023 13:35:07 +0530 Subject: [PATCH 09/12] removed action --- lib/resources/maskingSession.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/resources/maskingSession.js b/lib/resources/maskingSession.js index a471a557..d9c74fba 100644 --- a/lib/resources/maskingSession.js +++ b/lib/resources/maskingSession.js @@ -68,15 +68,15 @@ export class MaskingSession extends PlivoResource { } getMaskingSession(params={}) { params.isVoiceRequest = 'true'; - return super.executeAction(action + this.id, 'GET', params); + return super.executeAction(this.id, 'GET', params); } deleteMaskingSession(params={}) { params.isVoiceRequest = 'true'; - return super.executeAction(action + this.id, 'DELETE', params); + return super.executeAction(this.id, 'DELETE', params); } updateMaskingSession(params) { params.isVoiceRequest = 'true'; - return super.executeAction(action + this.id, 'POST', params); + return super.executeAction(this.id, 'POST', params); } } export class MaskingSessionInterface extends PlivoResourceInterface { From 588ab5728574fa22205bc71c2c8c89898a2db65d Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Mon, 31 Jul 2023 15:30:06 +0530 Subject: [PATCH 10/12] added adk version --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 693fa9a5..209716f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Change Log + +## [4.52.0](https://github.com/plivo/plivo-python/tree/v4.52.0) (2022-07-31) +**Feature - Number Masking** +- Added Create, Delete, Update, Get and List Masking Session API + ## [v4.51.0](https://github.com/plivo/plivo-go/tree/v4.51.0) (2023-07-07) **Fix Intermediate GET request failure** - GET API request body removed diff --git a/package.json b/package.json index d316b602..f2e5a8d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.51.0", + "version": "4.52.0", "description": "A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML", "homepage": "https://github.com/plivo/plivo-node", "files": [ From 0183191121762a72dafda199b4c681d912a80029 Mon Sep 17 00:00:00 2001 From: manjunath-plivo <85923934+manjunath-plivo@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:57:45 +0530 Subject: [PATCH 11/12] correct release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 209716f1..fcfd1fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.52.0](https://github.com/plivo/plivo-python/tree/v4.52.0) (2022-07-31) +## [4.52.0](https://github.com/plivo/plivo-python/tree/v4.52.0) (2023-07-31) **Feature - Number Masking** - Added Create, Delete, Update, Get and List Masking Session API From 50502409cc688ce0c127b409f184c734e4d5ef7e Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Mon, 31 Jul 2023 16:02:10 +0530 Subject: [PATCH 12/12] added adk version --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 209716f1..fcfd1fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.52.0](https://github.com/plivo/plivo-python/tree/v4.52.0) (2022-07-31) +## [4.52.0](https://github.com/plivo/plivo-python/tree/v4.52.0) (2023-07-31) **Feature - Number Masking** - Added Create, Delete, Update, Get and List Masking Session API