Skip to content

Commit 1103993

Browse files
authored
Merge pull request #50 from nixonsam/SUP-102
changes in endpoint.py resource by adding limit & offset parameters
2 parents 5c688fc + ee69e03 commit 1103993

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

plivo/resources/endpoints.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,26 @@ def create(self, username, password, alias, app_id=None):
3838
def get(self, endpoint_id):
3939
return self.client.request('GET', ('Endpoint', endpoint_id))
4040

41-
def list(self):
41+
@validate_args(
42+
limit=[
43+
optional(
44+
all_of(
45+
of_type(*six.integer_types),
46+
check(lambda limit: 0 < limit <= 20, '0 < limit <= 20')))
47+
],
48+
offset=[
49+
optional(
50+
all_of(
51+
of_type(*six.integer_types),
52+
check(lambda offset: 0 <= offset, '0 <= offset')))
53+
])
54+
def list(self, limit=20, offset=0):
4255
return self.client.request(
4356
'GET',
4457
('Endpoint', ),
58+
to_param_dict(self.list, locals()),
4559
objects_type=Endpoint,
46-
response_type=ListResponseObject,
47-
)
60+
response_type=ListResponseObject)
4861

4962
@validate_args(
5063
endpoint_id=[of_type(six.text_type)],

tests/resources/test_endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_list(self):
1919
self.assertEqual(len(list(endpoints)), 2)
2020
self.assertEqual(self.client.current_request.method, 'GET')
2121
self.assertUrlEqual(
22-
self.get_url('Endpoint'), self.client.current_request.url)
22+
self.get_url('Endpoint', limit=20, offset=0), self.client.current_request.url)
2323

2424
@with_response(200)
2525
def test_get(self):

0 commit comments

Comments
 (0)