示例#1
0
def search(email, vid):
    contacts_client = ContactsClient(api_key=settings.API_KEY)

    if email != None:
        contact = contacts_client.get_contact_by_email(email)
        print(contact)

    if vid != None:
        contact = contacts_client.get_contact_by_id(vid)
        click.echo(json.dumps(contact))
示例#2
0
    def contacts(self):
        """returns a hubspot3 contacts client"""
        from hubspot3.contacts import ContactsClient

        return ContactsClient(**self.auth, **self.options)
示例#3
0
TWITTER_CONSUMER_KEY = os.environ['PIS_TWITTER_CONSUMER_KEY']
TWITTER_CONSUMER_SECRET = os.environ['PIS_TWITTER_CONSUMER_SECRET']
TWITTER_ACCESS_TOKEN = os.environ['PIS_TWITTER_ACCESS_TOKEN']
TWITTER_ACCESS_SECRET = os.environ['PIS_TWITTER_ACCESS_SECRET']

HUBSPOT_TOKEN = os.environ['PIS_HUBSPOT_HAPIKEY']

# Twitter Client Setup
auth = tweepy.OAuthHandler(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET)
auth.set_access_token(TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_SECRET)

TwitterClient = tweepy.API(auth)

# HubSpot Client Setup
HubspotContactsClient = ContactsClient(api_key=HUBSPOT_TOKEN)
HubspotEngagementsClient = EngagementsClient(api_key=HUBSPOT_TOKEN)

# Get mentioned tweets
twitter_mentions = TwitterClient.mentions_timeline()

print(twitter_mentions)

# Get hubspot contacts
# hubspot_contacts = HubspotContactsClient.get_all()

for mention in twitter_mentions:
    # hubspot_contact = HubspotContactsClient.get_contact_by_email(mention.user.name)

    # if not hubspot_contact:
    data = [
示例#4
0
def deleteContact(vid):
    client = ContactsClient(api_key=settings.API_KEY)
    click.echo('Deleting: %s' % (vid))
    result = client.delete_a_contact(vid)
    click.echo(json.dumps(result))
示例#5
0
"""
testing hubspot3.contacts
"""
import pytest
from hubspot3.contacts import ContactsClient
from hubspot3.error import HubspotConflict, HubspotNotFound, HubspotBadRequest
from hubspot3.test.globals import TEST_KEY

CONTACTS = ContactsClient(TEST_KEY)

# since we need to have an id to submit and to attempt to get a contact,
# we need to be hacky here and fetch one upon loading this file.
BASE_CONTACT = CONTACTS.get_all(limit=1)[0]


def test_create_contact():
    """
    attempts to create a contact via the demo api
    :see: https://developers.hubspot.com/docs/methods/contacts/create_contact
    """
    with pytest.raises(HubspotBadRequest):
        CONTACTS.create(data={})

    with pytest.raises(HubspotConflict):
        CONTACTS.create(
            data={
                "properties": [
                    {
                        "property": "email",
                        "value": BASE_CONTACT["email"]
                    },