Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edited companies and added companies_properties. #64

Merged
merged 2 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion hubspot3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ def companies(self):

return CompaniesClient(**self.auth, **self.options)

@property
def companies_properties(self):
"""returns a hubspot3 companies properties client"""
from hubspot3.companies_properties import CompaniesPropertiesClient

return CompaniesPropertiesClient(**self.auth, **self.options)

@property
def contact_lists(self):
"""returns a hubspot3 contact_lists client"""
Expand Down Expand Up @@ -344,7 +351,7 @@ def workflows(self):

@property
def usage_limits(self):
"""fetches and returns a nice usage liimitation object"""
"""fetches and returns a nice usage limitation object"""
if self._usage_limits.need_update:
limits = self._base._call("integrations/v1/limit/daily")[0]
self._usage_limits = Hubspot3UsageLimits(
Expand Down
7 changes: 4 additions & 3 deletions hubspot3/companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def search_domain(
)

def get_all(
self, extra_properties: Union[str, List] = None, **options
self, prettify_output=True, extra_properties: Union[str, List] = None, **options
) -> Optional[List]:
"""get all companies, including extra properties if they are passed in"""
finished = False
Expand Down Expand Up @@ -115,13 +115,14 @@ def get_all(
params={
"limit": query_limit,
"offset": offset,
"properties": properties,
"propertiesWithHistory": properties,
"includeMergeAudits": "true"
},
**options
)
output.extend(
[
prettify(company, id_key="companyId")
prettify(company, id_key="companyId") if prettify_output else company
for company in batch["companies"]
if not company["isDeleted"]
]
Expand Down
35 changes: 35 additions & 0 deletions hubspot3/companies_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
hubspot companies properties api
"""
from hubspot3.base import BaseClient
from hubspot3.utils import get_log
from typing import List, Optional, Union


COMPANIES_PROPERTIES_API_VERSION = "1"


class CompaniesPropertiesClient(BaseClient):
"""
The hubspot3 Companies Properties 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 an companies properties client"""
super(CompaniesPropertiesClient, self).__init__(*args, **kwargs)
self.log = get_log("hubspot3.companies_properties")

def _get_path(self, subpath):
return "properties/v{}/companies/{}".format(
COMPANIES_PROPERTIES_API_VERSION, subpath
)

def get_all_companies_properties(self, extra_properties: Union[str, List] = None, **options) -> Optional[List]:
"""
Retrieve all of the company properties, including their definition, for a given account.
:see: https://developers.hubspot.com/docs/methods/companies/get_company_properties
"""
return self._call(
"properties".format(COMPANIES_PROPERTIES_API_VERSION), **options
)