diff --git a/CHANGELOG.md b/CHANGELOG.md index c1678126..724f2b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log -## [4.57.0](https://github.com/plivo/plivo-go/tree/v4.57.0) (2024-11-15) +## [4.58.0](https://github.com/plivo/plivo-python/tree/v4.58.0) (2024-11-19) +**Feature - Transcription params added in MPC XML Element** +- Support for the `transcriptionUrl`, `transcript` parameter in MPC XML Element. + +## [4.57.0](https://github.com/plivo/plivo-python/tree/v4.57.0) (2024-11-15) **Feature - CreateRecordingTranscription, GetRecordingTranscription and DeleteRecordingTranscription feature added** - Support added to create transcription for recorded calls for which transcription is not available and get API to retrieve and delete API to delete. - Support for the `type` filter parameter, supported filters are transcription, raw and diarized diff --git a/plivo/version.py b/plivo/version.py index dbc23571..ca614615 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__version__ = '4.57.0' +__version__ = '4.58.0' diff --git a/plivo/xml/MultiPartyCallElement.py b/plivo/xml/MultiPartyCallElement.py index d2cd27d1..8a01276f 100644 --- a/plivo/xml/MultiPartyCallElement.py +++ b/plivo/xml/MultiPartyCallElement.py @@ -554,6 +554,32 @@ def set_relay_dtmf_inputs(self, relay_dtmf_inputs): self.relay_dtmf_inputs = relay_dtmf_inputs return self + @property + def transcript(self): + return self.__transcript + + @transcript.setter + @validate_args(transcript=[optional(of_type_exact(bool))]) + def transcript(self, transcript): + self.__transcript = transcript + + def set_transcript(self, transcript): + self.transcript = transcript + return self + + @property + def transcription_url(self): + return self.__transcription_url + + @transcription_url.setter + @validate_args(transcription_url=[optional(of_type_exact(str), is_url())]) + def transcription_url(self, transcription_url): + self.__transcription_url = transcription_url + + def set_transcription_url(self, transcription_url): + self.transcription_url = transcription_url + return self + def __init__( self, content, @@ -592,7 +618,9 @@ def __init__( start_recording_audio=None, start_recording_audio_method='GET', stop_recording_audio=None, - stop_recording_audio_method='GET' + stop_recording_audio_method='GET', + transcript=False, + transcription_url=None ): super(MultiPartyCallElement, self).__init__() self.stop_recording_audio_method = stop_recording_audio_method @@ -632,6 +660,9 @@ def __init__( self.on_exit_action_url = on_exit_action_url self.on_exit_action_method = on_exit_action_method self.relay_dtmf_inputs = relay_dtmf_inputs + self.transcript = transcript + self.transcription_url = transcription_url + def to_dict(self): d = { @@ -670,7 +701,9 @@ def to_dict(self): 'startRecordingAudio': self.start_recording_audio, 'startRecordingAudioMethod': self.start_recording_audio_method, 'stopRecordingAudio': self.stop_recording_audio, - 'stopRecordingAudioMethod': self.stop_recording_audio_method + 'stopRecordingAudioMethod': self.stop_recording_audio_method, + 'transcript': self.transcript, + 'transcriptionUrl': self.transcription_url } return { k: six.text_type(map_type(v)) diff --git a/plivo/xml/ResponseElement.py b/plivo/xml/ResponseElement.py index a6679219..6860b8a7 100644 --- a/plivo/xml/ResponseElement.py +++ b/plivo/xml/ResponseElement.py @@ -361,8 +361,9 @@ def add_multi_party_call(self, start_recording_audio=None, start_recording_audio_method='GET', stop_recording_audio=None, - stop_recording_audio_method='GET' - + stop_recording_audio_method='GET', + transcript=False, + transcription_url=None ): self.add( MultiPartyCallElement( @@ -400,7 +401,9 @@ def add_multi_party_call(self, start_recording_audio=start_recording_audio, start_recording_audio_method=start_recording_audio_method, stop_recording_audio=stop_recording_audio, - stop_recording_audio_method=stop_recording_audio_method + stop_recording_audio_method=stop_recording_audio_method, + transcript=transcript, + transcription_url=transcription_url ) ) return self diff --git a/setup.py b/setup.py index 1a9a12b0..4c89acad 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='plivo', - version='4.57.0', + version='4.58.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 index a9ea9fd8..47576ae3 100644 --- a/tests/resources/fixtures/maskingSessionCreateResponse.json +++ b/tests/resources/fixtures/maskingSessionCreateResponse.json @@ -10,7 +10,7 @@ "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_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "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", @@ -20,10 +20,10 @@ "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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "record": false, "record_file_format": "mp3", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "recording_callback_method": "GET", "interaction": null, "total_call_amount": 0, diff --git a/tests/resources/fixtures/maskingSessionGetResponse.json b/tests/resources/fixtures/maskingSessionGetResponse.json index 424985e6..2e6976d3 100644 --- a/tests/resources/fixtures/maskingSessionGetResponse.json +++ b/tests/resources/fixtures/maskingSessionGetResponse.json @@ -7,7 +7,7 @@ "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_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "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", @@ -17,10 +17,10 @@ "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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "record": false, "record_file_format": "mp3", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "recording_callback_method": "GET", "interaction": null, "total_call_amount": 0, diff --git a/tests/resources/fixtures/maskingSessionListResponse.json b/tests/resources/fixtures/maskingSessionListResponse.json index 55714bc5..c18caf15 100644 --- a/tests/resources/fixtures/maskingSessionListResponse.json +++ b/tests/resources/fixtures/maskingSessionListResponse.json @@ -13,7 +13,7 @@ "amount": 0, "call_time_limit": 600, "callback_method": "GET", - "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "created_time": "2023-07-05 10:25:40.877364 +0000 UTC", "duration": 2863, "expiry_time": "2023-07-05 11:13:23.895313 +0000 UTC", @@ -26,11 +26,11 @@ "record": true, "record_file_format": "mp3", "recording_callback_method": "GET", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "session_uuid": "c2146ba4-798d-49b0-8580-53851a16e055", "status": "expired", "total_call_amount": 0, @@ -43,7 +43,7 @@ "amount": 0, "call_time_limit": 600, "callback_method": "GET", - "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "created_time": "2023-07-04 10:29:02.410778 +0000 UTC", "duration": 2571, "expiry_time": "2023-07-04 11:11:53.486694 +0000 UTC", @@ -56,11 +56,11 @@ "record": true, "record_file_format": "mp3", "recording_callback_method": "GET", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "session_uuid": "61130623-ac98-4d70-8961-3b3110700e0a", "status": "expired", "total_call_amount": 0, @@ -73,7 +73,7 @@ "amount": 0, "call_time_limit": 600, "callback_method": "GET", - "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "created_time": "2023-07-04 07:29:27.14973 +0000 UTC", "duration": 926, "expiry_time": "2023-07-04 07:36:50.056529 +0000 UTC", @@ -86,11 +86,11 @@ "record": true, "record_file_format": "mp3", "recording_callback_method": "GET", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "session_uuid": "4b083bef-7b26-4116-95a4-c35f81f5c2c1", "status": "expired", "total_call_amount": 0, @@ -103,7 +103,7 @@ "amount": 0, "call_time_limit": 600, "callback_method": "GET", - "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "created_time": "2023-07-04 06:41:19.396345 +0000 UTC", "duration": 1244, "expiry_time": "2023-07-04 07:02:03.635064 +0000 UTC", @@ -116,11 +116,11 @@ "record": true, "record_file_format": "mp3", "recording_callback_method": "GET", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "session_uuid": "24d9691b-3904-488f-9ad8-f5afa6121606", "status": "expired", "total_call_amount": 0, @@ -133,7 +133,7 @@ "amount": 0, "call_time_limit": 14400, "callback_method": "GET", - "callback_url": "http://plivobin.non-prod.plivops.com/w7mf5kw7", + "callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "created_time": "2023-07-03 09:46:07.91423 +0000 UTC", "duration": 8702, "expiry_time": "2023-07-03 12:11:09.939161 +0000 UTC", @@ -146,11 +146,11 @@ "record": false, "record_file_format": "mp3", "recording_callback_method": "GET", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "session_uuid": "964c20e0-9d59-40d5-90c3-7006ef5d03f4", "status": "expired", "total_call_amount": 0, @@ -163,7 +163,7 @@ "amount": 0, "call_time_limit": 600, "callback_method": "GET", - "callback_url": "http://plivobin.non-prod.plivops.com/12tksfd1", + "callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "created_time": "2023-06-30 06:51:11.021617 +0000 UTC", "duration": 6702, "expiry_time": "2023-06-30 08:42:53.503857 +0000 UTC", @@ -176,11 +176,11 @@ "record": true, "record_file_format": "mp3", "recording_callback_method": "GET", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "session_uuid": "c4ea0e4c-b3e7-47c3-a31c-79227ac6939c", "status": "expired", "total_call_amount": 0, @@ -193,7 +193,7 @@ "amount": 0, "call_time_limit": 14400, "callback_method": "GET", - "callback_url": "http://plivobin.non-prod.plivops.com/w7mf5kw7", + "callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "created_time": "2023-06-30 06:39:06.742974 +0000 UTC", "duration": 6000, "expiry_time": "2023-06-30 06:39:16.99714 +0000 UTC", @@ -206,11 +206,11 @@ "record": false, "record_file_format": "mp3", "recording_callback_method": "GET", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "session_uuid": "dd3bb3c2-4f18-4988-87f1-9116b00bb875", "status": "expired", "total_call_amount": 0, diff --git a/tests/resources/fixtures/maskingSessionUpdateResponse.json b/tests/resources/fixtures/maskingSessionUpdateResponse.json index 354dfdaa..9700286b 100644 --- a/tests/resources/fixtures/maskingSessionUpdateResponse.json +++ b/tests/resources/fixtures/maskingSessionUpdateResponse.json @@ -8,7 +8,7 @@ "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_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "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", @@ -18,10 +18,10 @@ "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", + "second_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", "record": true, "record_file_format": "mp3", - "recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", + "recording_callback_url": "https://s3.amazonaws.com/static.plivo.com/callback.xml", "recording_callback_method": "GET", "interaction": null, "total_call_amount": 0, diff --git a/tests/xml/test_MultiPartyCallElement.py b/tests/xml/test_MultiPartyCallElement.py index 5563ddec..8d8dae1f 100644 --- a/tests/xml/test_MultiPartyCallElement.py +++ b/tests/xml/test_MultiPartyCallElement.py @@ -19,7 +19,7 @@ def test_default_xml(self): 'statusCallbackEvents="mpc-state-changes,participant-state-changes" ' \ 'statusCallbackMethod="POST" stayAlone="false" ' \ 'stopRecordingAudioMethod="GET" ' \ - 'waitMusicMethod="GET">Nairobi' + 'waitMusicMethod="GET" transcript="false">Nairobi' element = plivoxml.MultiPartyCallElement(content='Nairobi', role='Agent') self.assertXmlEqual(element.to_string(False), expected_response) @@ -36,7 +36,7 @@ def test_setting_optional_fields(self): 'statusCallbackEvents="mpc-state-changes,participant-state-changes" ' \ 'statusCallbackMethod="POST" stayAlone="false" ' \ 'stopRecordingAudioMethod="GET" ' \ - 'waitMusicMethod="GET">Tokyo' + 'waitMusicMethod="GET" transcript="false">Tokyo' element = plivoxml.MultiPartyCallElement(content='Tokyo', role='supervisor', exit_sound='beep:1') self.assertXmlEqual(element.to_string(False), expected_response) @@ -79,13 +79,15 @@ def test_builder_setting(self): 'statusCallbackMethod="POST" stayAlone="false" stopRecordingAudio="http://plivo.com/api.mp3" ' \ 'stopRecordingAudioMethod="GET" ' \ 'waitTime="5" ' \ - 'waitMusicMethod="GET" recordMinMemberCount="1">Helsinki ' + 'waitMusicMethod="GET" recordMinMemberCount="1" transcript="true" transcriptionUrl="http://plivo.com/api.mp3" >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). \ set_on_exit_action_url('http://plivo.com/api.mp3').set_on_exit_action_method('GET'). \ set_stop_recording_audio("http://plivo.com/api.mp3"). \ set_start_recording_audio("http://plivo.com/api.mp3"). \ - set_wait_time(5) + set_wait_time(5). \ + set_transcript(True). \ + set_transcription_url("http://plivo.com/api.mp3") self.assertXmlEqual(expected_xml, element.to_string(False)) diff --git a/tests/xml/test_responseElement.py b/tests/xml/test_responseElement.py index e7efb230..f15f8fe4 100644 --- a/tests/xml/test_responseElement.py +++ b/tests/xml/test_responseElement.py @@ -119,9 +119,11 @@ def test_add_mpc(self): 'statusCallbackMethod="GET" stayAlone="false" ' \ 'stopRecordingAudio="https://plivo.com/plivoTone.mp3" ' \ 'stopRecordingAudioMethod="GET" ' \ + 'transcript="true" ' \ + 'transcriptionUrl="https://plivo.com/plivoTone.mp3" ' \ 'waitMusicMethod="POST" ' \ - 'waitTime="5" ' \ - 'waitMusicUrl="https://plivo.com/plivoTone.mp3">multi party conference' \ + 'waitMusicUrl = "https://plivo.com/plivoTone.mp3" ' \ + 'waitTime="5">multi party conference ' \ '' elem = plivoxml.ResponseElement().add_multi_party_call(content='multi party conference', role='customer', @@ -132,5 +134,7 @@ def test_add_mpc(self): enter_sound='beep:2', exit_sound='beep:1', hold=True, on_exit_action_url='https://plivo.com/exitAction', start_recording_audio='https://plivo.com/plivoTone.mp3', - stop_recording_audio='https://plivo.com/plivoTone.mp3') + stop_recording_audio='https://plivo.com/plivoTone.mp3', + transcript=True, + transcription_url="https://plivo.com/plivoTone.mp3") self.assertXmlEqual(expected_xml, elem.to_string(False))