diff --git a/airbyte-integrations/connectors/source-hubspot/source_hubspot/source.py b/airbyte-integrations/connectors/source-hubspot/source_hubspot/source.py index baa562164e87..fa5fbf208d56 100644 --- a/airbyte-integrations/connectors/source-hubspot/source_hubspot/source.py +++ b/airbyte-integrations/connectors/source-hubspot/source_hubspot/source.py @@ -2,7 +2,7 @@ # Copyright (c) 2023 Airbyte, Inc., all rights reserved. # -import logging +import logging, datetime from http import HTTPStatus from itertools import chain from typing import Any, List, Mapping, Optional, Tuple @@ -113,6 +113,17 @@ def get_api(config: Mapping[str, Any]) -> API: def get_common_params(self, config) -> Mapping[str, Any]: start_date = config.get("start_date", DEFAULT_START_DATE) + + start_date_offset = config.get("relative_start_date_offset", 0) + + if start_date_offset > 0: + # set start_Date relative to today + now = datetime.date.today() + delta = datetime.timedelta(days=start_date_offset) + start_date = (now - delta) + + print(f"getting config: now: {now} // delta: {delta} // start_date: {start_date}") + credentials = config["credentials"] api = self.get_api(config=config) return dict(api=api, start_date=start_date, credentials=credentials) diff --git a/airbyte-integrations/connectors/source-hubspot/source_hubspot/spec.yaml b/airbyte-integrations/connectors/source-hubspot/source_hubspot/spec.yaml index 6f105f4d05a5..653fe994ba80 100644 --- a/airbyte-integrations/connectors/source-hubspot/source_hubspot/spec.yaml +++ b/airbyte-integrations/connectors/source-hubspot/source_hubspot/spec.yaml @@ -18,6 +18,16 @@ connectionSpecification: examples: - "2017-01-25T00:00:00Z" format: date-time + relative_start_date_offset: + title: Relative date offset + type: integer + minimum: 0 + maximum: 365 + description: >- + Offset relative to current date, measured in whole days (integer between 1 and 365). If this is set, it takes precedence over the set start_date. To + gather data with a moving window fo a week, set this to 7 (days). + examples: + - "7" credentials: title: Authentication description: Choose how to authenticate to HubSpot.