From e323afd2738e22fa69cd6df2e37acc70de0f9a5a Mon Sep 17 00:00:00 2001 From: ajay-plivo Date: Mon, 11 Apr 2022 15:09:02 +0530 Subject: [PATCH 1/8] VT-4174 --- CHANGELOG.md | 4 ++++ plivo/resources/recordings.py | 9 +++++++-- plivo/version.py | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a89018..87458cc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [4.23.1](https://github.com/plivo/plivo-python/tree/v4.23.1) (2022-04-11) +**Feature - List all recordings** +- `from_number` and `to_number` added to filtering param [List all recordings](https://www.plivo.com/docs/voice/api/recording#list-all-recordings) + ## [4.23.0](https://github.com/plivo/plivo-python/tree/v4.23.0) (2022-03-18) **Feature - DialElement** - `confirmTimeout` parameter added to [The Dial element](https://www.plivo.com/docs/voice/xml/dial/) diff --git a/plivo/resources/recordings.py b/plivo/resources/recordings.py index 48e43edf..622314b9 100644 --- a/plivo/resources/recordings.py +++ b/plivo/resources/recordings.py @@ -22,6 +22,8 @@ class Recordings(PlivoResourceInterface): _resource_type = Recording @validate_args( + from_number=[optional(of_type(six.text_type))], + to_number=[optional(of_type(six.text_type))], subaccount=[optional(is_subaccount())], call_uuid=[optional(of_type(six.text_type))], limit=[ @@ -35,7 +37,8 @@ class Recordings(PlivoResourceInterface): all_of( of_type(*six.integer_types), check(lambda offset: 0 <= offset, '0 <= offset'))) - ]) + ], + ) def list(self, subaccount=None, call_uuid=None, @@ -45,7 +48,9 @@ def list(self, add_time__lte=None, add_time=None, limit=20, - offset=0): + offset=0, + from_number=None, + to_number=None): if subaccount: if isinstance(subaccount, Subaccount): diff --git a/plivo/version.py b/plivo/version.py index 63381b81..042040fd 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -__version__ = '4.23.0' +__version__ = '4.23.1' From 1eaed3556510fc86c4516a8d548c3f93746516cc Mon Sep 17 00:00:00 2001 From: ajay-plivo Date: Tue, 19 Apr 2022 09:58:44 +0530 Subject: [PATCH 2/8] VT-4174 --- .../recordingGetAddedFilterResponse.json | 15 +++++ .../recordingListFromFilterResponse.json | 57 +++++++++++++++++++ tests/resources/test_recordings.py | 42 ++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 tests/resources/fixtures/recordingGetAddedFilterResponse.json create mode 100644 tests/resources/fixtures/recordingListFromFilterResponse.json diff --git a/tests/resources/fixtures/recordingGetAddedFilterResponse.json b/tests/resources/fixtures/recordingGetAddedFilterResponse.json new file mode 100644 index 00000000..cb9e4926 --- /dev/null +++ b/tests/resources/fixtures/recordingGetAddedFilterResponse.json @@ -0,0 +1,15 @@ +{ + "add_time":"2022-04-12 16:08:53.523657+05:30", + "call_uuid":"f72eea2a-446b-4412-a17f-3b17083bd25a", + "conference_name":"", + "from_number":"+919768368717", + "recording_duration_ms":"7560.00000", + "recording_end_ms":"1649759930398.00000", + "recording_format":"mp3", + "recording_id":"d405c4eb-d562-4399-af32-6ff3c57fa55x", + "recording_start_ms":"1649759922838.00000", + "recording_type":"call", + "recording_url":"https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559.mp3", + "resource_uri":"/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559/", + "to_number":"sip:ajay6121801985815245533110@phone.plivo.com" +} \ No newline at end of file diff --git a/tests/resources/fixtures/recordingListFromFilterResponse.json b/tests/resources/fixtures/recordingListFromFilterResponse.json new file mode 100644 index 00000000..0eba469d --- /dev/null +++ b/tests/resources/fixtures/recordingListFromFilterResponse.json @@ -0,0 +1,57 @@ +{ + "api_id": "041a2d92-bf96-11ec-8d3a-0242ac110002", + "meta": { + "limit": 20, + "next": null, + "offset": 0, + "previous": null, + "total_count": 2 + }, + "objects": [ + { + "add_time": "2022-04-12 16:08:53.523657+05:30", + "call_uuid": "f72eea2a-446b-4412-a17f-3b17083bd25a", + "conference_name": "", + "from_number": "+919768368717", + "recording_duration_ms": "7560.00000", + "recording_end_ms": "1649759930398.00000", + "recording_format": "mp3", + "recording_id": "d405c4eb-d562-4399-af32-6ff3c57fa559", + "recording_start_ms": "1649759922838.00000", + "recording_type": "call", + "recording_url": "https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559.mp3", + "resource_uri": "/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/d405c4eb-d562-4399-af32-6ff3c57fa559/", + "to_number": "sip:ajay6121801985815245533110@phone.plivo.com" + }, + { + "add_time": "2022-04-12 13:49:19.579419+05:30", + "call_uuid": "b5e575b4-721c-425d-8da5-6c5cf6494487", + "conference_name": "", + "from_number": "+919768368712", + "recording_duration_ms": "25020.00000", + "recording_end_ms": "1649751556401.00000", + "recording_format": "mp3", + "recording_id": "7ed2395e-e08a-4448-86b1-9770331d94f3", + "recording_start_ms": "1649751531381.00000", + "recording_type": "call", + "recording_url": "https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3.mp3", + "resource_uri": "/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3/", + "to_number": "sip:ajay6121801985815245533110@phone.plivo.com" + }, + { + "add_time": "2022-04-12 13:49:19.579419+05:30", + "call_uuid": "b5e575b4-721c-425d-8da5-6c5cf6494487", + "conference_name": "", + "from_number": "+919768368711", + "recording_duration_ms": "25020.00000", + "recording_end_ms": "1649751556401.00000", + "recording_format": "mp3", + "recording_id": "7ed2395e-e08a-4448-86b1-9770331d94f3", + "recording_start_ms": "1649751531381.00000", + "recording_type": "call", + "recording_url": "https://media.plivo.com/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3.mp3", + "resource_uri": "/v1/Account/MAZTCXYJFKZJK3N2Q3YT/Recording/7ed2395e-e08a-4448-86b1-9770331d94f3/", + "to_number": "sip:ajay6121801985815245533110@phone.plivo.com" + } + ] +} \ No newline at end of file diff --git a/tests/resources/test_recordings.py b/tests/resources/test_recordings.py index ec4711f7..617501d6 100644 --- a/tests/resources/test_recordings.py +++ b/tests/resources/test_recordings.py @@ -148,3 +148,45 @@ def test_delete(self): # Verifying the method used self.assertEqual('DELETE', self.client.current_request.method) + + @with_response(200) + def test_get_added_filter(self): + recording = self.client.recordings.get( + 'd405c4eb-d562-4399-af32-6ff3c57fa55x') + + self.assertResponseMatches(recording) + + # Verifying the endpoint hit + self.assertEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Recording/d405c4eb-d562-4399-af32-6ff3c57fa55x/', + self.client.current_request.url) + + # Verifying the method used + self.assertEqual('GET', self.client.current_request.method) + + # Verifying the object type returned + self.assertEqual(plivo.resources.recordings.Recording, + recording.__class__) + # verify to and from no param + self.assertEqual('+919768368717', recording.from_number) + + self.assertEqual('sip:ajay6121801985815245533110@phone.plivo.com', recording.to_number) + + @with_response(200) + def test_list_from_filter(self): + recordings = self.client.recordings.list( + call_uuid="f72eea2a-446b-4412-a17f-3b17083bd25a", + from_number="919768368717" + ) + + # Verifying the endpoint hit + self.assertUrlEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Recording/?call_uuid=f72eea2a-446b-4412-a17f-3b17083bd25a&from_number=919768368717&limit=20&offset=0', + self.client.current_request.url) + + # Verifying if the Account specific changes and parsing happened + self.assertEqual('7ed2395e-e08a-4448-86b1-9770331d94f3', + recordings.objects[1].id) + + self.assertEqual('+919768368717', + recordings.objects[0].from_number) \ No newline at end of file From 4e32d7dd599d539261d4b12356a6b8a2245ed755 Mon Sep 17 00:00:00 2001 From: ajay-plivo Date: Tue, 19 Apr 2022 17:31:01 +0530 Subject: [PATCH 3/8] VT-4174 --- CHANGELOG.md | 3 ++- plivo/resources/multipartycall.py | 6 ++++++ plivo/xml/MultiPartyCallElement.py | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87458cc5..0738e37f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # Change Log ## [4.23.1](https://github.com/plivo/plivo-python/tree/v4.23.1) (2022-04-11) -**Feature - List all recordings** +**Feature - List all recordings and The MultiPartyCall element** - `from_number` and `to_number` added to filtering param [List all recordings](https://www.plivo.com/docs/voice/api/recording#list-all-recordings) +- `record_min_member_count` param added to [Add a participant to a multiparty call using API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) ## [4.23.0](https://github.com/plivo/plivo-python/tree/v4.23.0) (2022-03-18) **Feature - DialElement** diff --git a/plivo/resources/multipartycall.py b/plivo/resources/multipartycall.py index 4bf93634..fe46d3b8 100644 --- a/plivo/resources/multipartycall.py +++ b/plivo/resources/multipartycall.py @@ -29,6 +29,7 @@ def add_participant(self, delay_dial=0, max_duration=14400, max_participants=10, + record_min_member_count=1, wait_music_url=None, wait_music_method='GET', agent_hold_music_url=None, @@ -250,6 +251,10 @@ def get(self, uuid=None, friendly_name=None): of_type_exact(int), check(lambda max_participants: 2 <= max_participants <= 10, '2 < max_participants <= 10') )], + record_min_member_count=[optional( + of_type_exact(int), + check(lambda record_min_member_count: 1 <= record_min_member_count <= 2, '1 < record_min_member_count <= 2') + )], wait_music_url=[optional(of_type_exact(str), is_url())], wait_music_method=[optional(of_type_exact(str), is_in(('GET', 'POST'), case_sensitive=False))], agent_hold_music_url=[optional(of_type_exact(str), is_url())], @@ -313,6 +318,7 @@ def add_participant(self, delay_dial=0, max_duration=14400, max_participants=10, + record_min_member_count=1, wait_music_url=None, wait_music_method='GET', agent_hold_music_url=None, diff --git a/plivo/xml/MultiPartyCallElement.py b/plivo/xml/MultiPartyCallElement.py index c445ea25..395e311b 100644 --- a/plivo/xml/MultiPartyCallElement.py +++ b/plivo/xml/MultiPartyCallElement.py @@ -45,6 +45,26 @@ def set_max_participants(self, max_participants): self.max_participants = max_participants return self + @property + def record_min_member_count(self): + return self.__record_min_member_count + + @record_min_member_count.setter + @validate_args( + record_min_member_count=[ + optional( + of_type_exact(int), + check(lambda record_min_member_count: 1 <= record_min_member_count <= 2, '1 <= record_min_member_count <= 2') + ) + ], + ) + def record_min_member_count(self, record_min_member_count): + self.__record_min_member_count = record_min_member_count + + def set_record_min_member_count(self, record_min_member_count): + self.record_min_member_count = record_min_member_count + return self + @property def wait_music_url(self): return self.__wait_music_url @@ -507,6 +527,7 @@ def __init__( role, max_duration=14400, max_participants=10, + record_min_member_count=1, wait_music_url=None, wait_music_method='GET', agent_hold_music_url=None, @@ -547,6 +568,7 @@ def __init__( self.role = role self.max_duration = max_duration self.max_participants = max_participants + self.record_min_member_count = record_min_member_count self.wait_music_url = wait_music_url self.wait_music_method = wait_music_method self.agent_hold_music_url = agent_hold_music_url @@ -579,6 +601,7 @@ def to_dict(self): 'role': self.role, 'maxDuration': self.max_duration, 'maxParticipants': self.max_participants, + 'recordMinMemberCount': self.record_min_member_count, 'waitMusicUrl': self.wait_music_url, 'waitMusicMethod': self.wait_music_method, 'agentHoldMusicUrl': self.agent_hold_music_url, From 5e030cb35e523abc7c6ba48cb9d0aa691273c342 Mon Sep 17 00:00:00 2001 From: ajay-plivo Date: Wed, 20 Apr 2022 09:50:00 +0530 Subject: [PATCH 4/8] VT-4174:utFixed --- tests/resources/test_multipartycalls.py | 1 + tests/xml/test_MultiPartyCallElement.py | 8 +++++--- tests/xml/test_responseElement.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/resources/test_multipartycalls.py b/tests/resources/test_multipartycalls.py index 9407c6d2..ad2cb9d6 100644 --- a/tests/resources/test_multipartycalls.py +++ b/tests/resources/test_multipartycalls.py @@ -170,6 +170,7 @@ def test_add_participant(self): 'status_callback_events': 'mpc-state-changes,participant-state-changes', 'record_file_format': 'mp3', 'record': False, + 'record_min_member_count': 1, 'on_exit_action_method': 'POST', 'status_callback_method': 'GET', 'recording_callback_method': 'GET', diff --git a/tests/xml/test_MultiPartyCallElement.py b/tests/xml/test_MultiPartyCallElement.py index 6ea73d12..7adf5754 100644 --- a/tests/xml/test_MultiPartyCallElement.py +++ b/tests/xml/test_MultiPartyCallElement.py @@ -12,7 +12,8 @@ def test_default_xml(self): 'customerHoldMusicMethod="GET" endMpcOnExit="false" enterSound="beep:1" ' \ 'enterSoundMethod="GET" exitSound="beep:2" exitSoundMethod="GET" hold="false" ' \ 'maxDuration="14400" maxParticipants="10" mute="false" onExitActionMethod="POST" ' \ - 'record="false" recordFileFormat="mp3" recordingCallbackMethod="POST" ' \ + 'record="false" recordFileFormat="mp3" recordMinMemberCount="1" ' \ + 'recordingCallbackMethod="POST" ' \ 'relayDTMFInputs="false" role="agent" startMpcOnEnter="true" ' \ 'startRecordingAudioMethod="GET" ' \ 'statusCallbackEvents="mpc-state-changes,participant-state-changes" ' \ @@ -28,7 +29,8 @@ def test_setting_optional_fields(self): 'customerHoldMusicMethod="GET" endMpcOnExit="false" enterSound="beep:1" ' \ 'enterSoundMethod="GET" exitSound="beep:1" exitSoundMethod="GET" hold="false" ' \ 'maxDuration="14400" maxParticipants="10" mute="false" onExitActionMethod="POST" ' \ - 'record="false" recordFileFormat="mp3" recordingCallbackMethod="POST" ' \ + 'record="false" recordFileFormat="mp3" recordMinMemberCount="1" ' \ + 'recordingCallbackMethod="POST" ' \ 'relayDTMFInputs="false" role="supervisor" startMpcOnEnter="true" ' \ 'startRecordingAudioMethod="GET" ' \ 'statusCallbackEvents="mpc-state-changes,participant-state-changes" ' \ @@ -76,7 +78,7 @@ def test_builder_setting(self): 'statusCallbackEvents="mpc-state-changes,participant-state-changes" ' \ 'statusCallbackMethod="POST" stayAlone="false" stopRecordingAudio="http://plivo.com/api.mp3" ' \ 'stopRecordingAudioMethod="GET" ' \ - 'waitMusicMethod="GET">Helsinki ' + 'waitMusicMethod="GET" recordMinMemberCount="1">Helsinki ' element = plivoxml.MultiPartyCallElement(content='Helsinki', role='customer'). \ set_max_duration(4500).set_max_participants(9).set_end_mpc_on_exit(True). \ set_customer_hold_music_url('http://plivo.com/voice.mp3').set_coach_mode(False). \ diff --git a/tests/xml/test_responseElement.py b/tests/xml/test_responseElement.py index 637e059c..45f5ebe6 100644 --- a/tests/xml/test_responseElement.py +++ b/tests/xml/test_responseElement.py @@ -110,7 +110,8 @@ def test_add_mpc(self): 'enterSoundMethod="GET" exitSound="beep:1" exitSoundMethod="GET" hold="true" ' \ 'maxDuration="20000" maxParticipants="7" mute="true" onExitActionMethod="POST" ' \ 'onExitActionUrl="https://plivo.com/exitAction" record="true" recordFileFormat="wav" ' \ - 'recordingCallbackMethod="GET" relayDTMFInputs="false" role="customer" ' \ + 'recordMinMemberCount="1" recordingCallbackMethod="GET" ' \ + 'relayDTMFInputs="false" role="customer" ' \ 'startMpcOnEnter="true" '\ 'startRecordingAudio="https://plivo.com/plivoTone.mp3" ' \ 'startRecordingAudioMethod="GET" ' \ From 56d64cf64659fa9937b3c8ce0d50adeeb48388ab Mon Sep 17 00:00:00 2001 From: ajay-plivo Date: Mon, 25 Apr 2022 11:11:19 +0530 Subject: [PATCH 5/8] VT-4174 --- plivo/resources/recordings.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plivo/resources/recordings.py b/plivo/resources/recordings.py index 622314b9..d414fbdc 100644 --- a/plivo/resources/recordings.py +++ b/plivo/resources/recordings.py @@ -24,6 +24,10 @@ class Recordings(PlivoResourceInterface): @validate_args( from_number=[optional(of_type(six.text_type))], to_number=[optional(of_type(six.text_type))], + conference_name=[optional(of_type(six.text_type))], + mpc_name=[optional(of_type(six.text_type))], + conference_uuid=[optional(of_type(six.text_type))], + mpc_uuid=[optional(of_type(six.text_type))], subaccount=[optional(is_subaccount())], call_uuid=[optional(of_type(six.text_type))], limit=[ @@ -50,7 +54,11 @@ def list(self, limit=20, offset=0, from_number=None, - to_number=None): + to_number=None, + conference_name=None, + mpc_name=None, + conference_uuid=None, + mpc_uuid=None): if subaccount: if isinstance(subaccount, Subaccount): From 93c5308613fe705500bdd9d8043e451854257da6 Mon Sep 17 00:00:00 2001 From: ajay-plivo Date: Thu, 28 Apr 2022 09:42:50 +0530 Subject: [PATCH 6/8] VT-4174 --- CHANGELOG.md | 2 +- plivo/version.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0738e37f..acfb826c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.23.1](https://github.com/plivo/plivo-python/tree/v4.23.1) (2022-04-11) +## [4.24.0](https://github.com/plivo/plivo-python/tree/v4.24.0) (2022-04-11) **Feature - List all recordings and The MultiPartyCall element** - `from_number` and `to_number` added to filtering param [List all recordings](https://www.plivo.com/docs/voice/api/recording#list-all-recordings) - `record_min_member_count` param added to [Add a participant to a multiparty call using API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) diff --git a/plivo/version.py b/plivo/version.py index 042040fd..7b0b3668 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -__version__ = '4.23.1' +__version__ = '4.24.0' diff --git a/setup.py b/setup.py index b7d67f2c..635199a7 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='plivo', - version='4.23.0', + version='4.24.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', From 095f532f6cf71b50179c4efad095aeecb843bc76 Mon Sep 17 00:00:00 2001 From: manjunath-plivo <85923934+manjunath-plivo@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:21:04 +0530 Subject: [PATCH 7/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acfb826c..416b0f71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.24.0](https://github.com/plivo/plivo-python/tree/v4.24.0) (2022-04-11) +## [4.24.0](https://github.com/plivo/plivo-python/tree/v4.24.0) (2022-04-28) **Feature - List all recordings and The MultiPartyCall element** - `from_number` and `to_number` added to filtering param [List all recordings](https://www.plivo.com/docs/voice/api/recording#list-all-recordings) - `record_min_member_count` param added to [Add a participant to a multiparty call using API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) From 79b8e921176dae00cdbb16be0e21fea40b737b8b Mon Sep 17 00:00:00 2001 From: manjunath-plivo <85923934+manjunath-plivo@users.noreply.github.com> Date: Thu, 5 May 2022 17:35:03 +0530 Subject: [PATCH 8/8] VT-4174 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 416b0f71..3f7b278c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.24.0](https://github.com/plivo/plivo-python/tree/v4.24.0) (2022-04-28) +## [4.24.0](https://github.com/plivo/plivo-python/tree/v4.24.0) (2022-05-05) **Feature - List all recordings and The MultiPartyCall element** - `from_number` and `to_number` added to filtering param [List all recordings](https://www.plivo.com/docs/voice/api/recording#list-all-recordings) - `record_min_member_count` param added to [Add a participant to a multiparty call using API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant)