Skip to content

Commit 4394dba

Browse files
committed
add function documentation
1 parent 761250f commit 4394dba

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

sources/hubspot/helpers.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,35 @@ def search_data_since(
160160
associations: Optional[List[str]] = None,
161161
context: Optional[Dict[str, Any]] = None,
162162
) -> Iterator[List[Dict[str, Any]]]:
163+
"""
164+
Fetch data from the HUBSPOT search endpoint, based on a given root endpoint, using a specified
165+
API key and yield the properties of each result. This function yields results from a last modified
166+
point in time based on the provided last modified property.
167+
168+
Args:
169+
endpoint (str): The root endpoint to fetch data from, as a string.
170+
api_key (str): The API key to use for authentication, as a string.
171+
last_modified (str): The date from which to start the search, as a string in ISO format.
172+
last_modified_prop (str): The property used to check the last modified date against, as a string.
173+
props: The list of properties to include for the object in the request.
174+
associations: Optional dict of associations to search for for each object.
175+
context (Optional[Dict[str, Any]]): Additional data which need to be added in the resulting page.
176+
177+
Yields:
178+
A List of CRM object dicts
179+
180+
Raises:
181+
requests.exceptions.HTTPError: If the API returns an HTTP error status code.
182+
183+
Notes:
184+
This function uses the `requests` library to make a POST request to the specified endpoint, with
185+
the API key included in the headers. If the API returns a non-successful HTTP status code (e.g.
186+
404 Not Found), a `requests.exceptions.HTTPError` exception will be raised.
187+
188+
The `endpoint` argument should be a relative URL, which will be modified to a search endpoint
189+
and then appended to the base URL for the API. `last_modified`, `last_modified_prop`, and `props`
190+
are used to pass additional parameters to the request
191+
"""
163192
# Construct the URL and headers for the API request
164193
url = get_url(CRM_SEARCH_ENDPOINT.format(crm_endpoint=endpoint))
165194
headers = _get_headers(api_key)

0 commit comments

Comments
 (0)