Skip to content

Commit 0843141

Browse files
authored
Merge pull request #130 from plivo/VT-1863-mpc-changes
Vt 1863 mpc changes
2 parents 19c5c28 + 4bbc6c5 commit 0843141

31 files changed

Lines changed: 2125 additions & 63 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ dist/
88
*.pyo
99
./tests/htmlcov/
1010
.tox/
11-
venv/
11+
venv*/

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## [4.16.0](https://github.com/plivo/plivo-python/tree/v4.16.0) (2021-04-19)
4+
- Added SDK support for Multiparty Call APIs and XML.
5+
36
## [4.15.3](https://github.com/plivo/plivo-python/tree/v4.15.2) (2021-03-10)
47
- Add "npanxx" and "local_calling_area" support for Search Phone Number.
58

plivo/base.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,13 @@ def delete(self):
172172
return PlivoGenericResponse(
173173
self.client.send_request(self.__resource_uri, method='DELETE'))
174174

175-
def get(self, params=None):
175+
def get(self):
176176
if not self.id:
177177
raise InvalidRequestError(
178178
'Cannot get a {resource_type} resource without an '
179179
'identifier'.format(resource_type=self._name))
180180

181-
self.__resource_json = self.client.send_request(
182-
self.__resource_uri, data=params)
181+
self.__resource_json = self.client.send_request(self.__resource_uri)
183182
self.__parse_json()
184183
return self
185184

@@ -200,6 +199,27 @@ def create(self, params):
200199
self.__resource_uri, data=params, method='POST'), id_string)
201200

202201

202+
class SecondaryPlivoResource(PlivoResource):
203+
"""
204+
SecondaryPlivoResource resource object
205+
This provides an interface to deal with resources where identifier is has a mid level parent
206+
"""
207+
_secondary_identifier_string = None
208+
209+
@property
210+
def secondary_id(self):
211+
value = self.__dict__.get(self._secondary_identifier_string, None)
212+
if not value:
213+
raise ValueError('{} must be set'.format(self._secondary_identifier_string))
214+
return value
215+
216+
def __init__(self, client, data):
217+
"""Sets up the PlivoResource"""
218+
super(SecondaryPlivoResource, self).__init__(client, data)
219+
self._name = self._name or self.__class__.__name__
220+
self.client = client
221+
222+
203223
class PlivoResourceInterface(object):
204224
_iterable = True
205225

plivo/resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
from .call_feedback import CallFeedback
1616
from .powerpacks import Powerpacks
1717
from .lookup import Lookup
18+
from .multipartycall import MultiPartyCalls, MultiPartyCall, MultiPartyCallParticipant

plivo/resources/multipartycall.py

Lines changed: 409 additions & 0 deletions
Large diffs are not rendered by default.

plivo/rest/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from plivo.resources import (Accounts, Addresses, Applications, Calls,
1515
Conferences, Endpoints, Identities,
1616
Messages, Powerpacks, Media, Lookup,
17-
Numbers, Pricings, Recordings, Subaccounts, CallFeedback)
17+
Numbers, Pricings, Recordings, Subaccounts, CallFeedback, MultiPartyCalls)
1818
from plivo.resources.live_calls import LiveCalls
1919
from plivo.resources.queued_calls import QueuedCalls
2020
from plivo.resources.regulatory_compliance import EndUsers, ComplianceDocumentTypes, ComplianceDocuments, \
@@ -109,6 +109,7 @@ def __init__(self, auth_id=None, auth_token=None, proxies=None, timeout=5):
109109
self.compliance_documents = ComplianceDocuments(self)
110110
self.compliance_requirements = ComplianceRequirements(self)
111111
self.compliance_applications = ComplianceApplications(self)
112+
self.multi_party_calls = MultiPartyCalls(self)
112113
self.voice_retry_count = 0
113114

114115
def __enter__(self):
@@ -194,7 +195,7 @@ def process_response(self,
194195
raise PlivoRestError('Resource at {url} could not be '
195196
'deleted'.format(url=response.url))
196197

197-
elif response.status_code not in [200, 201, 202, 207]:
198+
elif response.status_code not in [200, 201, 202, 204, 207]:
198199
raise PlivoRestError(
199200
'Received status code {status_code} for the HTTP method '
200201
'"{method}"'.format(

plivo/utils/signature_v3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from base64 import encodebytes as encode
1414

1515

16-
1716
def string_format(value):
1817
if isinstance(value, bytes):
1918
return ''.join(chr(x) for x in bytearray(value))

plivo/utils/validators.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,38 @@ def f(name, value):
6262
return f
6363

6464

65-
def is_in(iterable, message=None, case_sensitive=True):
65+
def is_in(iterable, message=None, case_sensitive=True, case_type='upper'):
6666
def f(name, value):
6767
actual_value = value
6868
if not case_sensitive:
69-
value = str(value).upper()
69+
if case_type == 'upper':
70+
value = str(value).upper()
71+
elif case_type == 'lower':
72+
value = str(value).lower()
73+
elif case_type == 'title':
74+
value = str(value).title()
75+
7076
msg = message or '{} should be in {}'.format(name, iterable)
7177
if value in iterable:
7278
return value, []
7379
else:
7480
return None, ['{} (actual value: {})'.format(msg, actual_value)]
81+
return f
82+
83+
84+
def multi_is_in(iterable, message=None, case_sensitive=True, make_lower_case=False, separator=','):
85+
def f(name, value):
86+
actual_value = value
87+
if not case_sensitive:
88+
if make_lower_case:
89+
value = str(value).lower()
90+
else:
91+
value = str(value).upper()
92+
msg = message or '{} should be among {}. multiple values should be COMMA(,) separated'.format(name, iterable)
93+
for val in value.split(separator):
94+
if val not in iterable:
95+
return None, ['{} (actual value: {})'.format(msg, actual_value)]
96+
return value, []
7597

7698
return f
7799

@@ -193,3 +215,5 @@ def wrapper(self, *args, **kwargs):
193215
regex(
194216
r'(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+|None)'
195217
))
218+
is_proper_date_format = functools.partial(all_of, of_type_exact(str),
219+
regex(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2}(\.\d{1,6})?)?$'))

plivo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = '4.15.3'
2+
__version__ = '4.16.0'

0 commit comments

Comments
 (0)