Ejemplo n.º 1
0
	def create(self, audId=1):
		url = '/audiences/%s/blasts.xml' % str(audId)
		headers = {'Content-type':'application/xml'}
		##data = etree.tostring(self.xml, with_comments=False)
		data = self.tostring()
		resp = connection._request(url, 'POST', data, headers)
		return resp
Ejemplo n.º 2
0
	def create(self, audID=1):
		url = '/audiences/%d/lists.xml' % int(audID)
		data = etree.tostring(self.root, pretty_print=False)
		headers = {'Content-type':'application/xml'}
		resp = connection._request(url, 'POST', data, headers)
		'''print resp.status
		for header in resp.getheaders():
			if header[0] == 'location': print header[1]; break'''
		return resp
Ejemplo n.º 3
0
	def test(self, recipients, audId=1):
		url = '/audiences/%s/blasts/test.xml' % str(audId)
		headers = {'Content-type':'application/xml'}
		# handle recipients
		if type(recipients) != str: recipients = ','.join(recipients)
		toNode = self.xml.xpath('/blast/to')[0]
		etree.strip_elements(toNode, 'audience-id', 'include-lists')
		toNode.text = recipients
		# send request
		##data = etree.tostring(self.xml, with_comments=False)
		data = self.tostring()
		resp = connection._request(url, 'POST', data, headers)
		return resp
def test_req():
	return connection._request('/audiences.xml', 'GET')
Ejemplo n.º 5
0
def destroy(listID, audID=1):
	url = '/audiences/%d/lists/%d.xml' % (int(audID), int(listID))
	#print url
	resp = connection._request(url, 'DELETE')
	#print resp.status, resp.reason
	return resp
def show(importId, audId=1):
	url = '/audiences/%d/imports/%d.xml' % (audId, importId)
	resp = connection._request(url, 'GET')
	if resp.status < 300 and resp.status >= 200:
		return connection.Element(etree.fromstring(resp.read()))
Ejemplo n.º 7
0
def destroy(blast_id, aud_id=1):
	url = '/audiences/%s/blasts/%s.xml' % (str(aud_id), str(blast_id))
	resp = connection._request(url, 'DELETE')
	return resp
Ejemplo n.º 8
0
def show(blast_id, aud_id=1):
	url = '/audiences/%s/blasts/%s.xml' % (str(aud_id), str(blast_id))
	resp = connection._request(url, 'GET')
	return resp
Ejemplo n.º 9
0
def index(data={}, aud_id=1, **kwargs):
	data = dict(data.items() + kwargs.items())
	url = '/audiences/%s/blasts.xml' % str(aud_id)
	if data: url += '?%s' % urllib.urlencode(data)
	resp = connection._request(url, 'GET')
	return resp
def index(blastID, data={'per_page':10000, 'page':1}, **kwargs):
	data = dict(data.items() + kwargs.items())
	url = '/blasts/%d/views.xml' % int(blastID)
	resp = connection._request(url , 'GET', data)
	return resp