Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Fix: request selected properties for a given object only (#94)
Browse files Browse the repository at this point in the history
* request selected properties only

* selected properties for other streams

* remove logging

* get_selected_properties client method

* list comprehension

* PR comments
  • Loading branch information
irenegonzalez27 authored Jan 4, 2024
1 parent 25a2bab commit 126df4c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
7 changes: 7 additions & 0 deletions tap_hubspot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def get_url_params(
params["after"] = next_page_token
params["limit"] = 100
return params

def get_selected_properties(self) -> List[dict]:
selected_properties = [
key[-1] for key, value in self.metadata.items()
if value.selected and len(key) > 0
]
return list(set(self.properties).intersection(selected_properties))

def prepare_request_payload(
self, context: Optional[dict], next_page_token: Optional[Any]
Expand Down
22 changes: 15 additions & 7 deletions tap_hubspot/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class MeetingsStream(HubspotStream):
def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
selected_properties = self.get_selected_properties()
params = super().get_url_params(context, next_page_token)
params["properties"] = ",".join(self.properties)
params["properties"] = ",".join(selected_properties)
return params

@property
Expand All @@ -39,8 +40,9 @@ class CallsStream(HubspotStream):
def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
selected_properties = self.get_selected_properties()
params = super().get_url_params(context, next_page_token)
params["properties"] = ",".join(self.properties)
params["properties"] = ",".join(selected_properties)
return params

@property
Expand Down Expand Up @@ -73,11 +75,13 @@ class CompaniesStream(HubspotStream):
primary_keys = ["id"]
partitions = [{"archived": True}, {"archived": False}]


def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
selected_properties = self.get_selected_properties()
params = super().get_url_params(context, next_page_token)
params["properties"] = ",".join(self.properties)
params["properties"] = ",".join(selected_properties)
params["archived"] = context["archived"]
params["associations"] = ",".join(HUBSPOT_OBJECTS)
return params
Expand All @@ -103,8 +107,9 @@ class DealsStream(HubspotStream):
def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
selected_properties = self.get_selected_properties()
params = super().get_url_params(context, next_page_token)
params["properties"] = ",".join(self.properties)
params["properties"] = ",".join(selected_properties)
params["archived"] = context["archived"]
params["associations"] = ",".join(HUBSPOT_OBJECTS)
return params
Expand Down Expand Up @@ -134,8 +139,9 @@ class ContactsStream(HubspotStream):
def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
selected_properties = self.get_selected_properties()
params = super().get_url_params(context, next_page_token)
params["properties"] = ",".join(self.properties)
params["properties"] = ",".join(selected_properties)
params["archived"] = context["archived"]
params["associations"] = ",".join(HUBSPOT_OBJECTS)
return params
Expand Down Expand Up @@ -383,8 +389,9 @@ class QuotesStream(HubspotStream):
def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
selected_properties = self.get_selected_properties()
params = super().get_url_params(context, next_page_token)
params["properties"] = ",".join(self.properties)
params["properties"] = ",".join(selected_properties)
params["archived"] = context["archived"]
params["associations"] = ",".join(HUBSPOT_OBJECTS)
return params
Expand All @@ -404,8 +411,9 @@ class LineItemsStream(HubspotStream):
def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
selected_properties = self.get_selected_properties()
params = super().get_url_params(context, next_page_token)
params["properties"] = ",".join(self.properties)
params["properties"] = ",".join(selected_properties)
params["archived"] = context["archived"]
params["associations"] = ",".join(HUBSPOT_OBJECTS)
return params
Expand Down

0 comments on commit 126df4c

Please sign in to comment.