Esempio n. 1
0
def cc_indiegogo_signup(request):
    if request.method == "POST":
        constantcontact = ConstantContact(settings.CONSTANT_CONTACT_API_KEY, settings.CONSTANT_CONTACT_ACCESS_TOKEN, settings.CONSTANT_CONTACT_API_URL)
        contact = Contact()
        contact.add_list_id(settings.CONSTANT_CONTACT_LIST_ID)
        contact.set_email_address(request.POST['email'])
        response = constantcontact.post_contacts(contact)

        if response.has_key('error_key'):
            return HttpResponse(response['error_key'])
        else:
            return HttpResponse('201')
Esempio n. 2
0
def cc_indiegogo_signup(request):
    if request.method == "POST":
        constantcontact = ConstantContact(
            settings.CONSTANT_CONTACT_API_KEY,
            settings.CONSTANT_CONTACT_ACCESS_TOKEN,
            settings.CONSTANT_CONTACT_API_URL)
        contact = Contact()
        contact.add_list_id(settings.CONSTANT_CONTACT_LIST_ID)
        contact.set_email_address(request.POST['email'])
        response = constantcontact.post_contacts(contact)

        if response.has_key('error_key'):
            return HttpResponse(response['error_key'])
        else:
            return HttpResponse('201')
    def test_cont_lists(self):
        contact = Contact()

        lists = [{'id': '123'}, {'id': '456'}, {'id': '789'}]
        contact_list = Contact_List({'id': '321'})

        contact.set_lists(lists)

        self.assertEqual(len(contact.get_lists()), 3)
        self.assertEqual(contact.get_list(2).get_id(), '789')

        contact.add_list(contact_list)
        contact.add_list_id('654')
        contact.remove_list_id('123')
        contact.remove_list(1)

        self.assertEqual(contact.get_list(0).get_id(), '456')
        self.assertEqual(contact.get_list(2).get_id(), '654')
        self.assertEqual(len(contact.get_lists()), 3)

        contact.remove_all_lists()

        self.assertEqual(contact.get_lists(), None)
    def test_cont_lists(self):
        contact = Contact()

        lists = [{"id": "123"}, {"id": "456"}, {"id": "789"}]
        contact_list = Contact_List({"id": "321"})

        contact.set_lists(lists)

        self.assertEqual(len(contact.get_lists()), 3)
        self.assertEqual(contact.get_list(2).get_id(), "789")

        contact.add_list(contact_list)
        contact.add_list_id("654")
        contact.remove_list_id("123")
        contact.remove_list(1)

        self.assertEqual(contact.get_list(0).get_id(), "456")
        self.assertEqual(contact.get_list(2).get_id(), "654")
        self.assertEqual(len(contact.get_lists()), 3)

        contact.remove_all_lists()

        self.assertEqual(contact.get_lists(), None)
Esempio n. 5
0
print '[test] get_next_page'
response = constantcontact.next_page(next_page)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

contact_lists = constantcontact.get_lists()

for l in contact_lists:
    if l.get_name().lower() == 'general interest':
        list_id = l.get_id()
        break

print '[test] post_contacts'
contact = Contact()
contact.add_list_id(list_id)
contact.add_list_id('1481737116')
contact.set_email_address(test_email)
response = constantcontact.post_contacts(contact)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

print '[test] get_contact by email'
response = constantcontact.get_contacts(email = test_email)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')
contact = response['results'][0]
contact_id = contact.get_id()