diff --git a/hubspot3/companies.py b/hubspot3/companies.py index 80b2637..b0e43ea 100644 --- a/hubspot3/companies.py +++ b/hubspot3/companies.py @@ -82,10 +82,13 @@ def search_domain( def get_all( self, prettify_output: bool = True, - extra_properties: Union[str, List]=None, + extra_properties: Union[str, List] = None, **options ) -> Optional[List]: - """get all companies, including extra properties if they are passed in""" + """ + get all companies, including extra properties if they are passed in + :see: https://developers.hubspot.com/docs/methods/deals/get-all-deals + """ finished = False output = [] offset = 0 @@ -138,12 +141,13 @@ def get_all( return output def _get_recent( - self, - recency_type: str, - limit: int = 250, - offset: int = 0, - since: int = None, - **options) -> Optional[List]: + self, + recency_type: str, + limit: int = 250, + offset: int = 0, + since: int = None, + **options + ) -> Optional[List]: """ Returns either list of recently modified companies or recently created companies, depending on recency_type passed in. Both API endpoints take identical parameters @@ -156,10 +160,7 @@ def _get_recent( output = [] while not finished: - params = { - "count": limit, - "offset": offset, - } + params = {"count": limit, "offset": offset} if since: params["since"] = since batch = self._call( @@ -182,36 +183,30 @@ def _get_recent( return output def get_recently_modified( - self, - limit: int = 250, - offset: int = 0, - since: int = None, - **options + self, limit: int = 250, offset: int = 0, since: int = None, **options ) -> Optional[List]: + """ + returns all of the recently modified deals + :see: https://developers.hubspot.com/docs/methods/deals/get_deals_modified + """ return self._get_recent( - "modified", - limit=limit, - offset=offset, - since=since, - **options) + "modified", limit=limit, offset=offset, since=since, **options + ) def get_recently_created( - self, - limit: int = 250, - offset: int = 0, - since: int = None, - **options + self, limit: int = 250, offset: int = 0, since: int = None, **options ) -> Optional[List]: + """ + returns all of the recently created deals + :see: https://developers.hubspot.com/docs/methods/deals/get_deals_created + """ return self._get_recent( - "created", - limit=limit, - offset=offset, - since=since, - **options) + "created", limit=limit, offset=offset, since=since, **options + ) def get_contacts_at_a_company(self, company_id: str, **options) -> Optional[List]: """ - Returns all of the contacts who have an associatedcompanyid contact property of + returns all of the contacts who have an associatedcompanyid contact property of `company_id`. :see: https://developers.hubspot.com/docs/methods/companies/get_company_contacts diff --git a/hubspot3/deals.py b/hubspot3/deals.py index 73634a6..b2c7935 100644 --- a/hubspot3/deals.py +++ b/hubspot3/deals.py @@ -27,11 +27,16 @@ def __init__(self, *args, **kwargs): self.log = get_log("hubspot3.deals") def _get_path(self, subpath): + """get the full api url for the given subpath on this client""" return "deals/v{}/{}".format( self.options.get("version") or DEALS_API_VERSION, subpath ) def get(self, deal_id: str, **options): + """ + get a single deal by id + :see: https://developers.hubspot.com/docs/methods/deals/get_deal + """ return self._call("deal/{}".format(deal_id), method="GET", **options) def create(self, data: dict = None, **options): @@ -43,6 +48,10 @@ def create(self, data: dict = None, **options): return self._call("deal/", data=data, method="POST", **options) def update(self, deal_id: str, data: dict = None, **options): + """ + update a deal by id + :see: https://developers.hubspot.com/docs/methods/deals/update_deal + """ data = data or {} return self._call("deal/{}".format(deal_id), data=data, method="PUT", **options) @@ -70,7 +79,7 @@ def associate(self, deal_id, object_type, object_ids, **options): def get_all( self, offset: int = 0, - extra_properties: Union[list, str]=None, + extra_properties: Union[list, str] = None, limit: int = -1, **options ): @@ -127,8 +136,7 @@ def get_all( if not deal["isDeleted"] ] ) - finished = not batch["hasMore"] or ( - limited and len(output) >= limit) + finished = not batch["hasMore"] or (limited and len(output) >= limit) offset = batch["offset"] return output if not limited else output[:limit] diff --git a/hubspot3/globals.py b/hubspot3/globals.py index cff2f72..46753b0 100644 --- a/hubspot3/globals.py +++ b/hubspot3/globals.py @@ -1,7 +1,7 @@ """ globals file for hubspot3 """ -__version__ = "3.2.38" +__version__ = "3.2.39" BASE_URL = "https://api.hubapi.com"