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

add property mode in get_batch() from contacts #107

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pylint:
- cyclic-import
- import-outside-toplevel
- unnecessary-comprehension
- C0112

options:
max-args: 12
Expand Down
14 changes: 8 additions & 6 deletions hubspot3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ def __init__(

def __str__(self) -> str:
"""string representation"""
return "<Hubspot3UsageLimits: {}/{} ({}%) [reset in {}s, cached for {}s]>".format(
self.current_usage,
self.usage_limit,
self.calls_used,
self.until_reset,
self.until_cache_expire,
return (
"<Hubspot3UsageLimits: {}/{} ({}%) [reset in {}s, cached for {}s]>".format(
self.current_usage,
self.usage_limit,
self.calls_used,
self.until_reset,
self.until_cache_expire,
)
)

def __repr__(self) -> str:
Expand Down
15 changes: 14 additions & 1 deletion hubspot3/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def merge(self, primary_id: int, secondary_id: int, **options):
"associatedcompanyid",
]

def get_batch(self, ids, extra_properties: Union[list, str] = None):
def get_batch(
self, ids, extra_properties: Union[list, str] = None, property_mode: str = None
):
"""given a batch of vids, get more of their info"""
# default properties to fetch
properties = set(self.default_batch_properties)
Expand All @@ -126,6 +128,17 @@ def get_batch(self, ids, extra_properties: Union[list, str] = None):
if isinstance(extra_properties, str):
properties.add(extra_properties)

if property_mode == "value_and_history":
return self._call(
"contact/vids/batch",
method="GET",
doseq=True,
params={
"vid": ids,
"property": list(properties),
"propertyMode": property_mode,
},
)
batch = self._call(
"contact/vids/batch",
method="GET",
Expand Down