From 85407d1123fd1dcf7093c02e853cd077b2f9a364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Burwash?= <35510512+SBurwash@users.noreply.github.com> Date: Fri, 2 Jun 2023 17:07:42 -0400 Subject: [PATCH] DE-1717 Hubspot - Create replace existing associations tables for companies, contacts & deals with new version of the API (#60) * Added new client type * Added parameters * Logging metrics url * Added params * Printing response and removed properties * Removed type * Changed logger * Added logs * Removed error * Removed debugging * Removed logging _2 * Removed self.logger * Added endlines * Removed tab --- tap_hubspot/client.py | 28 ++++++++++++++++++++++++++++ tap_hubspot/streams.py | 3 +++ 2 files changed, 31 insertions(+) diff --git a/tap_hubspot/client.py b/tap_hubspot/client.py index 6ad7892..7b20a8b 100644 --- a/tap_hubspot/client.py +++ b/tap_hubspot/client.py @@ -166,6 +166,34 @@ def get_custom_schema(self, poorly_cast: List[str] = []): properties.append(th.Property('createdAt', th.DateTimeType())) properties.append(th.Property('id', th.StringType())) properties.append(th.Property('archived', th.BooleanType())) + properties.append( + th.Property('associations', th.ObjectType( + th.Property("companies", th.ObjectType( + th.Property("results", th.ArrayType( + th.ObjectType( + th.Property("id", th.StringType()), + th.Property("type", th.StringType()) + ) + )) + )), + th.Property("contacts", th.ObjectType( + th.Property("results", th.ArrayType( + th.ObjectType( + th.Property("id", th.StringType()), + th.Property("type", th.StringType()) + ) + )) + )), + th.Property("deals", th.ObjectType( + th.Property("results", th.ArrayType( + th.ObjectType( + th.Property("id", th.StringType()), + th.Property("type", th.StringType()) + ) + )) + )) + )) + ) properties.append(th.Property( 'properties', th.ObjectType(*internal_properties) )) diff --git a/tap_hubspot/streams.py b/tap_hubspot/streams.py index 96db20c..10f71fe 100644 --- a/tap_hubspot/streams.py +++ b/tap_hubspot/streams.py @@ -86,6 +86,7 @@ def get_url_params( params = super().get_url_params(context, next_page_token) params["properties"] = ",".join(self.properties) params["archived"] = context["archived"] + params["associations"] = "contacts,companies,deals" return params @property @@ -113,6 +114,7 @@ def get_url_params( params = super().get_url_params(context, next_page_token) params["properties"] = ",".join(self.properties) params["archived"] = context["archived"] + params["associations"] = "contacts,companies,deals" return params @property @@ -143,6 +145,7 @@ def get_url_params( params = super().get_url_params(context, next_page_token) params["properties"] = ",".join(self.properties) params["archived"] = context["archived"] + params["associations"] = "contacts,companies,deals" return params @property