From 0787274eab961f4a0fbdbc1df5935bae133d9b33 Mon Sep 17 00:00:00 2001 From: recomputing Date: Wed, 28 Dec 2011 12:37:18 -0500 Subject: [PATCH] Adding code for retrieve_lead to follow api --- hapi/leads.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hapi/leads.py b/hapi/leads.py index 5fd8178..72ad26a 100644 --- a/hapi/leads.py +++ b/hapi/leads.py @@ -104,13 +104,18 @@ def get_leads(self, *guids, **options): return leads def retrieve_lead(self, *guid, **options): - """path could be - https://hubapi.com/leads/v1/lead/(GUID)?hapikey=(your_API_KEY) - https://hubapi.com/leads/v1/lead?hapikey=(your_API_KEY)&conversionEventGuid=(event_guid) - https://hubapi.com/leads/v1/lead?hapikey=(your_API_KEY)&userToken=(user_token) - """ - - return self._call('lead/%s' % guid, **options) + cur_guid = guid or '' + params = {} + for key in options: + params[key] = options[key] + """ Set guid to -1 as default for not finding a user """ + lead = {'guid' : '-1'} + """ wrap lead call so that it doesn't error out when not finding a lead """ + try: + lead = self._call('lead/%s' % cur_guid, params, **options) + except: + """ no lead here """ + return lead def update_lead(self, guid, update_data=None, **options):