From 4e9d73077c5c9cd29091af359ce4f0b1ea6ebda9 Mon Sep 17 00:00:00 2001 From: Eliram Shatz Date: Wed, 21 Dec 2016 12:14:39 +0200 Subject: [PATCH 01/20] Add the last nextPageToken as part of the response for getLeadsActivities --- marketorestpython/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index c56a893..2f5ecac 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -805,10 +805,10 @@ def get_lead_activities(self, activityTypeIds, nextPageToken=None, sinceDatetime result_list.extend(new_result) else: result_list.extend(result['result']) + args['nextPageToken'] = result['nextPageToken'] if result['moreResult'] is False: break - args['nextPageToken'] = result['nextPageToken'] - return result_list + return result_list, args['nextPageToken'] def get_lead_activities_yield(self, activityTypeIds, nextPageToken=None, sinceDatetime=None, untilDatetime=None, batchSize=None, listId=None, leadIds=None): From 1937c1f2b5c2969a59bac1d90dcc638953afa6a3 Mon Sep 17 00:00:00 2001 From: Eliram Shatz Date: Wed, 21 Dec 2016 15:21:46 +0200 Subject: [PATCH 02/20] Add the last nextPageToken as part of the response for getLeadsActivityYield --- marketorestpython/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 2f5ecac..e787292 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -836,18 +836,18 @@ def get_lead_activities_yield(self, activityTypeIds, nextPageToken=None, sinceDa result = self._api_call('get', self.host + "/rest/v1/activities.json", args) if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) + args['nextPageToken'] = result['nextPageToken'] if 'result' in result: if untilDatetime is not None: new_result = self.process_lead_activity_until_datetime(result['result'], untilDatetime) if new_result: - yield new_result + yield new_result, args['nextPageToken'] if len(new_result) < len(result['result']): break else: - yield result['result'] + yield result['result'], args['nextPageToken'] if result['moreResult'] is False: break - args['nextPageToken'] = result['nextPageToken'] def get_lead_changes(self, fields, nextPageToken=None, sinceDatetime=None, batchSize=None, listId=None): self.authenticate() From 2426a7d6d78ada4dccb016a987f1bda7e053d7e7 Mon Sep 17 00:00:00 2001 From: Eliram Shatz Date: Sun, 25 Dec 2016 10:50:10 +0200 Subject: [PATCH 03/20] Add NextPageToken to get multi leads yield and set requests == 2.5.1 --- marketorestpython/client.py | 3 ++- setup.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index e787292..7c33920 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -343,8 +343,9 @@ def get_multiple_leads_by_list_id_yield(self, listId, fields=None, batchSize=Non result = self._api_call('post', self.host + "/rest/v1/list/" + str(listId)+ "/leads.json", args, data, mode='nojsondumps') if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) + args['nextPageToken'] = result.get('nextPageToken') if 'result' in result: - yield result['result'] + yield result['result'], args['nextPageToken'] if len(result['result']) == 0 or 'nextPageToken' not in result: break else: diff --git a/setup.py b/setup.py index 7db1a8b..3facbc2 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ packages=['marketorestpython', 'marketorestpython.helper'], license='MIT License', install_requires=[ - 'requests', + 'requests==2.5.1', ], keywords = ['Marketo', 'REST API', 'Wrapper', 'Client'], description='Python Client for the Marketo REST API', From 1a7155e288b8896d6f9c7631d38d2f490b58b499 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Sun, 25 Dec 2016 11:15:37 +0200 Subject: [PATCH 04/20] Revert "Add the last nextPageToken as part of the response for" This reverts commit 1937c1f2b5c2969a59bac1d90dcc638953afa6a3. --- marketorestpython/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index e787292..2f5ecac 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -836,18 +836,18 @@ def get_lead_activities_yield(self, activityTypeIds, nextPageToken=None, sinceDa result = self._api_call('get', self.host + "/rest/v1/activities.json", args) if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) - args['nextPageToken'] = result['nextPageToken'] if 'result' in result: if untilDatetime is not None: new_result = self.process_lead_activity_until_datetime(result['result'], untilDatetime) if new_result: - yield new_result, args['nextPageToken'] + yield new_result if len(new_result) < len(result['result']): break else: - yield result['result'], args['nextPageToken'] + yield result['result'] if result['moreResult'] is False: break + args['nextPageToken'] = result['nextPageToken'] def get_lead_changes(self, fields, nextPageToken=None, sinceDatetime=None, batchSize=None, listId=None): self.authenticate() From e5b2e17a5a2be81d7dba03ddaeeddf712327bac1 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Sun, 25 Dec 2016 11:17:58 +0200 Subject: [PATCH 05/20] Hook version to 2.5.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7db1a8b..3facbc2 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ packages=['marketorestpython', 'marketorestpython.helper'], license='MIT License', install_requires=[ - 'requests', + 'requests==2.5.1', ], keywords = ['Marketo', 'REST API', 'Wrapper', 'Client'], description='Python Client for the Marketo REST API', From 707536c605ef658c4091e64ebe856fd95bbfb175 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Sun, 25 Dec 2016 13:58:03 +0200 Subject: [PATCH 06/20] add yield to get multiple leads by filter --- marketorestpython/client.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 2f5ecac..8fed492 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -51,6 +51,7 @@ def execute(self, method, *args, **kargs): method_map={ 'get_lead_by_id': self.get_lead_by_id, 'get_multiple_leads_by_filter_type': self.get_multiple_leads_by_filter_type, + 'get_multiple_leads_by_filter_type_yield': self.get_multiple_leads_by_filter_type_yield, 'get_multiple_leads_by_list_id': self.get_multiple_leads_by_list_id, 'get_multiple_leads_by_list_id_yield': self.get_multiple_leads_by_list_id_yield, 'get_multiple_leads_by_program_id': self.get_multiple_leads_by_program_id, @@ -300,6 +301,32 @@ def get_multiple_leads_by_filter_type(self, filterType, filterValues, fields=Non args['nextPageToken'] = result['nextPageToken'] return result_list + def get_multiple_leads_by_filter_type_yield(self, filterType, filterValues, fields=None, batchSize=None): + self.authenticate() + if filterType is None: raise ValueError("Invalid argument: required argument filterType is none.") + if filterValues is None: raise ValueError("Invalid argument: required argument filter_values is none.") + filterValues = filterValues.split() if type(filterValues) is str else filterValues + data=[('filterValues',(',').join(filterValues)), ('filterType', filterType)] + if fields is not None: + data.append(('fields',fields)) + if batchSize is not None: + data.append(('batchSize',batchSize)) + args = { + 'access_token': self.token, + '_method': 'GET' + } + while True: + self.authenticate() + args['access_token'] = self.token # for long-running processes, this updates the access token + result = self._api_call('post', self.host + "/rest/v1/leads.json", args, data, mode='nojsondumps') + if result is None: raise Exception("Empty Response") + if not result['success'] : raise MarketoException(result['errors'][0]) + args['nextPageToken'] = result.get('nextPageToken') + if 'result' in result: + yield result['result'], args['nextPageToken'] + if len(result['result']) == 0 or 'nextPageToken' not in result: + break + def get_multiple_leads_by_list_id(self, listId, fields=None, batchSize=None): self.authenticate() if listId is None: raise ValueError("Invalid argument: required argument listId is none.") From 8b30643f08bff562b0a0f18795991876474556d4 Mon Sep 17 00:00:00 2001 From: Eliram Shatz Date: Wed, 28 Dec 2016 08:53:22 +0200 Subject: [PATCH 07/20] change requests = 2.10.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3facbc2..0d76a2d 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ packages=['marketorestpython', 'marketorestpython.helper'], license='MIT License', install_requires=[ - 'requests==2.5.1', + 'requests==2.10.0', ], keywords = ['Marketo', 'REST API', 'Wrapper', 'Client'], description='Python Client for the Marketo REST API', From e9b3d7e31ab5eb7a07d1a211616e079df8775150 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Thu, 29 Dec 2016 09:43:04 +0200 Subject: [PATCH 08/20] revert --- marketorestpython/client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 32ca70d..8fed492 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -370,9 +370,8 @@ def get_multiple_leads_by_list_id_yield(self, listId, fields=None, batchSize=Non result = self._api_call('post', self.host + "/rest/v1/list/" + str(listId)+ "/leads.json", args, data, mode='nojsondumps') if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) - args['nextPageToken'] = result.get('nextPageToken') if 'result' in result: - yield result['result'], args['nextPageToken'] + yield result['result'] if len(result['result']) == 0 or 'nextPageToken' not in result: break else: From 21c4871a7214a28634455943d3206814173f94b4 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Thu, 29 Dec 2016 09:56:27 +0200 Subject: [PATCH 09/20] add nextPageToken parameter --- marketorestpython/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 8fed492..59b03b4 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -301,7 +301,7 @@ def get_multiple_leads_by_filter_type(self, filterType, filterValues, fields=Non args['nextPageToken'] = result['nextPageToken'] return result_list - def get_multiple_leads_by_filter_type_yield(self, filterType, filterValues, fields=None, batchSize=None): + def get_multiple_leads_by_filter_type_yield(self, filterType, filterValues, fields=None, nextPageToken=None, batchSize=None): self.authenticate() if filterType is None: raise ValueError("Invalid argument: required argument filterType is none.") if filterValues is None: raise ValueError("Invalid argument: required argument filter_values is none.") @@ -315,6 +315,8 @@ def get_multiple_leads_by_filter_type_yield(self, filterType, filterValues, fiel 'access_token': self.token, '_method': 'GET' } + if nextPageToken is not None: + args['nextPageToken'] = nextPageToken while True: self.authenticate() args['access_token'] = self.token # for long-running processes, this updates the access token From 9ff4601c5a8b6cc91e85063702ed896756b0ce04 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Thu, 29 Dec 2016 09:58:00 +0200 Subject: [PATCH 10/20] fix identation --- marketorestpython/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 59b03b4..d78eeb0 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -315,8 +315,8 @@ def get_multiple_leads_by_filter_type_yield(self, filterType, filterValues, fiel 'access_token': self.token, '_method': 'GET' } - if nextPageToken is not None: - args['nextPageToken'] = nextPageToken + if nextPageToken is not None: + args['nextPageToken'] = nextPageToken while True: self.authenticate() args['access_token'] = self.token # for long-running processes, this updates the access token From 8cc4d2e926fc6a7eb206522d5d37cbfdb4c88d32 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Thu, 29 Dec 2016 14:07:25 +0200 Subject: [PATCH 11/20] add nextPageToken to yield in get_lead_activities_yield --- marketorestpython/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index d78eeb0..ee609e2 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -866,17 +866,17 @@ def get_lead_activities_yield(self, activityTypeIds, nextPageToken=None, sinceDa if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) if 'result' in result: + args['nextPageToken'] = result['nextPageToken'] if untilDatetime is not None: new_result = self.process_lead_activity_until_datetime(result['result'], untilDatetime) if new_result: - yield new_result + yield new_result, args['nextPageToken'] if len(new_result) < len(result['result']): break else: - yield result['result'] + yield result['result'], args['nextPageToken'] if result['moreResult'] is False: break - args['nextPageToken'] = result['nextPageToken'] def get_lead_changes(self, fields, nextPageToken=None, sinceDatetime=None, batchSize=None, listId=None): self.authenticate() From 5cbf8fa814d5dbe136fef88e059fd885e149235c Mon Sep 17 00:00:00 2001 From: Gilad Wagner Date: Tue, 21 Feb 2017 11:48:55 +0200 Subject: [PATCH 12/20] next page token should be updated regardless to results of requests --- marketorestpython/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index ee609e2..530e386 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -865,8 +865,8 @@ def get_lead_activities_yield(self, activityTypeIds, nextPageToken=None, sinceDa result = self._api_call('get', self.host + "/rest/v1/activities.json", args) if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) + args['nextPageToken'] = result['nextPageToken'] if 'result' in result: - args['nextPageToken'] = result['nextPageToken'] if untilDatetime is not None: new_result = self.process_lead_activity_until_datetime(result['result'], untilDatetime) if new_result: From d6f28c2cb865867ae7a7dc54cd5628c0f0326026 Mon Sep 17 00:00:00 2001 From: Gilad Wagner Date: Wed, 22 Feb 2017 09:34:06 +0200 Subject: [PATCH 13/20] next page token should be updated regardless to results of requests --- marketorestpython/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index ee609e2..530e386 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -865,8 +865,8 @@ def get_lead_activities_yield(self, activityTypeIds, nextPageToken=None, sinceDa result = self._api_call('get', self.host + "/rest/v1/activities.json", args) if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) + args['nextPageToken'] = result['nextPageToken'] if 'result' in result: - args['nextPageToken'] = result['nextPageToken'] if untilDatetime is not None: new_result = self.process_lead_activity_until_datetime(result['result'], untilDatetime) if new_result: From ccd16456b4528234bba7b03cdb0a129bb189ffc0 Mon Sep 17 00:00:00 2001 From: Meny Issakov Date: Tue, 26 Dec 2017 17:33:24 +0200 Subject: [PATCH 14/20] Support smart lists in the API --- marketorestpython/client.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 01e251e..2282e4c 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -234,7 +234,9 @@ def execute(self, method, *args, **kargs): 'discard_custom_activity_type_draft': self.discard_custom_activity_type_draft, 'delete_custom_activity_type': self.delete_custom_activity_type, 'update_custom_activity_type_attribute': self.update_custom_activity_type_attribute, - 'delete_custom_activity_type_attribute': self.delete_custom_activity_type_attribute + 'delete_custom_activity_type_attribute': self.delete_custom_activity_type_attribute, + 'get_smart_lists': self.get_smart_lists, + 'get_leads_from_smart_list': self.get_leads_from_smart_list, } result = method_map[method](*args,**kargs) except MarketoException as e: @@ -3801,3 +3803,26 @@ def delete_custom_activity_type_attribute(self, apiName, attributes): if result is None: raise Exception("Empty Response") if not result['success'] : raise MarketoException(result['errors'][0]) return result['result'] + + def get_smart_lists(self): + self.authenticate() + args = { + 'access_token': self.token + } + result = self._api_call('get', + self.host + "/rest/asset/v1/smartLists.json") + if result is None: raise Exception("Empty Response") + if not result['success'] : raise MarketoException(result['errors'][0]) + return result['result'] + + def get_leads_from_smart_list(self, id): + self.authenticate() + if id is None: raise ValueError("Invalid argument: required argument id is none.") + args = { + 'access_token': self.token + } + result = self._api_call('get', + self.host + "/rest/asset/v1/smartList/" + str(id) + ".json", args) + if result is None: raise Exception("Empty Response") + if not result['success'] : raise MarketoException(result['errors'][0]) + return result['result'] From 3edaddee293eff413634d5c9266545e166708bae Mon Sep 17 00:00:00 2001 From: Meny Issakov Date: Wed, 27 Dec 2017 09:26:28 +0200 Subject: [PATCH 15/20] Missing access_token in get_smart_lists call --- marketorestpython/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 2282e4c..75c8560 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -3810,7 +3810,7 @@ def get_smart_lists(self): 'access_token': self.token } result = self._api_call('get', - self.host + "/rest/asset/v1/smartLists.json") + self.host + "/rest/asset/v1/smartLists.json", args) if result is None: raise Exception("Empty Response") if not result['success'] : raise MarketoException(result['errors'][0]) return result['result'] From 9b9a3626e8454ec2cf0f5e288ada81bb4548f02f Mon Sep 17 00:00:00 2001 From: Meny Issakov Date: Wed, 27 Dec 2017 10:30:29 +0200 Subject: [PATCH 16/20] Increase version to 0.3.8 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ccf6cdd..c847a98 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='marketorestpython', - version= '0.3.7', + version= '0.3.8', url='https://github.com/jepcastelein/marketo-rest-python', author='Jep Castelein', author_email='jep@castelein.net', From 090012366e147dfa70032a351f83ae7ec118e3d9 Mon Sep 17 00:00:00 2001 From: Meny Issakov Date: Wed, 3 Jan 2018 16:06:40 +0200 Subject: [PATCH 17/20] Support fetching up to 200 smart lists --- marketorestpython/client.py | 18 ++++-------------- setup.py | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 75c8560..706f809 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -3804,25 +3804,15 @@ def delete_custom_activity_type_attribute(self, apiName, attributes): if not result['success'] : raise MarketoException(result['errors'][0]) return result['result'] - def get_smart_lists(self): + def get_smart_lists(self, maxReturn=20): self.authenticate() args = { - 'access_token': self.token + 'access_token': self.token, + 'maxReturn': maxReturn } - result = self._api_call('get', - self.host + "/rest/asset/v1/smartLists.json", args) - if result is None: raise Exception("Empty Response") - if not result['success'] : raise MarketoException(result['errors'][0]) - return result['result'] - def get_leads_from_smart_list(self, id): - self.authenticate() - if id is None: raise ValueError("Invalid argument: required argument id is none.") - args = { - 'access_token': self.token - } result = self._api_call('get', - self.host + "/rest/asset/v1/smartList/" + str(id) + ".json", args) + self.host + "/rest/asset/v1/smartLists.json", args) if result is None: raise Exception("Empty Response") if not result['success'] : raise MarketoException(result['errors'][0]) return result['result'] diff --git a/setup.py b/setup.py index c847a98..e091f88 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='marketorestpython', - version= '0.3.8', + version= '0.3.9', url='https://github.com/jepcastelein/marketo-rest-python', author='Jep Castelein', author_email='jep@castelein.net', From 5349b5abef0c40258291714e2d04c0c5f25eed69 Mon Sep 17 00:00:00 2001 From: Meny Issakov Date: Wed, 3 Jan 2018 16:39:12 +0200 Subject: [PATCH 18/20] Set max return for smart lists --- marketorestpython/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 706f809..ec43630 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -236,7 +236,6 @@ def execute(self, method, *args, **kargs): 'update_custom_activity_type_attribute': self.update_custom_activity_type_attribute, 'delete_custom_activity_type_attribute': self.delete_custom_activity_type_attribute, 'get_smart_lists': self.get_smart_lists, - 'get_leads_from_smart_list': self.get_leads_from_smart_list, } result = method_map[method](*args,**kargs) except MarketoException as e: From ad87660f0b31a435ef832868099ee4eb960294bb Mon Sep 17 00:00:00 2001 From: Meny Issakov Date: Thu, 4 Jan 2018 09:48:40 +0200 Subject: [PATCH 19/20] Add describe named accounts --- marketorestpython/client.py | 13 +++++++++++++ setup.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index ec43630..9776322 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -236,6 +236,7 @@ def execute(self, method, *args, **kargs): 'update_custom_activity_type_attribute': self.update_custom_activity_type_attribute, 'delete_custom_activity_type_attribute': self.delete_custom_activity_type_attribute, 'get_smart_lists': self.get_smart_lists, + 'describe_named_accounts': self.describe_named_accounts, } result = method_map[method](*args,**kargs) except MarketoException as e: @@ -3815,3 +3816,15 @@ def get_smart_lists(self, maxReturn=20): if result is None: raise Exception("Empty Response") if not result['success'] : raise MarketoException(result['errors'][0]) return result['result'] + + def describe_named_accounts(self): + self.authenticate() + args = { + 'access_token': self.token, + } + + result = self._api_call('get', + self.host + "/rest/v1/namedaccounts/describe.json", args) + if result is None: raise Exception("Empty Response") + if not result['success'] : raise MarketoException(result['errors'][0]) + return result['result'] diff --git a/setup.py b/setup.py index e091f88..5b723ce 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='marketorestpython', - version= '0.3.9', + version= '0.4.0', url='https://github.com/jepcastelein/marketo-rest-python', author='Jep Castelein', author_email='jep@castelein.net', From f18a4ff78abb5b656e2170efd8e3e7f8066650d0 Mon Sep 17 00:00:00 2001 From: Meny Issakov Date: Sun, 28 Jan 2018 09:58:46 +0200 Subject: [PATCH 20/20] Treat unhandled KeyError in activities generator. set the NextPullToken to None --- marketorestpython/client.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/marketorestpython/client.py b/marketorestpython/client.py index 9776322..9151433 100644 --- a/marketorestpython/client.py +++ b/marketorestpython/client.py @@ -905,7 +905,7 @@ def get_lead_activities_yield(self, activityTypeIds, nextPageToken=None, sinceDa result = self._api_call('get', self.host + "/rest/v1/activities.json", args) if result is None: raise Exception("Empty Response") if not result['success']: raise MarketoException(result['errors'][0]) - args['nextPageToken'] = result['nextPageToken'] + args['nextPageToken'] = result.get('nextPageToken') if 'result' in result: if untilDatetime is not None: new_result = self.process_lead_activity_until_datetime(result['result'], untilDatetime) diff --git a/setup.py b/setup.py index 5b723ce..57fb389 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='marketorestpython', - version= '0.4.0', + version= '0.4.1', url='https://github.com/jepcastelein/marketo-rest-python', author='Jep Castelein', author_email='jep@castelein.net',