diff --git a/CHANGELOG.md b/CHANGELOG.md index 693fa9a5..fcfd1fd9 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) (2023-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/lib/resources/call.js b/lib/resources/call.js index b9166db6..9fa9d125 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -657,7 +657,7 @@ export class CallInterface extends PlivoResourceInterface { }); }); } - + /** * Hangup A Specific Call * @method diff --git a/lib/resources/maskingSession.js b/lib/resources/maskingSession.js new file mode 100644 index 00000000..d9c74fba --- /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(this.id, 'GET', params); + } + deleteMaskingSession(params={}) { + params.isVoiceRequest = 'true'; + return super.executeAction(this.id, 'DELETE', params); + } + updateMaskingSession(params) { + params.isVoiceRequest = 'true'; + return super.executeAction(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/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/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": [ 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/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"; +