Skip to content

Commit e445e65

Browse files
author
Rajat Singh
authored
Merge pull request #73 from plivo/sept-2018-release
Add python3.7 support Add support to get queued calls Add powerpack support Add support for filter of parent call UUID
2 parents 1103993 + 6faac5a commit e445e65

File tree

16 files changed

+145
-34
lines changed

16 files changed

+145
-34
lines changed

.DS_Store

6 KB
Binary file not shown.

.travis.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
sudo: false
22
language: python
3-
python:
4-
- "2.7"
5-
- "3.3"
6-
- "3.4"
7-
- "3.5"
8-
- "3.5-dev" # 3.5 development branch
9-
- "3.6"
10-
- "3.6-dev" # 3.6 development branch
3+
matrix:
4+
include:
5+
- python: "2.7"
6+
dist: trusty
7+
- python: "3.4"
8+
dist: trusty
9+
- python: "3.5"
10+
dist: trusty
11+
- python: "3.6"
12+
dist: trusty
13+
- python: "3.7"
14+
dist: xenial
15+
sudo: true
16+
- python: "3.7-dev"
17+
dist: xenial
18+
sudo: true
1119
install: pip install tox-travis
12-
script: tox
20+
script: tox

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.1.1](https://github.com/plivo/plivo-python/tree/v4.1.1) (2018-06-29)
4+
- Added limit & offset parameters to endpoint list api
5+
36
## [4.1.0](https://github.com/plivo/plivo-python/tree/v4.1.0) (2018-02-26)
47
- Add Address and Identity resources
58
- Change a few functions in numbers.py to support the verification flows

plivo/.DS_Store

6 KB
Binary file not shown.

plivo/resources/applications.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def update(self,
2525
message_method='POST',
2626
default_number_app=False,
2727
default_endpoint_app=False,
28-
subaccount=None):
28+
subaccount=None,
29+
log_incoming_messages=True):
2930
params = to_param_dict(self.update, locals())
3031
self.__dict__.update(params)
3132
return self.client.applications.update(self.id, **params)
@@ -54,7 +55,8 @@ class Applications(PlivoResourceInterface):
5455
message_method=[optional(of_type(six.text_type))],
5556
default_number_app=[optional(of_type_exact(bool))],
5657
default_endpoint_app=[optional(of_type_exact(bool))],
57-
subaccount=[optional(is_subaccount())])
58+
subaccount=[optional(is_subaccount())],
59+
log_incoming_messages = [optional(of_type_exact(bool))])
5860
def create(self,
5961
answer_url,
6062
app_name,
@@ -67,7 +69,8 @@ def create(self,
6769
message_method='POST',
6870
default_number_app=False,
6971
default_endpoint_app=False,
70-
subaccount=None):
72+
subaccount=None,
73+
log_incoming_messages=True):
7174

7275
if subaccount:
7376
if isinstance(subaccount, Subaccount):
@@ -117,7 +120,8 @@ def list(self, subaccount=None, limit=20, offset=0):
117120
message_method=[optional(of_type(six.text_type))],
118121
default_number_app=[optional(of_type_exact(bool))],
119122
default_endpoint_app=[optional(of_type_exact(bool))],
120-
subaccount=[optional(is_subaccount())])
123+
subaccount=[optional(is_subaccount())],
124+
log_incoming_messages=[optional(of_type_exact(bool))])
121125
def update(self,
122126
app_id,
123127
answer_url,
@@ -130,7 +134,8 @@ def update(self,
130134
message_method='POST',
131135
default_number_app=False,
132136
default_endpoint_app=False,
133-
subaccount=None):
137+
subaccount=None,
138+
log_incoming_messages=True):
134139
if subaccount:
135140
if isinstance(subaccount, Subaccount):
136141
subaccount = subaccount.id

