Skip to content

Commit

Permalink
Merge pull request #64 from ndewani/develop
Browse files Browse the repository at this point in the history
Edited companies and added companies_properties.
  • Loading branch information
jpetrucciani committed Oct 9, 2019
2 parents e1c831e + 3b08c75 commit d4df21a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
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
)

0 comments on commit d4df21a

Please sign in to comment.