Skip to content

Commit 9cc2560

Browse files
Source Hubspot: adding form_submissions stream (#8011)
* Source Hubspot: adding form_submissions stream * Adding form_id to form_submissions output * Adding form_id to form_submissions output and schema * Removing field deletions and id generation * Adding new line to form_submissions.json * Fixing form_submissions.json schema * add form_submissions as empty_stream to run ci airbyte * add forms_submissions to empty_stream * bump connector seed version Co-authored-by: Marcos Marx <[email protected]>
1 parent 5f4a5bb commit 9cc2560

File tree

12 files changed

+99
-6
lines changed

12 files changed

+99
-6
lines changed

airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/36c891d9-4bd9-43ac-bad2-10e12756272c.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"sourceDefinitionId": "36c891d9-4bd9-43ac-bad2-10e12756272c",
33
"name": "HubSpot",
44
"dockerRepository": "airbyte/source-hubspot",
5-
"dockerImageTag": "0.1.30",
5+
"dockerImageTag": "0.1.32",
66
"documentationUrl": "https://docs.airbyte.io/integrations/sources/hubspot",
77
"icon": "hubspot.svg"
88
}

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
- name: HubSpot
288288
sourceDefinitionId: 36c891d9-4bd9-43ac-bad2-10e12756272c
289289
dockerRepository: airbyte/source-hubspot
290-
dockerImageTag: 0.1.31
290+
dockerImageTag: 0.1.32
291291
documentationUrl: https://docs.airbyte.io/integrations/sources/hubspot
292292
icon: hubspot.svg
293293
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2846,7 +2846,7 @@
28462846
path_in_connector_config:
28472847
- "credentials"
28482848
- "client_secret"
2849-
- dockerImage: "airbyte/source-hubspot:0.1.31"
2849+
- dockerImage: "airbyte/source-hubspot:0.1.32"
28502850
spec:
28512851
documentationUrl: "https://docs.airbyte.io/integrations/sources/hubspot"
28522852
connectionSpecification:

airbyte-integrations/connectors/source-hubspot/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ COPY source_hubspot ./source_hubspot
3434
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
3535
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
3636

37-
LABEL io.airbyte.version=0.1.31
37+
LABEL io.airbyte.version=0.1.32
3838
LABEL io.airbyte.name=airbyte/source-hubspot

airbyte-integrations/connectors/source-hubspot/acceptance-test-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ tests:
1818
basic_read:
1919
- config_path: "secrets/config.json"
2020
configured_catalog_path: "sample_files/full_refresh_catalog.json"
21-
empty_streams: ["workflows"]
21+
empty_streams: ["workflows", "form_submissions"]
2222
- config_path: "secrets/config_oauth.json"
2323
configured_catalog_path: "sample_files/configured_catalog_for_oauth_config.json"
2424
# The `campaigns` stream is empty in this case, because we use a catalog with
2525
# incremental streams: subscription_changes and email_events (it takes a long time to read)
2626
# and therefore the start date is set at 2021-10-10 for `config_oauth.json`,
2727
# but the campaign was created on 2021-01-11
28-
empty_streams: ["campaigns", "workflows", "contacts_list_memberships"]
28+
empty_streams: ["campaigns", "workflows", "contacts_list_memberships", "form_submissions"]
2929
incremental:
3030
- config_path: "secrets/config.json"
3131
configured_catalog_path: "sample_files/configured_catalog.json"

airbyte-integrations/connectors/source-hubspot/sample_files/configured_catalog.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@
9696
"sync_mode": "full_refresh",
9797
"destination_sync_mode": "overwrite"
9898
},
99+
{
100+
"stream": {
101+
"name": "form_submissions",
102+
"json_schema": {},
103+
"supported_sync_modes": ["full_refresh"]
104+
},
105+
"sync_mode": "full_refresh",
106+
"destination_sync_mode": "overwrite"
107+
},
99108
{
100109
"stream": {
101110
"name": "line_items",

airbyte-integrations/connectors/source-hubspot/sample_files/configured_catalog_for_oauth_config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@
9393
"sync_mode": "full_refresh",
9494
"destination_sync_mode": "overwrite"
9595
},
96+
{
97+
"stream": {
98+
"name": "form_submissions",
99+
"json_schema": {},
100+
"supported_sync_modes": ["full_refresh"]
101+
},
102+
"sync_mode": "full_refresh",
103+
"destination_sync_mode": "overwrite"
104+
},
96105
{
97106
"stream": {
98107
"name": "line_items",

airbyte-integrations/connectors/source-hubspot/sample_files/full_refresh_catalog.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@
8181
"sync_mode": "full_refresh",
8282
"destination_sync_mode": "overwrite"
8383
},
84+
{
85+
"stream": {
86+
"name": "form_submissions",
87+
"json_schema": {},
88+
"supported_sync_modes": ["full_refresh"]
89+
},
90+
"sync_mode": "full_refresh",
91+
"destination_sync_mode": "overwrite"
92+
},
8493
{
8594
"stream": {
8695
"name": "line_items",

airbyte-integrations/connectors/source-hubspot/source_hubspot/api.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,34 @@ class FormStream(Stream):
732732
created_at_field = "createdAt"
733733

734734

735+
class FormSubmissionStream(Stream):
736+
"""Marketing Forms, API v1
737+
This endpoint requires the forms scope.
738+
Docs: https://legacydocs.hubspot.com/docs/methods/forms/get-submissions-for-a-form
739+
"""
740+
741+
url = "/form-integrations/v1/submissions/forms"
742+
limit = 50
743+
updated_at_field = "updatedAt"
744+
745+
def _transform(self, records: Iterable) -> Iterable:
746+
for record in super()._transform(records):
747+
keys = record.keys()
748+
749+
# There's no updatedAt field in the submission however forms fetched by using this field,
750+
# so it has to be added to the submissions otherwise it would fail when calling _filter_old_records
751+
if "updatedAt" not in keys:
752+
record["updatedAt"] = record["submittedAt"]
753+
754+
yield record
755+
756+
def list(self, fields) -> Iterable:
757+
for form in self.read(getter=partial(self._api.get, url="/marketing/v3/forms")):
758+
for submission in self.read(getter=partial(self._api.get, url=f"{self.url}/{form['id']}")):
759+
submission["formId"] = form["id"]
760+
yield submission
761+
762+
735763
class MarketingEmailStream(Stream):
736764
"""Marketing Email, API v1
737765
Docs: https://legacydocs.hubspot.com/docs/methods/cms_email/get-all-marketing-emails

airbyte-integrations/connectors/source-hubspot/source_hubspot/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
EmailEventStream,
2020
EngagementStream,
2121
FormStream,
22+
FormSubmissionStream,
2223
MarketingEmailStream,
2324
OwnerStream,
2425
SubscriptionChangeStream,
@@ -45,6 +46,7 @@ def __init__(self, start_date, credentials, **kwargs):
4546
"email_events": EmailEventStream(**common_params),
4647
"engagements": EngagementStream(**common_params),
4748
"forms": FormStream(**common_params),
49+
"form_submissions": FormSubmissionStream(**common_params),
4850
"line_items": CRMObjectIncrementalStream(entity="line_item", **common_params),
4951
"marketing_emails": MarketingEmailStream(**common_params),
5052
"owners": OwnerStream(**common_params),

0 commit comments

Comments
 (0)