plivo/resources/calls.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def create(self,
167167
optional(of_type(six.text_type), is_in(('inbound', 'outbound')))
168168
],
169169
from_number=[optional(is_phonenumber())],
170-
to_number=[optional(is_iterable(six.text_type, '<'))],
170+
to_number=[optional(is_iterable(of_type(six.text_type), sep='<'))],
171171
limit=[
172172
optional(
173173
all_of(
@@ -179,6 +179,9 @@ def create(self,
179179
all_of(
180180
of_type(*six.integer_types),
181181
check(lambda offset: 0 <= offset, '0 <= offset')))
182+
],
183+
parent_call_uuid=[
184+
optional(of_type(six.text_type))
182185
])
183186
def list(self,
184187
subaccount=None,
@@ -197,7 +200,8 @@ def list(self,
197200
bill_duration=None,
198201
limit=20,
199202
offset=0,
200-
status=None):
203+
status=None,
204+
parent_call_uuid=None):
201205
return self.client.request(
202206
'GET',
203207
('Call', ),
@@ -358,3 +362,9 @@ def live_call_list_ids(self, limit=None, offset=None):
358362

359363
def live_call_get(self, _id):
360364
return self.client.live_calls.get(_id)
365+
366+
def queued_call_list_ids(self, limit=None, offset=None):
367+
return self.client.queued_calls.list_ids(limit, offset)
368+
369+
def queued_call_get(self, _id):
370+
return self.client.queued_calls.get(_id)

plivo/resources/messages.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,36 @@ class Messages(PlivoResourceInterface):
2424
_resource_type = Message
2525

2626
@validate_args(
27-
src=[is_phonenumber()],
27+
src=[optional(is_phonenumber())],
2828
dst=[is_iterable(of_type(six.text_type), '<')],
2929
text=[of_type(six.text_type)],
3030
type_=[optional(all_of(of_type(six.text_type), is_in(('sms', ))))],
3131
url=[optional(is_url())],
3232
method=[optional(of_type(six.text_type))],
33-
log=[optional(of_type_exact(bool))])
33+
log=[optional(of_type_exact(bool))],
34+
trackable=[optional(of_type_exact(bool))],
35+
powerpack_uuid=[optional(of_type(six.text_type))])
3436
def create(self,
35-
src,
3637
dst,
3738
text,
39+
src=None,
3840
type_='sms',
3941
url=None,
4042
method='POST',
41-
log=True):
43+
log=True,
44+
trackable=False,
45+
powerpack_uuid=None):
4246
if src in dst.split('<'):
4347
raise ValidationError(
4448
'destination number cannot be same as source number')
49+
elif (src is None) and (powerpack_uuid is None):
50+
raise ValidationError(
51+
'Specify either powerpack_uuid or src in request params to send a message'
52+
)
53+
elif (src is not None) and (powerpack_uuid is not None):
54+
raise ValidationError(
55+
'Both powerpack_uuid and src cannot be specified. Specify either powerpack_uuid or src in request params to send a message.'
56+
)
4557
return self.client.request('POST', ('Message', ),
4658
to_param_dict(self.create, locals()))
4759

plivo/resources/queued_calls.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from plivo.base import PlivoResource, PlivoResourceInterface
2+
3+
from ..utils.validators import *
4+
5+
6+
class QueuedCall(PlivoResource):
7+
_name = 'QueuedCall'
8+
_identifier_string = 'call_uuid'
9+
10+
11+
class QueuedCalls(PlivoResourceInterface):
12+
_resource_type = QueuedCall
13+
_iterable = False
14+
15+
@validate_args(
16+
limit=[
17+
optional(
18+
all_of(
19+
of_type(*six.integer_types),
20+
check(
21+
lambda limit: 0 < limit <= 20,
22+
message='0 < limit <= 20')))
23+
],
24+
offset=[
25+
optional(
26+
all_of(
27+
of_type(*six.integer_types),
28+
check(lambda offset: 0 <= offset, message='0 <= offset')))
29+
])
30+
def list_ids(self, limit=20, offset=0):
31+
return self.client.request('GET', ('Call', ), {
32+
'status': 'queued',
33+
'limit': limit,
34+
'offset': offset,
35+
})
36+
37+
@validate_args(_id=[of_type(six.text_type)])
38+
def get(self, _id):
39+
return self.client.request('GET', ('Call', _id), {'status': 'queued'})

plivo/rest/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Conferences, Endpoints, Identities, Messages,
1616
Numbers, Pricings, Recordings, Subaccounts)
1717
from plivo.resources.live_calls import LiveCalls
18+
from plivo.resources.queued_calls import QueuedCalls
1819
from plivo.utils import is_valid_mainaccount, is_valid_subaccount
1920
from plivo.version import __version__
2021
from requests import Request, Session
@@ -77,6 +78,7 @@ def __init__(self, auth_id=None, auth_token=None, proxies=None, timeout=5):
7778
self.applications = Applications(self)
7879
self.calls = Calls(self)
7980
self.live_calls = LiveCalls(self)
81+
self.queued_calls = QueuedCalls(self)
8082
self.conferences = Conferences(self)
8183
self.endpoints = Endpoints(self)
8284
self.messages = Messages(self)

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.1.0'
2+
__version__ = '4.1.1'

0 commit comments

Comments
 (0)