def get_lead(self, email=None): if not email or not isinstance(email, str): raise ValueError('Must supply an email as a non empty string.') body = get_lead.wrap(email) response = self.request(body) if response.status_code == 200: return get_lead.unwrap(response) else: raise Exception(response.text)
def get_lead(self, email=None): if not email or not isinstance(email, (str, unicode)): raise ValueError('Must supply an email as a non empty string.') body = get_lead.wrap(email) response = self.request(body) if response.status_code == 200: return get_lead.unwrap(response) else: raise Exception(response.text)
def get_lead(self, idnum=None, cookie=None, email=None, sfdcleadid=None, leadowneremail=None, sfdcaccountid=None, sfdccontactid=None, sfdcleadownerid=None, sfdcopptyid=None, **kwargs): """ This function retrieves a single lead record from Marketo. If the lead exists based on the input parameters, the lead record attributes will be returned in the result. http://developers.marketo.com/documentation/soap/getlead/ :param idnum: The Marketo ID :param cookie: The value generated by the Munchkin Javascript :param email: The email address associated with the lead :param sfdcleadid: The lead ID from SalesForce :param leadowneremail: The Lead Owner Email :param sfdcaccountid: The Account ID from SalesForce :param sfdccontactid: The Contact ID from SalesForce :param sfdcleadownerid: The Lead owner ID from SalesForce :param sfdcopptyid: The Opportunity ID from SalesForce :param kwargs: For other keytypes in the future... :return: :raise exceptions.unwrap: """ # collect all keyword arguments key_types = locals().copy() del key_types["self"] del key_types["kwargs"] key_types.update(kwargs) for each in key_types.keys(): if not key_types[each]: del key_types[each] if len(key_types) != 1: raise exceptions.MktException( "get_leads() takes exactly 1 keyword argument (%d given)" % len(key_types)) body = get_lead.wrap(*(key_types.items()[0])) response = self.request(body) if response.status_code == 200: return get_lead.unwrap(response.text.encode("utf-8")) else: raise exceptions.unwrap(response.text)
def get_lead(self, email=None, key_value=None, key_type='EMAIL'): if email: key_value = email key_type = 'EMAIL' if not key_value or not isinstance(key_value, (str, unicode)): raise ValueError('Must supply a key_value(i.e. email) as a non empty string.') body = get_lead.wrap(key_value=key_value, key_type=key_type) response = self.request(body) # print response.text if response.status_code == 200: return get_lead.unwrap(response) else: raise Exception(response.text)
def get_lead(self, idnum=None, cookie=None, email=None, sfdcleadid=None, leadowneremail=None, sfdcaccountid=None, sfdccontactid=None, sfdcleadownerid=None, sfdcopptyid=None, **kwargs): """ This function retrieves a single lead record from Marketo. If the lead exists based on the input parameters, the lead record attributes will be returned in the result. http://developers.marketo.com/documentation/soap/getlead/ :param idnum: The Marketo ID :param cookie: The value generated by the Munchkin Javascript :param email: The email address associated with the lead :param sfdcleadid: The lead ID from SalesForce :param leadowneremail: The Lead Owner Email :param sfdcaccountid: The Account ID from SalesForce :param sfdccontactid: The Contact ID from SalesForce :param sfdcleadownerid: The Lead owner ID from SalesForce :param sfdcopptyid: The Opportunity ID from SalesForce :param kwargs: For other keytypes in the future... :return: :raise exceptions.unwrap: """ # collect all keyword arguments key_types = locals().copy() del key_types["self"] del key_types["kwargs"] key_types.update(kwargs) for each in key_types.keys(): if not key_types[each]: del key_types[each] if len(key_types) != 1: raise exceptions.MktException("get_leads() takes exactly 1 keyword argument (%d given)" % len(key_types)) body = get_lead.wrap(*(key_types.items()[0])) response = self.request(body) if response.status_code == 200: return get_lead.unwrap(response.text.encode("utf-8")) else: raise exceptions.unwrap(response.text)
def test_unwrap(self): response = "<root>" \ "<leadRecord>" \ "<Id>101</Id>" \ "<Email>[email protected]</Email>" \ "<leadAttributeList>" \ "<attribute>" \ "<attrName>FirstName</attrName>" \ "<attrType>string</attrType>" \ "<attrValue>John</attrValue>" \ "</attribute>" \ "<attribute>" \ "<attrName>LastName</attrName>" \ "<attrType>string</attrType>" \ "<attrValue>Doe</attrValue>" \ "</attribute>" \ "</leadAttributeList>" \ "</leadRecord>" \ "</root>" lead_record = get_lead.unwrap(response) self.assertEqual(lead_record.id, 101) self.assertEqual(lead_record.email, "*****@*****.**") self.assertEqual(lead_record.attributes, {"FirstName": "John", "LastName": "Doe"})