Skip to content

Commit

Permalink
Merge pull request #202 from plivo/VT-4174
Browse files Browse the repository at this point in the history
VT-4174
  • Loading branch information
manjunath-plivo authored May 5, 2022
2 parents df2daad + 79b8e92 commit 8e36a2d
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [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)

## [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/)
Expand Down
6 changes: 6 additions & 0 deletions plivo/resources/multipartycall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())],
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 15 additions & 2 deletions plivo/resources/recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class Recordings(PlivoResourceInterface):
_resource_type = Recording

@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=[
Expand All @@ -35,7 +41,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,
Expand All @@ -45,7 +52,13 @@ def list(self,
add_time__lte=None,
add_time=None,
limit=20,
offset=0):
offset=0,
from_number=None,
to_number=None,
conference_name=None,
mpc_name=None,
conference_uuid=None,
mpc_uuid=None):

if subaccount:
if isinstance(subaccount, Subaccount):
Expand Down
2 changes: 1 addition & 1 deletion plivo/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
__version__ = '4.23.0'
__version__ = '4.24.0'

23 changes: 23 additions & 0 deletions plivo/xml/MultiPartyCallElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 15 additions & 0 deletions tests/resources/fixtures/recordingGetAddedFilterResponse.json
Original file line number Diff line number Diff line change
@@ -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:[email protected]"
}
57 changes: 57 additions & 0 deletions tests/resources/fixtures/recordingListFromFilterResponse.json
Original file line number Diff line number Diff line change
@@ -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:[email protected]"
},
{
"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:[email protected]"
},
{
"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:[email protected]"
}
]
}
1 change: 1 addition & 0 deletions tests/resources/test_multipartycalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
42 changes: 42 additions & 0 deletions tests/resources/test_recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]', 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)
8 changes: 5 additions & 3 deletions tests/xml/test_MultiPartyCallElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" ' \
Expand All @@ -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" ' \
Expand Down Expand Up @@ -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</MultiPartyCall> '
'waitMusicMethod="GET" recordMinMemberCount="1">Helsinki</MultiPartyCall> '
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). \
Expand Down
3 changes: 2 additions & 1 deletion tests/xml/test_responseElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" ' \
Expand Down

0 comments on commit 8e36a2d

Please sign in to comment.