Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testingbranch #193

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.23.1](https://github.com/plivo/plivo-python/tree/v4.23.1) (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)

## [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
9 changes: 9 additions & 0 deletions makeCall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import plivo

client = plivo.RestClient('MAYJI2ZJDIMTVIODIWYJ','OTI2NWFmNGI4MmZjZjZkOTQ0YjNkYTQwMzY2ZDJl')
response = client.calls.create(
from_='+919999323467',
to_='sip:[email protected]',
answer_url='https://s3.amazonaws.com/static.plivo.com/answer.xml',
answer_method='GET', )
print(response)
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
9 changes: 7 additions & 2 deletions plivo/resources/recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand All @@ -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,
Expand All @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions plivo/rest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
AuthenticationCredentials = namedtuple('AuthenticationCredentials',
'auth_id auth_token')

PLIVO_API = 'https://api.plivo.com'
PLIVO_API = 'https://api-qa.voice.plivodev.com'
PLIVO_API_BASE_URI = '/'.join([PLIVO_API, 'v1/Account'])

# Will change these urls before putting this change in production
API_VOICE = 'https://api.plivo.com'
API_VOICE = 'https://api-qa.voice.plivodev.com'
API_VOICE_BASE_URI = '/'.join([API_VOICE, 'v1/Account'])
API_VOICE_FALLBACK_1 = 'https://api.plivo.com'
API_VOICE_FALLBACK_2 = 'https://api.plivo.com'
API_VOICE_FALLBACK_1 = 'https://api-qa.voice.plivodev.com'
API_VOICE_FALLBACK_2 = 'https://api-qa.voice.plivodev.com'
API_VOICE_BASE_URI_FALLBACK_1 = '/'.join([API_VOICE_FALLBACK_1, 'v1/Account'])
API_VOICE_BASE_URI_FALLBACK_2 = '/'.join([API_VOICE_FALLBACK_2, 'v1/Account'])

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.23.1'

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 requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
decorator==4.1.2
lxml==4.2.3
requests==2.20.0
six==1.10.0
six==1.16.0
PyJWT==2.1.0
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]"
}
]
}
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)