def test_search_by_name_with_results(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contacts = hatchbuck.search_contacts(firstName="Jack",
                                          lastName="Spratt")
     self.assertEqual(len(contacts), 1)
     self.assertEqual(contacts[0].firstName, "Jack")
     self.assertEqual(contacts[0].lastName, "Spratt")
 def test_add_full_contact(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact = hatchbuck.new_contact()
     contact.add_email(address="*****@*****.**", type="Work")
     contact.set_status(name="Customer")
     contact.firstName = "Alex"
     contact.lastName = "Smith"
     contact.title = "Account Manager"
     contact.company = "ACME Incorporated"
     contact.add_address(street="123 Main Street",
                         city="Anytown",
                         state="AL",
                         zip="55555",
                         country="United States",
                         type="Work")
     contact.timezone = "Pacific Standard Time"
     contact.set_temperature(
         id="QzlHRFRCXzBNN2s3SlppdlBfT2ttVklsRWwzVTFOM3d6SWNJV0xzZkFHODE1")
     contact.add_phone(number="555-555-5555", type="Work")
     contact.add_social_network(address="@pyhatchbuck", type="twitter")
     contact.add_instant_message_address(address="alex.pyhatchbuck",
                                         type="skype")
     contact.add_website(websiteUrl="www.pyhatchbuck.net")
     contact.sourceId = "UnVvT0c0dmxsVVdFYUR1MUZIOTVJeDFXSGxudTBaUG5uZ1QxdVo1aElUVTE1"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(
         contact.contactId,
         "TWlQd3RkSUNKc2h5dXg3UWtFbkZGZE1QZ3R4d0tUM3N0TjI0bDRUMS03MDE1")
     self.assertEqual(contact.addresses[0].street, "123 Main Street")
 def test_search_contact_with_customFields(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact = hatchbuck.search_contacts(contactId=CONTACT_ID)[0]
     self.assertEqual(contact.contactId, CONTACT_ID)
     customFields = contact.customFields
     self.assertEqual(len(customFields), 2)
     self.assertEqual(customFields[0].name, "Company Size")
     self.assertEqual(customFields[0].value, "42")
 def test_search_by_contact_id_with_results(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "NlNfOTJrVFFtd0E4NVhXWGdmSy0ySVdBSHhpZ01hS1NCSFFxMVBTTmlKVTE1"
     contacts = hatchbuck.search_contacts(contactId=contact_id)
     self.assertEqual(len(contacts), 1)
     self.assertEqual(contacts[0].contactId, contact_id)
     self.assertEqual(contacts[0].firstName, "Jack")
     self.assertEqual(contacts[0].lastName, "Spratt")
Ejemplo n.º 5
0
 def test_get_contact_tags_by_email(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_email = "*****@*****.**"
     tags = hatchbuck.get_tags(contact_email)
     self.assertEqual(tags[0].name, "Possible Client")
     self.assertEqual(tags[0].score, 1)
     self.assertEqual(
         tags[0].id,
         "WjFmbDktWGpDVV9OMEtHdjY0Mm83ZVJUT0w5UDVKRTNmN0NRcXdrSGhMMDE1")
Ejemplo n.º 6
0
 def test_stop_contact_campaigns(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.contactId, contact_id)
     success = contact.stop_campaigns([{
         'name': 'Brochure Request Followup'
     }])
     self.assertEqual(success, True)
Ejemplo n.º 7
0
 def test_get_contact_campaigns_by_email(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_email = "*****@*****.**"
     campaigns = hatchbuck.get_campaigns(contact_email)
     self.assertEqual(campaigns[0].name, "Brochure Request Followup")
     self.assertEqual(campaigns[0].step, 0)
     self.assertEqual(
         campaigns[0].id,
         "b1BFUnM1Unh0MDVVOVJEWUc1d0pTM0pUSVY4QS0xOW5GRHRsS05DXzNXazE1")
Ejemplo n.º 8
0
 def test_start_contact_campaigns_by_email(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_email = "*****@*****.**"
     campaigns = [{
         'id':
         'b1BFUnM1Unh0MDVVOVJEWUc1d0pTM0pUSVY4QS0xOW5GRHRsS05DXzNXazE1'
     }]
     success = hatchbuck.start_campaigns(contact_email, campaigns)
     self.assertEqual(success, True)
Ejemplo n.º 9
0
 def test_stop_contact_campaigns_by_email(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_email = "*****@*****.**"
     campaigns = [{
         'id':
         'eVFMdnphWjZSR2UtUllRYlRDYVpOMTd1aDMyZDhDSV9haExIcmpqdU85dzE1'
     }]
     success = hatchbuck.stop_campaigns(contact_email, campaigns)
     self.assertEqual(success, True)
Ejemplo n.º 10
0
 def test_update_contact_temperature(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "TWlQd3RkSUNKc2h5dXg3UWtFbkZGZE1QZ3R4d0tUM3N0TjI0bDRUMS03MDE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.temperature.name, "Hot")
     contact.set_temperature(
         id="M2tyTXVQUmg1NUdKUDViWjkwOFUzQWtPSW9pZzV2STZkS29DeEdDS1ZlSTE1")
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.temperature.name, "On Fire")
 def test_add_custom_fields(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact = hatchbuck.new_contact()
     contact.add_custom_field(name='Company Size', value=42)
     contact.add_custom_field(name='Gender', value='Female')
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(len(contact.customFields), 2)
     self.assertEqual(contact.customFields[0].name, "Company Size")
     self.assertEqual(contact.customFields[0].value, "42")
Ejemplo n.º 12
0
 def test_get_contact_campaigns(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.contactId, contact_id)
     campaigns = contact.get_campaigns()
     self.assertEqual(campaigns[0].name, "Brochure Request Followup")
     self.assertEqual(campaigns[0].step, 0)
     self.assertEqual(
         campaigns[0].id,
         "b1BFUnM1Unh0MDVVOVJEWUc1d0pTM0pUSVY4QS0xOW5GRHRsS05DXzNXazE1")
Ejemplo n.º 13
0
 def test_get_contact_tags(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.contactId, contact_id)
     tags = contact.get_tags()
     self.assertEqual(tags[0].name, "Possible Client")
     self.assertEqual(tags[0].score, 1)
     self.assertEqual(
         tags[0].id,
         "WjFmbDktWGpDVV9OMEtHdjY0Mm83ZVJUT0w5UDVKRTNmN0NRcXdrSGhMMDE1")
Ejemplo n.º 14
0
 def test_update_basic_contact(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.contactId, contact_id)
     contact.firstName = "Jill"
     contact.lastName = "Smith"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.firstName, "Jill")
     self.assertEqual(contact.lastName, "Smith")
 def test_add_basic_contact(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact = hatchbuck.new_contact()
     self.assertEqual(contact.contactId, "")
     contact.add_email(address="*****@*****.**", type="Work")
     contact.set_status(name="Customer")
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(
         contact.contactId,
         "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1")
Ejemplo n.º 16
0
 def save(self):
     from hatchbuck.api import HatchbuckAPI
     new_data = None
     if self.contactId == "":
         new_data = HatchbuckAPI(self.api_key).add_contact(self)
     else:
         new_data = HatchbuckAPI(self.api_key).update_contact(self)
     if new_data != None:
         self.load_dict(new_data)
         return self.contactId != ""
     else:
         return False
 def test_search_by_email_with_results(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contacts = hatchbuck.search_contacts(emails=["*****@*****.**"])
     self.assertEqual(len(contacts), 1)
     self.assertEqual(contacts[0].firstName, "Jack")
     self.assertEqual(contacts[0].lastName, "Spratt")
     self.assertEqual(contacts[0].salesRep.username, "jakesen")
     self.assertEqual(contacts[0].status.name, "Lead")
     self.assertEqual(contacts[0].emails[0].address, "*****@*****.**")
     self.assertEqual(contacts[0].emails[0].type, "Work")
     self.assertEqual(contacts[0].subscribed, True)
     self.assertEqual(contacts[0].timezone, "Central Standard Time")
Ejemplo n.º 18
0
 def test_delete_contact_tags(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.contactId, contact_id)
     success = contact.delete_tags([{'name': 'Possible Client'}])
     self.assertEqual(success, True)
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(len(contact.tags), 1)
     self.assertEqual(contact.tags[0].name, "Old Contact List")
     self.assertEqual(contact.tags[0].score, 3)
     self.assertEqual(
         contact.tags[0].id,
         "elZDN1dSa3ZmSDJ1MjNrRVBabDhoNmdKbmthUmY1YTVOYkx5TmhwYVZfSTE1")
Ejemplo n.º 19
0
 def test_start_contact_campaigns(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.contactId, contact_id)
     success = contact.start_campaigns([{'name': 'Trial Request Followup'}])
     self.assertEqual(success, True)
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.campaigns[0].name,
                      "Brochure Request Followup")
     self.assertEqual(contact.campaigns[0].step, 0)
     self.assertEqual(contact.campaigns[0].id, "958650")
     self.assertEqual(contact.campaigns[1].name, "Trial Request Followup")
     self.assertEqual(contact.campaigns[1].step, 0)
     self.assertEqual(contact.campaigns[1].id, "958651")
Ejemplo n.º 20
0
 def test_delete_contact_tags_by_email(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_email = "*****@*****.**"
     success = hatchbuck.delete_tags(contact_email, [{
         'id':
         'elZDN1dSa3ZmSDJ1MjNrRVBabDhoNmdKbmthUmY1YTVOYkx5TmhwYVZfSTE1'
     }])
     self.assertEqual(success, True)
     contact = hatchbuck.search_contacts(emails=[contact_email])[0]
     self.assertEqual(len(contact.tags), 1)
     self.assertEqual(contact.tags[0].name, "Possible Client")
     self.assertEqual(contact.tags[0].score, 1)
     self.assertEqual(
         contact.tags[0].id,
         "WjFmbDktWGpDVV9OMEtHdjY0Mm83ZVJUT0w5UDVKRTNmN0NRcXdrSGhMMDE1")
Ejemplo n.º 21
0
 def test_update_contact_phone(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "TWlQd3RkSUNKc2h5dXg3UWtFbkZGZE1QZ3R4d0tUM3N0TjI0bDRUMS03MDE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.phones[0].number, "555-555-5555")
     self.assertEqual(
         contact.phones[0].id,
         "YzNZTGhZRjdadlNRMzl6Qlo1YkY3X1JmX09DNHp0RDZJT1lrMGl6NjJETTE1")
     contact.phones[0].number = "555-555-1234"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.phones[0].number, "555-555-1234")
     self.assertEqual(
         contact.phones[0].id,
         "YzNZTGhZRjdadlNRMzl6Qlo1YkY3X1JmX09DNHp0RDZJT1lrMGl6NjJETTE1")
Ejemplo n.º 22
0
 def test_update_contact_address(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "TWlQd3RkSUNKc2h5dXg3UWtFbkZGZE1QZ3R4d0tUM3N0TjI0bDRUMS03MDE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.addresses[0].street, "123 Main Street")
     self.assertEqual(
         contact.addresses[0].id,
         "YlFxUEZPR3M5MGVDSW9XXzhEMDhqVmNVdzVHTUU3U2duT21lYk9tMnU1YzE1")
     contact.addresses[0].street = "555 Commerce Ave"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.addresses[0].street, "555 Commerce Ave")
     self.assertEqual(
         contact.addresses[0].id,
         "YlFxUEZPR3M5MGVDSW9XXzhEMDhqVmNVdzVHTUU3U2duT21lYk9tMnU1YzE1")
Ejemplo n.º 23
0
 def test_update_contact_social_networks(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "TWlQd3RkSUNKc2h5dXg3UWtFbkZGZE1QZ3R4d0tUM3N0TjI0bDRUMS03MDE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.socialNetworks[0].address, "@pyhatchbuck")
     self.assertEqual(
         contact.socialNetworks[0].id,
         "dGNZT0xWVVJSQlBKOWxLdnBlZS01MWdUQkxadk1XM2p1cG8yRWFhNjAyWTE1")
     contact.socialNetworks[0].address = "@alex.smith.pyhatchbuck"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.socialNetworks[0].address,
                      "@alex.smith.pyhatchbuck")
     self.assertEqual(
         contact.socialNetworks[0].id,
         "dGNZT0xWVVJSQlBKOWxLdnBlZS01MWdUQkxadk1XM2p1cG8yRWFhNjAyWTE1")
Ejemplo n.º 24
0
 def test_update_contact_website(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "TWlQd3RkSUNKc2h5dXg3UWtFbkZGZE1QZ3R4d0tUM3N0TjI0bDRUMS03MDE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.website[0].websiteUrl, "www.pyhatchbuck.net")
     self.assertEqual(
         contact.website[0].id,
         "VC1Hcl9yeXVucjFDdVViRkY4RXA2UzNkcnVBeFQtSEhmUkdIWEZPdnp5STE1")
     contact.website[0].websiteUrl = "www.pyhatchbuck-rocks.net"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.website[0].websiteUrl,
                      "www.pyhatchbuck-rocks.net")
     self.assertEqual(
         contact.website[0].id,
         "VC1Hcl9yeXVucjFDdVViRkY4RXA2UzNkcnVBeFQtSEhmUkdIWEZPdnp5STE1")
Ejemplo n.º 25
0
 def test_update_contact_email(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.emails[0].address, "*****@*****.**")
     self.assertEqual(
         contact.emails[0].id,
         "SXU4LVZRWkFzM3UtMnZ4UGtrRTJtMmgyQWV2dnpUV19tNjFBaVFqRnk2QTE1")
     contact.emails[0].address = "*****@*****.**"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.emails[0].address,
                      "*****@*****.**")
     self.assertEqual(
         contact.emails[0].id,
         "SXU4LVZRWkFzM3UtMnZ4UGtrRTJtMmgyQWV2dnpUV19tNjFBaVFqRnk2QTE1")
Ejemplo n.º 26
0
 def test_update_contact_instant_messages(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "TWlQd3RkSUNKc2h5dXg3UWtFbkZGZE1QZ3R4d0tUM3N0TjI0bDRUMS03MDE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.instantMessaging[0].address,
                      "alex.pyhatchbuck")
     self.assertEqual(
         contact.instantMessaging[0].id,
         "OWdYcHkzcVBwRE4zZEtzTEhJbFc4SVpLTm91WjJWd2tQUWxXcm9TdjdHazE1")
     contact.instantMessaging[0].address = "as.pyhatchbuck"
     success = contact.save()
     self.assertEqual(success, True)
     self.assertEqual(contact.instantMessaging[0].address, "as.pyhatchbuck")
     self.assertEqual(
         contact.instantMessaging[0].id,
         "OWdYcHkzcVBwRE4zZEtzTEhJbFc4SVpLTm91WjJWd2tQUWxXcm9TdjdHazE1")
Ejemplo n.º 27
0
 def get_tags(self):
     from hatchbuck.api import HatchbuckAPI
     updated_tags = HatchbuckAPI(self.api_key).get_tags(self.contactId)
     if updated_tags != None:
         self.tags = updated_tags
         return self.tags
     else:
         return None
Ejemplo n.º 28
0
 def get_campaigns(self):
     from hatchbuck.api import HatchbuckAPI
     updated_campaigns = HatchbuckAPI(self.api_key).get_campaigns(
         self.contactId)
     if updated_campaigns != None:
         self.campaigns = updated_campaigns
         return self.campaigns
     else:
         return None
Ejemplo n.º 29
0
 def test_add_contact_tags(self):
     hatchbuck = HatchbuckAPI(self.test_api_key)
     contact_id = "d1F4Tm1tcUxVRmdFQmVIT3lhVjNpaUtxamprakk5S3JIUGRmVWtHUXJaRTE1"
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.contactId, contact_id)
     success = contact.add_tags([{'name': 'Old Contact List'}])
     self.assertEqual(success, True)
     contact = hatchbuck.search_contacts(contactId=contact_id)[0]
     self.assertEqual(contact.tags[0].name, "Possible Client")
     self.assertEqual(contact.tags[0].score, 1)
     self.assertEqual(
         contact.tags[0].id,
         "WjFmbDktWGpDVV9OMEtHdjY0Mm83ZVJUT0w5UDVKRTNmN0NRcXdrSGhMMDE1")
     self.assertEqual(contact.tags[1].name, "Old Contact List")
     self.assertEqual(contact.tags[1].score, 3)
     self.assertEqual(
         contact.tags[1].id,
         "elZDN1dSa3ZmSDJ1MjNrRVBabDhoNmdKbmthUmY1YTVOYkx5TmhwYVZfSTE1")
Ejemplo n.º 30
0
 def stop_campaigns(self, campaigns):
     from hatchbuck.api import HatchbuckAPI
     return HatchbuckAPI(self.api_key).stop_campaigns(
         self.contactId, campaigns)