Пример #1
0
    def __init__(
        self,
        api_key=None,
        timeout=10,
        mixins=None,
        access_token=None,
        refresh_token=None,
        client_id=None,
        **extra_options
    ):
        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 or extra_options.get("api_key")
        self.access_token = access_token or extra_options.get("access_token")
        self.refresh_token = refresh_token or extra_options.get("refresh_token")
        self.client_id = client_id or extra_options.get("client_id")
        self.log = utils.get_log("hubspot3")
        if self.api_key and self.access_token:
            raise Exception("Cannot use both api_key and access_token.")
        if not (self.api_key or self.access_token or self.refresh_token):
            raise Exception("Missing required credentials.")
        self.options = {"api_base": "api.hubapi.com", "debug": False}
        self.options["timeout"] = timeout
        self.options.update(extra_options)
        self._prepare_connection_type()
Пример #2
0
    def __init__(self,
                 api_key=None,
                 timeout=10,
                 mixins=[],
                 access_token=None,
                 refresh_token=None,
                 client_id=None,
                 **extra_options):
        super(BaseClient, self).__init__()
        # reverse so that the first one in the list because the first parent
        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 or extra_options.get('api_key')
        self.access_token = access_token or extra_options.get('access_token')
        self.refresh_token = refresh_token or extra_options.get(
            'refresh_token')
        self.client_id = client_id or extra_options.get('client_id')
        self.log = utils.get_log('hubspot3')
        if self.api_key and self.access_token:
            raise Exception("Cannot use both api_key and access_token.")
        if not (self.api_key or self.access_token or self.refresh_token):
            raise Exception("Missing required credentials.")
        self.options = {'api_base': 'api.hubapi.com'}
        if not _PYTHON25:
            self.options['timeout'] = timeout
        self.options.update(extra_options)
        self._prepare_connection_type()
Пример #3
0
    def __init__(self,
                 api_key: str = None,
                 access_token: str = None,
                 refresh_token: str = None,
                 client_id: str = None,
                 client_secret: str = None,
                 oauth2_token_getter: Optional[
                     Callable[[Literal["access_token", "refresh_token"], str],
                              str]] = None,
                 oauth2_token_setter: Optional[Callable[
                     [Literal["access_token",
                              "refresh_token"], str, str], None]] = 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
        # These are used as fallbacks if there aren't setters/getters, or if no remote tokens can be
        # found. The properties without `__` prefixes should generally be used instead of these.
        self.__access_token = access_token
        self.__refresh_token = refresh_token
        self.client_id = client_id
        self.client_secret = client_secret
        if (oauth2_token_getter is None) != (oauth2_token_setter is None):
            raise HubspotBadConfig(
                "You must either specify both the oauth2 token setter and getter, or neither."
            )
        self.oauth2_token_getter = oauth2_token_getter
        self.oauth2_token_setter = oauth2_token_setter
        self.log = utils.get_log("hubspot3")
        if not disable_auth:
            if self.api_key and self.access_token:
                raise HubspotBadConfig(
                    "Cannot use both api_key and access_token.")
            if not (self.api_key or self.access_token or self.refresh_token):
                raise HubspotNoConfig("Missing required credentials.")
        self.options = {
            "api_base": api_base,
            "debug": debug,
            "disable_auth": disable_auth,
            "timeout": timeout,
        }
        self.options.update(extra_options)
        self._prepare_connection_type()
Пример #4
0
 def __init__(self, *args, **kwargs):
     """initialize a contacts client"""
     # Since this client is used to generate tokens for authentication, it does not require
     # authentication itself.
     kwargs["disable_auth"] = True
     super(OAuth2Client, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.oauth2")
     self.options["content_type"] = "application/x-www-form-urlencoded"
     # Make sure that certain credentials that wouldn't be used anyway are not set. Not having
     # an access token will also make sure that the `_call_raw` implementation does not try to
     # refresh access tokens on its own.
     self.api_key = None
     self.access_token = None
Пример #5
0
    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:
                raise HubspotBadConfig(
                    "Cannot use both api_key and access_token.")
            if not (self.api_key or self.access_token or self.refresh_token):
                raise HubspotNoConfig("Missing required credentials.")
        self.options = {
            "api_base": api_base,
            "debug": debug,
            "disable_auth": disable_auth,
            "timeout": timeout,
        }
        self.options.update(extra_options)
        self._prepare_connection_type()
Пример #6
0
 def __init__(self, *args, **kwargs):
     super(ContactListsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.contact_lists")
Пример #7
0
 def __init__(self, *args, **kwargs):
     super(PropertyGroupsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.properties")
Пример #8
0
 def __init__(self, *args, **kwargs):
     super(DealsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.deals")
Пример #9
0
 def __init__(self, *args, **kwargs):
     super(PipelinesClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.crm-pipelines")
Пример #10
0
 def __init__(self, *args, **kwargs):
     super(CompaniesClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.companies")
Пример #11
0
 def __init__(self, *args, **kwargs) -> None:
     """initialize a products client"""
     super(ProductsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.products")
Пример #12
0
 def __init__(self, *args, **kwargs):
     """initialize an ecommerce bridge client"""
     super(EcommerceBridgeClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.ecommerce_bridge")
Пример #13
0
 def __init__(self, *args, **kwargs):
     super(EngagementsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.engagements")
Пример #14
0
 def __init__(self, *args, **kwargs):
     super(LeadsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.leads")
Пример #15
0
 def __init__(self, *args, **kwargs):
     """initialize a workflows client"""
     super(WorkflowsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.workflows")
Пример #16
0
 def __init__(self, *args, **kwargs):
     """initialize a tickets client"""
     super(TicketsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.tickets")
Пример #17
0
 def __init__(self, *args, **kwargs):
     """initialize an email subscription client"""
     super(EmailSubscriptionClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.email_subscription")
Пример #18
0
 def __init__(self, *args, **kwargs):
     """initialize an email events client"""
     super(EmailEventsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.email_events")
Пример #19
0
 def __init__(self, *args, **kwargs):
     super(CRMAssociationsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.crm_associations")
Пример #20
0
 def __init__(self, *args, **kwargs):
     """initialize a contacts client"""
     super(ContactsClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.contacts")
Пример #21
0
 def __init__(self, *args, **kwargs):
     """initialize an companies properties client"""
     super(CompaniesPropertiesClient, self).__init__(*args, **kwargs)
     self.log = get_log("hubspot3.companies_properties")