From 53f5566f10bcb19950dd42ab18bea0a9681417cd Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Wed, 6 Sep 2023 17:02:41 +0530 Subject: [PATCH 01/10] Number masking SDK changes --- .../MaskingSession/MaskingSession.php | 65 +++++ .../MaskingSessionCreateResponse.php | 63 +++++ .../MaskingSessionInterface.php | 265 ++++++++++++++++++ .../MaskingSessionListResponse.php | 58 ++++ .../MaskingSessionUpdateResponse.php | 39 +++ 5 files changed, 490 insertions(+) create mode 100644 src/Plivo/Resources/MaskingSession/MaskingSession.php create mode 100644 src/Plivo/Resources/MaskingSession/MaskingSessionCreateResponse.php create mode 100644 src/Plivo/Resources/MaskingSession/MaskingSessionInterface.php create mode 100644 src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php create mode 100644 src/Plivo/Resources/MaskingSession/MaskingSessionUpdateResponse.php diff --git a/src/Plivo/Resources/MaskingSession/MaskingSession.php b/src/Plivo/Resources/MaskingSession/MaskingSession.php new file mode 100644 index 00000000..871ba61f --- /dev/null +++ b/src/Plivo/Resources/MaskingSession/MaskingSession.php @@ -0,0 +1,65 @@ +properties = [ + // 'firstParty' => $response['first_party'], + // 'secondParty' => $response['second_party'], + // 'virtualNumber' => $response['virtual_number'], + // 'status' => $response['status'], + // 'initiateCallToFirstParty' => $response['initiate_call_to_first_party'], + // 'sessionUuid' => $response['session_uuid'], + // 'callbackUrl' => $response['callback_url'], + // 'callbackMethod' => $response['callback_method'], + // 'createdAt' => $response['created_time'], + // 'updatedAt' => $response['modified_time'], + // 'expiryAt' => $response['expiry_time'], + // 'duration' => $response['duration'], + // 'amount' => $response['amount'], + // 'callTimeLimit' => $response['call_time_limit'], + // 'ringTimeout' => $response['ring_timeout'], + // 'firstPartyPlayUrl' => $response['first_party_play_url'], + // 'secondPartyPlayUrl' => $response['second_party_play_url'], + // 'record' => $response['record'], + // 'recordFileFormat' => $response['record_file_format'], + // 'recordingCallbackUrl' => $response['recording_callback_url'], + // 'recordingCallbackMethod' => $response['recording_callback_method'], + // 'interaction' => $response['interaction'], + // 'totalCallAmount' => $response['total_call_amount'], + // 'totalCallCount' => $response['total_call_count'], + // 'totalCallBilledDuration' => $response['total_call_billed_duration'], + // 'totalSessionAmount' => $response['total_session_amount'], + // 'lastInteractionTime' => $response['last_interaction_time'] + // ]; + + $this->properties = [ + 'api_id' => $response['api_id'], + 'response' => $response['response'] + ]; + + $this->pathParams = [ + 'authId' => $authId, + 'sessionUuid' => $response['response']['session_uuid'] + ]; + + $this->id = $response['session_uuid']; + + } +} \ No newline at end of file diff --git a/src/Plivo/Resources/MaskingSession/MaskingSessionCreateResponse.php b/src/Plivo/Resources/MaskingSession/MaskingSessionCreateResponse.php new file mode 100644 index 00000000..79693364 --- /dev/null +++ b/src/Plivo/Resources/MaskingSession/MaskingSessionCreateResponse.php @@ -0,0 +1,63 @@ +sessionUuid = $sessionUuid; + $this->virtualNumber = $virtualNumber; + $this->session = $session; + + } + + /** + * @return mixed + */ + public function getSessionUuid() + { + return $this->sessionUuid; + } + + /** + * @return mixed + */ + public function getVirtualNumber() + { + return $this->virtualNumber; + } + + /** + * @return mixed + */ + public function getSession() + { + return $this->session; + } + + + + +} \ No newline at end of file diff --git a/src/Plivo/Resources/MaskingSession/MaskingSessionInterface.php b/src/Plivo/Resources/MaskingSession/MaskingSessionInterface.php new file mode 100644 index 00000000..644a65d3 --- /dev/null +++ b/src/Plivo/Resources/MaskingSession/MaskingSessionInterface.php @@ -0,0 +1,265 @@ +pathParams = [ + 'authId' => $authId + ]; + $this->uri = "Account/".$authId."/Masking/Session/"; + } + + /** + * 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 array $optionalArgs + * + Valid arguments with their types + * + [number] sessionExpiry - The duration in seconds for which the masking session will be active. + * + [number] callTimeLimit - The maximum duration in seconds for each call in the masking session. + * + [boolean] record - Indicates whether the calls in the masking session should be recorded. + * + [string] recordFileFormat - The file format for the recorded calls. + * + [string] recordingCallbackUrl - The URL to which the recording callback will be sent. + * + [boolean] initiateCallToFirstParty - Indicates whether the call to the first party should be initiated automatically. + * + [string] callbackUrl - The URL to which the callback for the masking session will be sent. + * + [string] callbackMethod] - The HTTP method for the callback request. + * + [number] ringTimeout - The duration in seconds for which the call will ring before being canceled. + * + [string] firstPartyPlayUrl - The URL to play audio to the first party when the call is established. + * + [string] secondPartyPlayUrl - The URL to play audio to the second party when the call is established. + * + [string] recordingCallbackMethod - The HTTP method for the recording callback request. + + * @return JSON output + * @throws PlivoValidationException,PlivoResponseException + */ + public function createMaskingSession($firstParty, $secondParty, + array $optionalArgs = []) + { + $mandatoryArgs = [ + 'first_party' => $firstParty, + 'second_party' => $secondParty, + ]; + $optionalArgs['isVoiceRequest'] = true; + + if (ArrayOperations::checkNull($mandatoryArgs)) { + throw new PlivoValidationException( + "Mandatory parameters cannot be null"); + } + + + $response = $this->client->update( + $this->uri, + array_merge($mandatoryArgs, $optionalArgs) + ); + + $responseContents = $response->getContent(); + if(!array_key_exists("error",$responseContents)){ + return new MaskingSessionCreateResponse( + $responseContents['api_id'], + $responseContents['session_uuid'], + $responseContents['virtual_number'], + $responseContents['message'], + $responseContents['session'], + $response->getStatusCode() + ); + } else { + throw new PlivoResponseException( + $responseContents['error'], + 0, + null, + $response->getContent(), + $response->getStatusCode() + + ); + } + + } + + /** + * delete a masking session. + * @param string $sessionUuid + * @throws PlivoValidationException + */ + public function deleteMaskingSession($sessionUuid) + { + if (ArrayOperations::checkNull([$sessionUuid])) { + throw + new PlivoValidationException( + 'session uuid is mandatory'); + } + $optionalArgs['isVoiceRequest'] = true; + return $this->client->delete( + $this->uri . $sessionUuid . '/', + $optionalArgs + ); + + } + + /** + * Get details of a masking session + * @param string $sessionUuid + * @throws PlivoValidationException + */ + public function getMaskingSession($sessionUuid) + { + if (ArrayOperations::checkNull([$sessionUuid])) { + throw + new PlivoValidationException( + 'session uuid is mandatory'); + } + $optionalArgs['isVoiceRequest'] = true; + $response = $this->client->fetch( + $this->uri . $sessionUuid . '/', + $optionalArgs + ); + + return new MaskingSession( + $this->client, + $response->getContent(), + $this->pathParams['authId']); + } + + /** + * Update a masking session + * @method + * @param {string} sessionUuid + * + * @param array $optionalArgs + * + Valid arguments with their types + * + [number] sessionExpiry - The duration in seconds for which the masking session will be active. + * + [number] callTimeLimit - The maximum duration in seconds for each call in the masking session. + * + [boolean] record - Indicates whether the calls in the masking session should be recorded. + * + [string] recordFileFormat - The file format for the recorded calls. + * + [string] recordingCallbackUrl - The URL to which the recording callback will be sent. + * + [string] callbackUrl - The URL to which the callback for the masking session will be sent. + * + [string] callbackMethod] - The HTTP method for the callback request. + * + [number] ringTimeout - The duration in seconds for which the call will ring before being canceled. + * + [string] firstPartyPlayUrl - The URL to play audio to the first party when the call is established. + * + [string] secondPartyPlayUrl - The URL to play audio to the second party when the call is established. + * + [string] recordingCallbackMethod - The HTTP method for the recording callback request. + + * @return ResponseUpdate + * @throws PlivoValidationException,PlivoResponseException + */ + public function updateMaskingSession($sessionUuid, + array $optionalArgs = []) + { + if (ArrayOperations::checkNull([$sessionUuid])) { + throw + new PlivoValidationException( + 'session uuid is mandatory'); + } + $optionalArgs['isVoiceRequest'] = true; + + $response = $this->client->update( + $this->uri . $sessionUuid . '/', + $optionalArgs + ); + + $responseContents = $response->getContent(); + + if(!array_key_exists("error",$responseContents)){ + return new MaskingSessionUpdateResponse( + $responseContents['api_id'], + $responseContents['message'], + $responseContents['session'], + $response->getStatusCode() + ); + } else { + throw new PlivoResponseException( + $responseContents['error'], + 0, + null, + $response->getContent(), + $response->getStatusCode() + + ); + } + + } + + + /** + * Get list of masking sessions + * + * @param array $optionalArgs + * + Valid arguments with their types + * + [string] firstParty - The phone number or SIP endpoint of the first party. + * + [string] secondParty - The phone number or SIP endpoint of the second party. + * + [string] virtual number - The virtual number associated with the masking session. + * + [string] status - The status of the masking session. + * + [string] created_time - Filter out the session based on its created time. The filter can be used in one of the following five forms:
+ * created_time: Input the exact value. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. + * created_time\__gt: gt stands for greater than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose created time is after 2012-03-21 11:47, use end_time\__gt=2012-03-21 11:47
+ * created_time\__gte: gte stands for greater than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose created time is after or exactly at 2012-03-21 11:47[:30], use end_time\__gte=2012-03-21 11:47[:30]
+ * created_time\__lt: lt stands for lesser than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose created time is before 2012-03-21 11:47, use end_time\__lt=2012-03-21 11:47
+ * created_time\__lte: lte stands for lesser than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose created time is before or exactly at 2012-03-21 11:47[:30], use end_time\__lte=2012-03-21 11:47[:30] + * + [string] expiry_time - Filter out the session based on its expiry time. The filter can be used in the following five forms:
+ * expiry_time: Input the exact value. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. + * expiry_time\__gt: gt stands for greater than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose expiry time is after 2012-03-21 11:47, use end_time\__gt=2012-03-21 11:47
+ * expiry_time\__gte: gte stands for greater than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose expirty time is after or exactly at 2012-03-21 11:47[:30], use end_time\__gte=2012-03-21 11:47[:30]
+ * expiry_time\__lt: lt stands for lesser than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose expiry time is before 2012-03-21 11:47, use end_time\__lt=2012-03-21 11:47
+ * expiry_time\__lte: lte stands for lesser than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all sessions whose expiry time is before or exactly at 2012-03-21 11:47[:30], use end_time\__lte=2012-03-21 11:47[:30] + * + [string] duration - Filter the results according to duration of session. The filter can be used in one of the following five forms:
+ * duration: Input the exact value. E.g., to filter out sessions that were exactly three minutes long, use duration=180
+ * duration\__gt: gt stands for greater than. E.g., to filter out sessions that were more than two hours in duration _duration\__gt=7200
+ * duration\__gte: gte stands for greater than or equal to. E.g., to filter out sessions that were two hours or more in duration bill_duration\__gte=7200
+ * duration\__lt: lt stands for lesser than. E.g., to filter out sessions that were less than seven minutes in duration bill_duration\__lt=420
+ * duration\__lte: lte stands for lesser than or equal to. E.g., to filter out sessions that were two hours or less in duration bill_duration\__lte=7200 + + * Note: The above filters can be combined to get sessions that ended in a particular time range. The timestamps need to be UTC timestamps. + * + [int] limit - Used to display the number of results per page. The maximum number of results that can be fetched is 20. + * + [int] offset - Denotes the number of value items by which the results should be offset. E.g., If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results. + * @return MaskingSessionList + * @throws PlivoResponseException + */ + public function listMaskingSession(array $optionalArgs = []) + { + $optionalArgs['isVoiceRequest'] = true; + $response = $this->client->fetch( + $this->uri, + $optionalArgs + ); + + $responseContents = $response->getContent(); + if(!array_key_exists("error",$responseContents)){ + return new MaskingSessionListResponse( + $responseContents['api_id'], + $responseContents['response']['meta'], + $responseContents['response']['objects'], + $response->getStatusCode() + ); + } else { + throw new PlivoResponseException( + $responseContents['error'], + 0, + null, + $response->getContent(), + $response->getStatusCode() + ); + } + } +} diff --git a/src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php b/src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php new file mode 100644 index 00000000..ef4c6457 --- /dev/null +++ b/src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php @@ -0,0 +1,58 @@ +meta = $meta; + $this->objects = $objects; + } + + public function getMeta() + { + return $this->meta; + } + + public function getObjects() + { + return $this->objects; + } +} \ No newline at end of file diff --git a/src/Plivo/Resources/MaskingSession/MaskingSessionUpdateResponse.php b/src/Plivo/Resources/MaskingSession/MaskingSessionUpdateResponse.php new file mode 100644 index 00000000..351ad70e --- /dev/null +++ b/src/Plivo/Resources/MaskingSession/MaskingSessionUpdateResponse.php @@ -0,0 +1,39 @@ +session = $session; + + } + + /** + * @return mixed + */ + public function getSession() + { + return $this->session; + } + +} \ No newline at end of file From 8fe269a8850be20fbf735c26758372be3ebd427f Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Wed, 6 Sep 2023 18:59:34 +0530 Subject: [PATCH 02/10] UTs added --- .../MaskingSession/MaskingSession.php | 2 +- tests/Mocks/maskingSessionCreateResponse.json | 35 +++++ tests/Mocks/maskingSessionDeleteResponse.json | 4 + tests/Mocks/maskingSessionGetResponse.json | 32 +++++ tests/Mocks/maskingSessionListResponse.json | 74 ++++++++++ tests/Mocks/maskingSessionUpdateResponse.json | 33 +++++ tests/Resources/MaskingSessionTest.php | 132 ++++++++++++++++++ 7 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 tests/Mocks/maskingSessionCreateResponse.json create mode 100644 tests/Mocks/maskingSessionDeleteResponse.json create mode 100644 tests/Mocks/maskingSessionGetResponse.json create mode 100644 tests/Mocks/maskingSessionListResponse.json create mode 100644 tests/Mocks/maskingSessionUpdateResponse.json create mode 100644 tests/Resources/MaskingSessionTest.php diff --git a/src/Plivo/Resources/MaskingSession/MaskingSession.php b/src/Plivo/Resources/MaskingSession/MaskingSession.php index 871ba61f..bc60983c 100644 --- a/src/Plivo/Resources/MaskingSession/MaskingSession.php +++ b/src/Plivo/Resources/MaskingSession/MaskingSession.php @@ -59,7 +59,7 @@ function __construct( 'sessionUuid' => $response['response']['session_uuid'] ]; - $this->id = $response['session_uuid']; + $this->id = $response['response']['session_uuid']; } } \ No newline at end of file diff --git a/tests/Mocks/maskingSessionCreateResponse.json b/tests/Mocks/maskingSessionCreateResponse.json new file mode 100644 index 00000000..55642f60 --- /dev/null +++ b/tests/Mocks/maskingSessionCreateResponse.json @@ -0,0 +1,35 @@ +{ + "api_id": "1c8beb2c-01bf-4649-b0fb-5e3bd7836311", + "session_uuid": "c2146ba4-798d-49b0-8580-53851a16e055", + "virtual_number": "+916361728680", + "message": "Session created", + "session": { + "first_party": "917708772011", + "second_party": "919976106830", + "virtual_number": "916361728680", + "status": "active", + "initiate_call_to_first_party": false, + "session_uuid": "c2146ba4-798d-49b0-8580-53851a16e055", + "callback_url": "http://plivobin.non-prod.plivops.com/w7mf5kw7", + "callback_method": "GET", + "created_time": "2023-07-05 10:25:40.877364 +0000 UTC", + "modified_time": "2023-07-05 16:33:08.444312 +0000 UTC", + "expiry_time": "2023-07-05 12:43:08.222701 +0000 UTC", + "duration": 8247, + "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": "" + } + } \ No newline at end of file diff --git a/tests/Mocks/maskingSessionDeleteResponse.json b/tests/Mocks/maskingSessionDeleteResponse.json new file mode 100644 index 00000000..d365fc8f --- /dev/null +++ b/tests/Mocks/maskingSessionDeleteResponse.json @@ -0,0 +1,4 @@ +{ + "api_id": "4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5", + "message": "Session expired" + } \ No newline at end of file diff --git a/tests/Mocks/maskingSessionGetResponse.json b/tests/Mocks/maskingSessionGetResponse.json new file mode 100644 index 00000000..85e8ac7f --- /dev/null +++ b/tests/Mocks/maskingSessionGetResponse.json @@ -0,0 +1,32 @@ +{ + "api_id": "b503c0b9-a419-406f-8e49-9856844600ab", + "response": { + "first_party": "917708772011", + "second_party": "919976106830", + "virtual_number": "916361728680", + "status": "active", + "initiate_call_to_first_party": false, + "session_uuid": "4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5", + "callback_url": "http://plivobin.non-prod.plivops.com/w7mf5kw7", + "callback_method": "GET", + "created_time": "2023-07-05 10:25:40.877364 +0000 UTC", + "modified_time": "2023-07-05 10:25:40.877364 +0000 UTC", + "expiry_time": "2023-07-05 12:05:40.877364 +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": "" + } + } \ No newline at end of file diff --git a/tests/Mocks/maskingSessionListResponse.json b/tests/Mocks/maskingSessionListResponse.json new file mode 100644 index 00000000..fd66fb11 --- /dev/null +++ b/tests/Mocks/maskingSessionListResponse.json @@ -0,0 +1,74 @@ +{ + "api_id": "2900eb2b-0d47-4464-8eff-bbd413e15bf9", + "response": { + "meta": { + "limit": 20, + "next": null, + "offset": 0, + "previous": null, + "total_count": 2 + }, + "objects": [ + { + "amount": 0, + "call_time_limit": 600, + "callback_method": "GET", + "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "created_time": "2023-07-05 10:25:40.877364 +0000 UTC", + "duration": 2863, + "expiry_time": "2023-07-05 11:13:23.895313 +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-05 11:03:23.895354 +0000 UTC", + "record": true, + "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/c2146ba4-798d-49b0-8580-53851a16e055/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "c2146ba4-798d-49b0-8580-53851a16e055", + "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/w7mf5kw7", + "created_time": "2023-06-30 06:39:06.742974 +0000 UTC", + "duration": 6000, + "expiry_time": "2023-06-30 06:39:16.99714 +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-06-30 12:09:17.221954 +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/dd3bb3c2-4f18-4988-87f1-9116b00bb875/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "dd3bb3c2-4f18-4988-87f1-9116b00bb875", + "status": "expired", + "total_call_amount": 0, + "total_call_billed_duration": 0, + "total_call_count": 0, + "total_session_amount": 0, + "virtual_number": "916361728680" + } + ] + } + } \ No newline at end of file diff --git a/tests/Mocks/maskingSessionUpdateResponse.json b/tests/Mocks/maskingSessionUpdateResponse.json new file mode 100644 index 00000000..95d63e99 --- /dev/null +++ b/tests/Mocks/maskingSessionUpdateResponse.json @@ -0,0 +1,33 @@ +{ + "api_id": "b5506536-83d0-498f-929f-4427cb6ca391", + "message": "Session updated", + "session": { + "first_party": "917708772011", + "second_party": "919976106830", + "virtual_number": "916361728680", + "status": "active", + "initiate_call_to_first_party": false, + "session_uuid": "7b5c5e17-e1e9-4ccd-a480-42f5c97fbe96", + "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "callback_method": "GET", + "created_time": "2023-07-06 10:53:32.814078 +0000 +0000", + "modified_time": "2023-07-06 10:53:45.106122 +0000 UTC", + "expiry_time": "2023-07-06 11:03:45.106117 +0000 UTC", + "duration": 612, + "amount": 0, + "call_time_limit": 600, + "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": true, + "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": "" + } + } \ No newline at end of file diff --git a/tests/Resources/MaskingSessionTest.php b/tests/Resources/MaskingSessionTest.php new file mode 100644 index 00000000..3a498dd9 --- /dev/null +++ b/tests/Resources/MaskingSessionTest.php @@ -0,0 +1,132 @@ + '919999999999', + 'second_party' => '919999999998' + + ]); + $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionCreateResponse.json'); + + $this->mock(new PlivoResponse($request,201, $body)); + + $actual = $this->client->maskingSessions->createMaskingSession( + '919999999999', '919999999998'); + + $this->assertRequest($request); + + self::assertNotNull($actual); + + // $actual = json_decode($actual); + + self::assertEquals($actual->message, "Session created"); + self::assertEquals($actual->apiId, "1c8beb2c-01bf-4649-b0fb-5e3bd7836311"); + } + + function testUpdateMaskingSession() + { + $request = new PlivoRequest( + 'POST', + 'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/', + [ + '4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5', + array( + 'call_time_limit' => 1600, + 'record_file_format' => 'wav' + ) + + ]); + $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionUpdateResponse.json'); + + $this->mock(new PlivoResponse($request,201, $body)); + + $actual = $this->client->maskingSessions->updateMaskingSession( + '4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5', + array('call_time_limit'=>1600,'record_file_format' => 'wav' + )); + + self::assertNotNull($actual); + + // $actual = json_decode($actual); + + self::assertEquals($actual->message, "Session updated"); + self::assertEquals($actual->apiId, "b5506536-83d0-498f-929f-4427cb6ca391"); + } + + + function testDeleteMaskingSession() + { + $request = new PlivoRequest( + 'DELETE', + 'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5', + []); + $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionDeleteResponse.json'); + + $this->mock(new PlivoResponse($request,204, $body)); + + $actual = $this->client->maskingSessions->deleteMaskingSession("4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5");; + + self::assertNotNull($actual); + } + + + function testGetMaskingSession() + { + $request = new PlivoRequest( + 'GET', + 'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5/', + []); + $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionGetResponse.json'); + + $this->mock(new PlivoResponse($request,200, $body)); + + $actual = $this->client->maskingSessions->getMaskingSession("4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5"); + + $this->assertRequest($request); + + self::assertNotNull($actual); + + self::assertEquals($actual->getId(), "4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5"); + } + + function testListMaskingSession() + { + $request = new PlivoRequest( + 'GET', + 'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/', + [ + array('first_party'=>'916361728680', + 'second_party' => '917708772011' + )]); + $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionListResponse.json'); + + $this->mock(new PlivoResponse($request,200, $body)); + + $actual = $this->client->maskingSessions->listMaskingSession(array('first_party'=>'916361728680', + 'second_party' => '917708772011')); + + self::assertNotNull($actual); + + self::assertEquals($actual->meta, array('total_count'=>2, 'limit'=>20, 'next'=>null, 'offset'=>0, 'previous'=>null)); + } + + + +} From 0424b207578829ff886cbe8c115fc72b4777e411 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Thu, 7 Sep 2023 10:56:14 +0530 Subject: [PATCH 03/10] typo fix --- tests/Resources/MaskingSessionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Resources/MaskingSessionTest.php b/tests/Resources/MaskingSessionTest.php index 3a498dd9..9a2c1c0b 100644 --- a/tests/Resources/MaskingSessionTest.php +++ b/tests/Resources/MaskingSessionTest.php @@ -11,7 +11,7 @@ * Class MaskingSessionlTest * @package Resources */ -class MaskingSessionlTest extends BaseTestCase +class MaskingSessionTest extends BaseTestCase { function testCreateMaskingSession() { From d3a837a1410f15bff602e6a155e987ad71a9eaed Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Thu, 7 Sep 2023 11:02:04 +0530 Subject: [PATCH 04/10] php version change --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fa84acc1..3a3ba92c 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "source": "https://github.com/plivo/plivo-php" }, "require": { - "php": ">=7.1.0", + "php": ">=7.4.0", "guzzlehttp/guzzle": "^6.3 || ^7.0", "firebase/php-jwt": ">=5.2" }, From 97eadeb53eddace54c13934ba81a2ef976029b2a Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Thu, 7 Sep 2023 12:12:01 +0530 Subject: [PATCH 05/10] commiting the missed file --- src/Plivo/RestClient.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Plivo/RestClient.php b/src/Plivo/RestClient.php index c9517891..48d6342d 100644 --- a/src/Plivo/RestClient.php +++ b/src/Plivo/RestClient.php @@ -6,6 +6,7 @@ use Plivo\Resources\Account\AccountInterface; use Plivo\Resources\Application\ApplicationInterface; use Plivo\Resources\Call\CallInterface; +use Plivo\Resources\MaskingSession\MaskingSessionInterface; use Plivo\Resources\Conference\ConferenceInterface; use Plivo\Resources\Endpoint\EndpointInterface; use Plivo\Resources\HostedMessaging\HostedMessageLOAInterface; @@ -62,6 +63,7 @@ * @property HostedMessageLOAInterface hostedMessageLOA Interface to handle all HostedMessageLOA related api calls * @property HostedMessagingNumberInterface hostedMessagingNumber Interface to handle all HostedMessagingNumber related api calls * @property ZentrunkInterface Zentrunk Interface to handle all Zentrunk Call related api + * @property MaskingSessionInterface Masking session Interface to handle all session related api calls * */ class RestClient @@ -216,6 +218,10 @@ class RestClient * @var ZentrunkInterface */ protected $_zentrunkCall; + /** + * @var MaskingSessionInterface + */ + protected $_maskingSession; /** * RestClient constructor. @@ -393,6 +399,17 @@ protected function getCalls() } return $this->_call; } + + /** + * @return MaskingSessionInterface + */ + protected function getMaskingSessions() + { + if (!$this->_maskingSession) { + $this->_maskingSession = new MaskingSessionInterface($this->client, $this->client->getAuthId()); + } + return $this->_maskingSession; + } /** * @return TokenInterface */ From df9577f520b792d7df40cbd9ae5e4fc36aec8b3a Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Thu, 7 Sep 2023 12:17:44 +0530 Subject: [PATCH 06/10] reverting the unwanted changes --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a3ba92c..fa84acc1 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "source": "https://github.com/plivo/plivo-php" }, "require": { - "php": ">=7.4.0", + "php": ">=7.1.0", "guzzlehttp/guzzle": "^6.3 || ^7.0", "firebase/php-jwt": ">=5.2" }, From 5dafeab377e099de85061adde46109d28b3429ca Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Fri, 8 Sep 2023 15:58:26 +0530 Subject: [PATCH 07/10] removed unwanted comments --- .../MaskingSession/MaskingSessionListResponse.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php b/src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php index ef4c6457..19dd89f1 100644 --- a/src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php +++ b/src/Plivo/Resources/MaskingSession/MaskingSessionListResponse.php @@ -10,21 +10,6 @@ * Class MaskingSessionList * @package Plivo\Resources\Call */ -// class MaskingSessionListResponse extends ResourceList -// { - -// /** -// * MaskingSessionList constructor. -// * @param BaseClient $plivoClient -// * @param array $meta -// * @param array $resources -// */ -// function __construct(BaseClient $plivoClient, $meta, array $resources) -// { -// parent::__construct($plivoClient, $meta, $resources); -// } - -// } class MaskingSessionListResponse extends ResponseUpdate { From 862505fa318716fb1daa85847c221594f786a51d Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Fri, 8 Sep 2023 15:59:47 +0530 Subject: [PATCH 08/10] removed unwanted comments --- .../MaskingSession/MaskingSession.php | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/Plivo/Resources/MaskingSession/MaskingSession.php b/src/Plivo/Resources/MaskingSession/MaskingSession.php index bc60983c..d28ac263 100644 --- a/src/Plivo/Resources/MaskingSession/MaskingSession.php +++ b/src/Plivo/Resources/MaskingSession/MaskingSession.php @@ -17,38 +17,7 @@ class MaskingSession extends Resource function __construct( BaseClient $client, $response, $authId) { - parent::__construct($client); - - // $this->properties = [ - // 'firstParty' => $response['first_party'], - // 'secondParty' => $response['second_party'], - // 'virtualNumber' => $response['virtual_number'], - // 'status' => $response['status'], - // 'initiateCallToFirstParty' => $response['initiate_call_to_first_party'], - // 'sessionUuid' => $response['session_uuid'], - // 'callbackUrl' => $response['callback_url'], - // 'callbackMethod' => $response['callback_method'], - // 'createdAt' => $response['created_time'], - // 'updatedAt' => $response['modified_time'], - // 'expiryAt' => $response['expiry_time'], - // 'duration' => $response['duration'], - // 'amount' => $response['amount'], - // 'callTimeLimit' => $response['call_time_limit'], - // 'ringTimeout' => $response['ring_timeout'], - // 'firstPartyPlayUrl' => $response['first_party_play_url'], - // 'secondPartyPlayUrl' => $response['second_party_play_url'], - // 'record' => $response['record'], - // 'recordFileFormat' => $response['record_file_format'], - // 'recordingCallbackUrl' => $response['recording_callback_url'], - // 'recordingCallbackMethod' => $response['recording_callback_method'], - // 'interaction' => $response['interaction'], - // 'totalCallAmount' => $response['total_call_amount'], - // 'totalCallCount' => $response['total_call_count'], - // 'totalCallBilledDuration' => $response['total_call_billed_duration'], - // 'totalSessionAmount' => $response['total_session_amount'], - // 'lastInteractionTime' => $response['last_interaction_time'] - // ]; - + parent::__construct($client); $this->properties = [ 'api_id' => $response['api_id'], 'response' => $response['response'] From a179a1751cb3b7764c9e859f6ecafa1020ed291d Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Tue, 12 Sep 2023 18:00:16 +0530 Subject: [PATCH 09/10] removed older php version --- .github/workflows/unitTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 69ca5a8c..7a8dc3c5 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php-version: [7.3, 7.4, 8.1] + php-version: [7.4, 8.1] steps: - uses: actions/checkout@v2 From 77918dd323a462b3d528af0663887a53987af471 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Tue, 12 Sep 2023 18:07:55 +0530 Subject: [PATCH 10/10] added sdk versioning --- CHANGELOG.md | 4 ++++ src/Plivo/Version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7775e77c..6f14ccf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Change Log +## [4.57.0](https://github.com/plivo/plivo-php/tree/v4.57.0) (2023-09-13) +**Feature - Number Masking** +- Added Create, Delete, Update, Get and List Masking Session API + ## [4.56.0](https://github.com/plivo/plivo-php/tree/v4.56.0) (2023-08-25) **Feature - Added New Param 'carrier_fees', 'carrier_fees_rate', 'destination_network' in Get Message and List Message APIs** - Added new params on message get and list response diff --git a/src/Plivo/Version.php b/src/Plivo/Version.php index 37d63815..57d4a19b 100644 --- a/src/Plivo/Version.php +++ b/src/Plivo/Version.php @@ -20,7 +20,7 @@ class Version /** * @const int PHP helper library minor version number */ - const MINOR = 56; + const MINOR = 57; /** * @const int PHP helper library patch number