diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index b4db2dd8..f31fb3b0 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -11,7 +11,7 @@ jobs: name: UnitTests strategy: matrix: - python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.11] + python-version: [ 3.5, 3.6, 3.7, 3.8, 3.9, 3.11] os: [macos-latest] runs-on: ${{ matrix.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cbea951..112e7276 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [4.38.0](https://github.com/plivo/plivo-python/tree/v4.38.0) (2022-07-31) +**Feature - Number Masking** +- Added Create, Delete, Update, Get and List Masking Session API + ## [4.37.0](https://github.com/plivo/plivo-python/tree/v4.37.0) (2022-06-38) **Feature - Streaming API and XML** - Added Stream API endpoints diff --git a/plivo/resources/calls.py b/plivo/resources/calls.py index 4f4a3c59..8a4f0cbe 100644 --- a/plivo/resources/calls.py +++ b/plivo/resources/calls.py @@ -200,7 +200,7 @@ def create(self, callback_method=None): if from_ in to_.split('<'): raise ValidationError('src and destination cannot overlap') - return self.client.request('POST', ('Call', ), to_param_dict(self.create, locals()), is_voice_request=True) + return self.client.request('POST', ('Call',), to_param_dict(self.create, locals()), is_voice_request=True) @validate_args( subaccount=[optional(is_subaccount())], @@ -262,14 +262,14 @@ def list(self, # Adding if else block because if we are fetching response without callback_url then response will be of type # ListResponseObject, if passing callback_url then will be of type # {'api_id': '94722e88-ae7c-11ec-b52e-0242ac11000a', 'message': 'async api spawned'} - if callback_url : + if callback_url: return self.client.request( 'GET', ('Call',), to_param_dict(self.list, locals()), is_voice_request=True ) - else : + else: return self.client.request( 'GET', ('Call',), @@ -369,7 +369,8 @@ def record_stop(self, call_uuid, callback_url=None, callback_method=None): callback_method=[optional(of_type(six.text_type))] ) def stop_recording(self, call_uuid, callback_url, callback_method): - return self.client.request('DELETE', ('Call', call_uuid, 'Record'), to_param_dict(self.stop_recording, locals()), is_voice_request=True) + return self.client.request('DELETE', ('Call', call_uuid, 'Record'), + to_param_dict(self.stop_recording, locals()), is_voice_request=True) @validate_args(call_uuid=[of_type(six.text_type)]) def play(self, @@ -404,7 +405,8 @@ def play_stop(self, call_uuid, callback_url=None, callback_method=None): callback_method=[optional(of_type(six.text_type))] ) def stop_playing(self, call_uuid, callback_url=None, callback_method=None): - return self.client.request('DELETE', ('Call', call_uuid, 'Play'), to_param_dict(self.stop_playing, locals()), is_voice_request=True) + return self.client.request('DELETE', ('Call', call_uuid, 'Play'), to_param_dict(self.stop_playing, locals()), + is_voice_request=True) @validate_args(call_uuid=[of_type(six.text_type)], callback_url=[optional(is_url())], @@ -442,7 +444,8 @@ def start_speaking(self, @validate_args(call_uuid=[of_type(six.text_type)]) def stop_speaking(self, call_uuid, callback_url=None, callback_method=None): - return self.client.request('DELETE', ('Call', call_uuid, 'Speak'), to_param_dict(self.stop_speaking, locals()), is_voice_request=True) + return self.client.request('DELETE', ('Call', call_uuid, 'Speak'), to_param_dict(self.stop_speaking, locals()), + is_voice_request=True) @validate_args( callback_url=[optional(is_url())], @@ -468,7 +471,8 @@ def delete(self, call_uuid, callback_url=None, callback_method=None): - return self.client.request('DELETE', ('Call', call_uuid), to_param_dict(self.delete, locals()), is_voice_request=True) + return self.client.request('DELETE', ('Call', call_uuid), to_param_dict(self.delete, locals()), + is_voice_request=True) @validate_args(call_uuid=[of_type(six.text_type)]) def hangup(self, call_uuid): @@ -542,3 +546,4 @@ def get_details_of_specific_stream(self, def get_all_streams(self, call_uuid): return self.client.request('GET', ('Call', call_uuid, 'Stream'), is_voice_request=True) + diff --git a/plivo/resources/maskingsession.py b/plivo/resources/maskingsession.py new file mode 100644 index 00000000..d4dd30f3 --- /dev/null +++ b/plivo/resources/maskingsession.py @@ -0,0 +1,110 @@ +from plivo.base import (ListResponseObject, PlivoResource, + PlivoResourceInterface) +from plivo.utils import to_param_dict +from plivo.utils.validators import * + +class MaskingSession(PlivoResource): + _name = 'MaskingSession' + _identifier_string = 'session_uuid' + def create_masking_session(self): + return self.client.calls.create_masking_session(self.id, + **to_param_dict(self.create_masking_session(), locals())) + + def delete_masking_session(self): + return self.client.calls.delete_masking_session(self.id, + **to_param_dict(self.delete_masking_session(), locals())) + + def get_masking_session(self): + return self.client.calls.get_masking_session(self.id, + **to_param_dict(self.get_masking_session(), locals())) + + def update_masking_session(self): + return self.client.calls.update_masking_session(self.id, + **to_param_dict(self.update_masking_session(), locals())) + + def list_masking_session(self): + return self.client.calls.list_masking_session(self.id, + **to_param_dict(self.list_masking_session(), locals())) + + +class MaskingSessions(PlivoResourceInterface): + _resource_type = MaskingSession + + @validate_args( + callback_url=[optional(is_url())], + recording_callback_url=[optional(is_url())], + first_party_play_url=[optional(is_url())], + second_party_play_url=[optional(is_url())], + ) + def create_masking_session(self, + first_party=None, + second_party=None, + session_expiry=None, + call_time_limit=None, + record=None, + record_file_format=None, + recording_callback_url=None, + initiate_call_to_first_party=None, + callback_url=None, + callback_method=None, + ring_timeout=None, + first_party_play_url=None, + second_party_play_url=None, + recording_callback_method=None + ): + return self.client.request('POST', ('Masking', 'Session',), + to_param_dict(self.create_masking_session, locals()), is_voice_request=True) + + def delete_masking_session(self, + session_uuid + ): + return self.client.request('DELETE', ('Masking', 'Session', session_uuid), + to_param_dict(self.delete_masking_session, locals()), is_voice_request=True) + + def get_masking_session(self, + session_uuid + ): + return self.client.request('GET', ('Masking', 'Session', session_uuid), is_voice_request=True) + + def update_masking_session(self, + session_uuid, + session_expiry=None, + call_time_limit=None, + record=None, + record_file_format=None, + recording_callback_url=None, + callback_url=None, + callback_method=None, + ring_timeout=None, + first_party_play_url=None, + second_party_play_url=None, + recording_callback_method=None + ): + return self.client.request('POST', ('Masking', 'Session', session_uuid), + to_param_dict(self.update_masking_session, locals()), is_voice_request=True) + + def list_masking_session(self, + first_party=None, + second_party=None, + virtual_number=None, + status=None, + created_time=None, + created_time__lt=None, + created_time__lte=None, + created_time__gt=None, + created_time__gte=None, + expiry_time=None, + expiry_time__lt=None, + expiry_time__lte=None, + expiry_time__gt=None, + expiry_time__gte=None, + duration=None, + duration__lt=None, + duration__lte=None, + duration__gt=None, + duration__gte=None, + limit=None, + offset=None + ): + return self.client.request('GET', ('Masking', 'Session'), to_param_dict(self.list_masking_session, locals()), + is_voice_request=True) diff --git a/plivo/rest/client.py b/plivo/rest/client.py index 1568d1f5..6f45cba1 100644 --- a/plivo/rest/client.py +++ b/plivo/rest/client.py @@ -16,6 +16,7 @@ Messages, Powerpacks, Media, Lookup, Brand, Campaign, Profile, Numbers, Pricings, Recordings, Subaccounts, CallFeedback, MultiPartyCalls) from plivo.resources.live_calls import LiveCalls +from plivo.resources.maskingsession import MaskingSessions from plivo.resources.profile import Profile from plivo.resources.queued_calls import QueuedCalls from plivo.resources.regulatory_compliance import EndUsers, ComplianceDocumentTypes, ComplianceDocuments, \ @@ -115,6 +116,7 @@ def __init__(self, auth_id=None, auth_token=None, proxies=None, timeout=5): self.compliance_requirements = ComplianceRequirements(self) self.compliance_applications = ComplianceApplications(self) self.multi_party_calls = MultiPartyCalls(self) + self.masking_sessions = MaskingSessions(self) self.voice_retry_count = 0 def __enter__(self): diff --git a/plivo/version.py b/plivo/version.py index 05640551..781090fd 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__version__ = '4.37.0' +__version__ = '4.38.0' diff --git a/setup.py b/setup.py index 6024b1fd..e05026b0 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='plivo', - version='4.37.0', + version='4.38.0', description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML', long_description=long_description, url='https://github.com/plivo/plivo-python', diff --git a/tests/resources/fixtures/maskingSessionCreateResponse.json b/tests/resources/fixtures/maskingSessionCreateResponse.json new file mode 100644 index 00000000..e979604c --- /dev/null +++ b/tests/resources/fixtures/maskingSessionCreateResponse.json @@ -0,0 +1,35 @@ +{ + "api_id": "7fef62d3-a451-40ef-95e7-b4ad9969aa1e", + "session_uuid": "bc0a20bb-9f09-4116-b3f8-709def3a89df", + "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": "bc0a20bb-9f09-4116-b3f8-709def3a89df", + "callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1", + "callback_method": "GET", + "created_time": "2023-07-12 15:52:14.772699 +0000 UTC", + "modified_time": "2023-07-12 15:52:14.772699 +0000 UTC", + "expiry_time": "2023-07-12 17:32:14.772699 +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/resources/fixtures/maskingSessionDeleteResponse.json b/tests/resources/fixtures/maskingSessionDeleteResponse.json new file mode 100644 index 00000000..92f39736 --- /dev/null +++ b/tests/resources/fixtures/maskingSessionDeleteResponse.json @@ -0,0 +1,4 @@ +{ + "api_id": "f91f459a-283d-4850-9b33-ad914dcb64c0", + "message": "Session Deleted" +} \ No newline at end of file diff --git a/tests/resources/fixtures/maskingSessionGetResponse.json b/tests/resources/fixtures/maskingSessionGetResponse.json new file mode 100644 index 00000000..424985e6 --- /dev/null +++ b/tests/resources/fixtures/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": "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 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/resources/fixtures/maskingSessionListResponse.json b/tests/resources/fixtures/maskingSessionListResponse.json new file mode 100644 index 00000000..55714bc5 --- /dev/null +++ b/tests/resources/fixtures/maskingSessionListResponse.json @@ -0,0 +1,224 @@ +{ + "api_id": "2900eb2b-0d47-4464-8eff-bbd413e15bf9", + "response": { + "meta": { + "limit": 20, + "next": null, + "offset": 0, + "previous": null, + "total_count": 7 + }, + "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": 600, + "callback_method": "GET", + "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "created_time": "2023-07-04 10:29:02.410778 +0000 UTC", + "duration": 2571, + "expiry_time": "2023-07-04 11:11:53.486694 +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-04 11:01:53.486696 +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/61130623-ac98-4d70-8961-3b3110700e0a/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "61130623-ac98-4d70-8961-3b3110700e0a", + "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": 600, + "callback_method": "GET", + "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "created_time": "2023-07-04 07:29:27.14973 +0000 UTC", + "duration": 926, + "expiry_time": "2023-07-04 07:36:50.056529 +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-04 13:06:50.284062 +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/4b083bef-7b26-4116-95a4-c35f81f5c2c1/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "4b083bef-7b26-4116-95a4-c35f81f5c2c1", + "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": 600, + "callback_method": "GET", + "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "created_time": "2023-07-04 06:41:19.396345 +0000 UTC", + "duration": 1244, + "expiry_time": "2023-07-04 07:02:03.635064 +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-04 06:52:03.635068 +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/24d9691b-3904-488f-9ad8-f5afa6121606/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "24d9691b-3904-488f-9ad8-f5afa6121606", + "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-07-03 09:46:07.91423 +0000 UTC", + "duration": 8702, + "expiry_time": "2023-07-03 12:11:09.939161 +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-03 16:01:10.202999 +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/964c20e0-9d59-40d5-90c3-7006ef5d03f4/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "964c20e0-9d59-40d5-90c3-7006ef5d03f4", + "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": 600, + "callback_method": "GET", + "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "created_time": "2023-06-30 06:51:11.021617 +0000 UTC", + "duration": 6702, + "expiry_time": "2023-06-30 08:42:53.503857 +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 08:32:53.503891 +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/c4ea0e4c-b3e7-47c3-a31c-79227ac6939c/", + "ring_timeout": 120, + "second_party": "919976106830", + "second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "session_uuid": "c4ea0e4c-b3e7-47c3-a31c-79227ac6939c", + "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/resources/fixtures/maskingSessionUpdateResponse.json b/tests/resources/fixtures/maskingSessionUpdateResponse.json new file mode 100644 index 00000000..354dfdaa --- /dev/null +++ b/tests/resources/fixtures/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": 14600, + "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/test_calls.py b/tests/resources/test_calls.py index 8b4d29ab..043afbf9 100644 --- a/tests/resources/test_calls.py +++ b/tests/resources/test_calls.py @@ -142,4 +142,4 @@ def test_stream_delete_all(self): self.assertEqual(self.client.current_request.method, 'DELETE') self.assertUrlEqual( self.get_voice_url('Call', uuid, 'Stream'), - self.client.current_request.url) + self.client.current_request.url) \ No newline at end of file diff --git a/tests/resources/test_maskingsessions.py b/tests/resources/test_maskingsessions.py new file mode 100644 index 00000000..cf657e23 --- /dev/null +++ b/tests/resources/test_maskingsessions.py @@ -0,0 +1,50 @@ +from tests.base import PlivoResourceTestCase +from tests.decorators import with_response + +class MaskingSessionTest(PlivoResourceTestCase): + @with_response(201) + def test_create(self): + self.client.masking_sessions.create_masking_session( + first_party='917708772011', + second_party='918220568648') + self.assertEqual(self.client.current_request.method, 'POST') + self.assertUrlEqual( + self.get_voice_url('Masking', 'Session'), self.client.current_request.url) + + @with_response(200) + def test_delete(self): + session_uuid = "9fe6cba9-62b2-4de0-98a4-6b878fb906de" + self.client.masking_sessions.delete_masking_session( + session_uuid) + self.assertEqual(self.client.current_request.method, 'DELETE') + self.assertUrlEqual( + self.get_voice_url('Masking', 'Session', session_uuid), self.client.current_request.url) + + @with_response(200) + def test_get(self): + session_uuid = "c2146ba4-798d-49b0-8580-53851a16e055" + self.client.masking_sessions.get_masking_session(session_uuid) + self.assertEqual(self.client.current_request.method, 'GET') + self.assertUrlEqual( + self.get_voice_url('Masking', 'Session', session_uuid), self.client.current_request.url) + + @with_response(200) + def test_update(self): + session_uuid = "7b5c5e17-e1e9-4ccd-a480-42f5c97fbe96" + self.client.masking_sessions.update_masking_session( + session_uuid=session_uuid, + call_time_limit=14600, + record=True) + self.assertEqual(self.client.current_request.method, 'POST') + self.assertUrlEqual( + self.get_voice_url('Masking', 'Session', session_uuid), self.client.current_request.url) + + @with_response(200) + def test_list(self): + self.client.masking_sessions.list_masking_session( + duration__gte=50, + status="expired") + self.assertEqual(self.client.current_request.method, 'GET') + self.assertUrlEqual( + self.get_voice_url('Masking', 'Session', duration__gte=50, + status="expired"), self.client.current_request.url) \ No newline at end of file