@@ -35,7 +35,8 @@ def __init__(self, munchkin_id, client_id=None, client_secret=None, api_limit=No
3535 self .API_LIMIT = api_limit
3636 self .max_retry_time = max_retry_time
3737 if requests_timeout is not None :
38- error_message = "requests_timeout must be a postive float or int, or a two-element tuple of positive floats or ints"
38+ error_message = "requests_timeout must be a positive float or int, or a two-element tuple of positive " \
39+ "floats or ints"
3940 if isinstance (requests_timeout , int ) or isinstance (requests_timeout , float ):
4041 assert requests_timeout > 0 , error_message
4142 self .requests_timeout = requests_timeout
@@ -48,6 +49,8 @@ def __init__(self, munchkin_id, client_id=None, client_secret=None, api_limit=No
4849 self .requests_timeout = requests_timeout
4950 else :
5051 raise AssertionError (error_message )
52+ else :
53+ self .requests_timeout = None
5154
5255 def _api_call (self , method , endpoint , * args , ** kwargs ):
5356 request = HttpLib (max_retry_time_conf = self .max_retry_time , requests_timeout = self .requests_timeout )
@@ -79,6 +82,7 @@ def execute(self, method, *args, **kargs):
7982 'associate_lead' : self .associate_lead ,
8083 'push_lead' : self .push_lead ,
8184 'merge_lead' : self .merge_lead ,
85+ 'get_smart_campaigns_by_lead_id' : self .get_smart_campaigns_by_lead_id ,
8286 'get_lead_partitions' : self .get_lead_partitions ,
8387 'create_list' : self .create_list ,
8488 'update_list' : self .update_list ,
@@ -655,6 +659,19 @@ def merge_lead(self, id, leadIds, mergeInCRM=False):
655659 # there is no 'result' node returned in this call
656660 return result ['success' ]
657661
662+ def get_smart_campaigns_by_lead_id (self , lead_id ):
663+ self .authenticate ()
664+ if lead_id is None :
665+ raise ValueError ("Invalid argument: required argument lead_id is none." )
666+ args = {
667+ 'access_token' : self .token
668+ }
669+ result = self ._api_call (
670+ 'get' , '{}/rest/v1/leads/{}/smartCampaignMembership.json' .format (self .host , lead_id ), args )
671+ if result is None :
672+ raise Exception ("Empty Response" )
673+ return result ['result' ]
674+
658675 # --------- LEAD PARTITIONS ---------
659676
660677 def get_lead_partitions (self ):
@@ -2386,8 +2403,6 @@ def get_emails_yield(self, offset=0, maxReturn=20, status=None, folderId=None, f
23862403 yield result
23872404 else :
23882405 yield result ['result' ]
2389- if len (result ['result' ]) < maxReturn :
2390- break
23912406 else :
23922407 break
23932408 offset += maxReturn
0 commit comments