Skip to content

Commit 997441e

Browse files
committed
Merge pull request #36 from twitterdev/cursor-options-fix
[bug] fixing cursor to handle next cursor and request params correctly
2 parents 4188a46 + 5549dd8 commit 997441e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

twitter_ads/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (C) 2015 Twitter, Inc.
22

3-
VERSION = (0, 1, 1)
3+
VERSION = (0, 1, 2)
44

55
from twitter_ads.utils import get_version
66

twitter_ads/cursor.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def next(self):
5858
value = self._collection[self._current_index]
5959
self._current_index += 1
6060
return value
61-
elif self._current_index > len(self._collection) and self._next_cursor:
61+
elif self._next_cursor:
6262
self.__fetch_next()
6363
return self.next()
6464
else:
@@ -74,8 +74,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
7474
self.__die()
7575

7676
def __fetch_next(self):
77-
params = self._options.copy().update({'next_cursor': self._next_cursor})
78-
response = Request(self._client, self._method, self._resource, params=params).perform()
77+
options = self._options.copy()
78+
params = options.get('params', {})
79+
params.update({'cursor': self._next_cursor})
80+
options['params'] = params
81+
response = Request(self._client, self._method, self._resource, **options).perform()
7982
return self.__from_response(response)
8083

8184
def __from_response(self, response):

0 commit comments

Comments
 (0)