How to use hubspot3 - 10 common examples

To help you get started, we’ve selected a few hubspot3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jpetrucciani / hubspot3 / hubspot3 / tickets.py View on Github external
"""
hubspot tickets api
"""
from hubspot3.base import BaseClient
from hubspot3.utils import get_log
from typing import Dict, List


TICKETS_API_VERSION = "1"


class TicketsClient(BaseClient):
    """
    hubspot3 Tickets client
    :see: https://developers.hubspot.com/docs/methods/tickets/tickets-overview
    """

    def __init__(self, *args, **kwargs):
        """initialize a tickets client"""
        super(TicketsClient, self).__init__(*args, **kwargs)
        self.log = get_log("hubspot3.tickets")

    def _get_path(self, subpath):
        """tickets subpath generator"""
        return "crm-objects/v{}/{}".format(TICKETS_API_VERSION, subpath)

    def create(
        self, pipeline: str, stage: str, properties: Dict = None, **options
github jpetrucciani / hubspot3 / hubspot3 / contact_lists.py View on Github external
"""
hubspot contact lists api
"""
from hubspot3.base import BaseClient
from hubspot3.utils import get_log


CONTACT_LISTS_API_VERSION = "1"


class ContactListsClient(BaseClient):
    """
    The hubspot3 Contact Lists client uses the _make_request method to call the API for data.
    It returns a python object translated from the json returned
    """

    def __init__(self, *args, **kwargs):
        super(ContactListsClient, self).__init__(*args, **kwargs)
        self.log = get_log("hubspot3.contact_lists")

    def _get_path(self, subpath):
        return "contacts/v{}/{}".format(
            self.options.get("version") or CONTACT_LISTS_API_VERSION, subpath
        )

    def get_contact_lists(self, **options):
        """Returns all of the contact lists"""
github jpetrucciani / hubspot3 / hubspot3 / prospects.py View on Github external
"""
hubspot prospects client
"""
from hubspot3.base import BaseClient


PROSPECTS_API_VERSION = "v1"


class ProspectsClient(BaseClient):
    """
    Python client for the HubSpot Prospects API.
    This client provides convenience methods for the HubSpot Prospects API.
    It is a work in progress, and contributions are welcome.
    """

    def _get_path(self, subpath):
        """get the full api url for the given subpath on this client"""
        return "prospects/{}/{}".format(PROSPECTS_API_VERSION, subpath)

    def get_prospects(self, offset=None, orgoffset=None, limit=None):
        """
        Return the prospects for the current API key.

        Optionally start the result list at the given offset.
github jpetrucciani / hubspot3 / hubspot3 / blog.py View on Github external
"""
hubspot blog api client
"""
import json
from hubspot3.base import BaseClient
from typing import Dict


BLOG_API_VERSION = "2"
COMMENTS_API_VERSION = "3"
TOPICS_API_VERSION = "3"


class BlogClient(BaseClient):
    """
    provides a client for accessing hubspot blog info
    """

    def _get_path(self, subpath: str) -> str:
        return "content/api/v{}/{}".format(BLOG_API_VERSION, subpath)

    def get_blogs(self, **options):
        return self._call("blogs", **options)

    def get_blog_info(self, blog_guid, **options):
        return self._call("blogs/{}".format(blog_guid), **options)

    def get_posts(self, blog_guid: str, **options) -> Dict:
        if "params" not in options:
            options["params"] = {}
github jpetrucciani / hubspot3 / hubspot3 / companies.py View on Github external
"""
hubspot companies api
"""
from hubspot3.base import BaseClient
from hubspot3.utils import prettify, get_log
from typing import List, Dict, Optional, Union


COMPANIES_API_VERSION = "2"


class CompaniesClient(BaseClient):
    """
    hubspot3 Companies client
    :see: https://developers.hubspot.com/docs/methods/companies/companies-overview
    """

    def __init__(self, *args, **kwargs):
        super(CompaniesClient, self).__init__(*args, **kwargs)
        self.log = get_log("hubspot3.companies")

    def _get_path(self, subpath: str) -> str:
        """get the full api url for the given subpath on this client"""
        return "companies/v{}/{}".format(
            self.options.get("version") or COMPANIES_API_VERSION, subpath
        )

    def create(self, data: Dict = None, **options) -> Dict:
github jpetrucciani / hubspot3 / hubspot3 / base.py View on Github external
def __init__(
        self,
        api_key: str = None,
        access_token: str = None,
        refresh_token: str = None,
        client_id: str = None,
        client_secret: str = None,
        timeout: int = 10,
        mixins: List = None,
        api_base: str = "api.hubapi.com",
        debug: bool = False,
        disable_auth: bool = False,
        **extra_options
    ) -> None:
        super(BaseClient, self).__init__()
        # reverse so that the first one in the list because the first parent
        if not mixins:
            mixins = []
        mixins.reverse()
        for mixin_class in mixins:
            if mixin_class not in self.__class__.__bases__:
                self.__class__.__bases__ = (mixin_class,) + self.__class__.__bases__

        self.api_key = api_key
        self.access_token = access_token
        self.refresh_token = refresh_token
        self.client_id = client_id
        self.client_secret = client_secret
        self.log = utils.get_log("hubspot3")
        if not disable_auth:
            if self.api_key and self.access_token:
github jpetrucciani / hubspot3 / hubspot3 / __main__.py View on Github external
def _discover_clients(self, hubspot3: Hubspot3) -> Dict[str, BaseClient]:
        """Find all client instance properties on the given Hubspot3 object."""
        clients = {}
        for attr in dir(hubspot3.__class__):
            # Find properties by searching the class first - that way, a call
            # to getattr doesn't run the properties code on the object.
            if (
                attr.startswith("_")
                or attr in self.IGNORED_PROPERTIES
                or not isinstance(getattr(hubspot3.__class__, attr), property)
            ):
                continue
            client = getattr(hubspot3, attr)
            if isinstance(client, BaseClient):
                clients[attr] = client
        return clients
github jpetrucciani / hubspot3 / hubspot3 / crm_associations.py View on Github external
PARENT_COMPANY_TO_CHILD_COMPANY = 13
    CHILD_COMPANY_TO_PARENT_COMPANY = 14
    CONTACT_TO_TICKET = 15
    TICKET_TO_CONTACT = 16
    TICKET_TO_ENGAGEMENT = 17
    ENGAGEMENT_TO_TICKET = 18
    DEAL_TO_LINE_ITEM = 19
    LINE_ITEM_TO_DEAL = 20
    COMPANY_TO_TICKET = 25
    TICKET_TO_COMPANY = 26
    DEAL_TO_TICKET = 27
    TICKET_TO_DEAL = 28
    OWNER_TO_COMPANY = 41


class CRMAssociationsClient(BaseClient):
    """
    Associations extension for Associations API endpoint
    :see: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview
    """

    def __init__(self, *args, **kwargs):
        super(CRMAssociationsClient, self).__init__(*args, **kwargs)
        self.log = get_log("hubspot3.crm_associations")

    def _get_path(self, subpath: str) -> str:
        return "crm-associations/v{}/{}".format(
            self.options.get("version") or ASSOCIATIONS_API_VERSION, subpath
        )

    def get(self, object_id: str, definition: Union[Definitions, int]):
        """
github jpetrucciani / hubspot3 / hubspot3 / workflows.py View on Github external
"""
hubspot workflows api
"""
from hubspot3.base import BaseClient
from hubspot3.utils import get_log

WORKFLOWS_API_VERSION = "3"


class WorkflowsClient(BaseClient):
    """
    The hubspot3 Workflows client uses the _make_request method to call the
    API for data.  It returns a python object translated from the json returned
    """

    def __init__(self, *args, **kwargs):
        """initialize a workflows client"""
        super(WorkflowsClient, self).__init__(*args, **kwargs)
        self.log = get_log("hubspot3.workflows")

    def _get_path(self, subpath):
        return "automation/v{}/{}".format(WORKFLOWS_API_VERSION, subpath)

    def get_all_workflow_ids(self, **options):
        """
        Get all workflow IDs
github jpetrucciani / hubspot3 / hubspot3 / email_subscription.py View on Github external
"""
hubspot email subscription api
"""
from typing import Dict, Iterable, Mapping
from hubspot3.base import BaseClient
from hubspot3.utils import get_log


EMAIL_SUBSCRIPTION_API_VERSION = "1"


class EmailSubscriptionClient(BaseClient):
    """
    The hubspot3 Email Subscription client uses the _make_request method to call the
    API for data.  It returns a python object translated from the json returned
    """

    class OptState:
        """opt state enum"""

        OPT_IN = "OPT_IN"
        OPT_OUT = "OPT_OUT"
        NOT_OPTED = "NOT_OPTED"

    class LegalBasis:
        """legal basis enum"""

        CONSENT_WITH_NOTICE = "CONSENT_WITH_NOTICE"