Skip to content

Commit d067b34

Browse files
committed
Fix connection errors when paginating -- fixes #120
1 parent 026d22f commit d067b34

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

intercom/collection_proxy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,6 @@ def paging_info_present(self, response):
9898
def extract_next_link(self, response):
9999
if self.paging_info_present(response):
100100
paging_info = response["pages"]
101-
return paging_info["next"]
101+
if paging_info["next"]:
102+
next_parsed = six.moves.urllib.parse.urlparse(paging_info["next"])
103+
return '{}?{}'.format(next_parsed.path, next_parsed.query)

tests/unit/test_collection_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def it_keeps_iterating_if_next_link(self):
3030
side_effect = [page1, page2]
3131
with patch.object(Client, 'get', side_effect=side_effect) as mock_method: # noqa
3232
emails = [user.email for user in self.client.users.all()]
33-
eq_([call('/users', {}), call('https://api.intercom.io/users?per_page=50&page=2', {})], # noqa
33+
eq_([call('/users', {}), call('/users?per_page=50&page=2', {})], # noqa
3434
mock_method.mock_calls)
3535
eq_(emails, ['user1@example.com', 'user2@example.com', 'user3@example.com'] * 2) # noqa
3636

0 commit comments

Comments
 (0)