Skip to content

Commit

Permalink
adding custom fields to close schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jtruty committed Nov 30, 2023
1 parent 3200e1f commit b505d92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.4.3
LABEL io.airbyte.version=0.5.0
LABEL io.airbyte.name=airbyte/source-close-com
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@


from .datetime_incremental_sync import CustomDatetimeIncrementalSync
from .source_lc import SourceCloseCom
from .source import SourceCloseCom

__all__ = ["SourceCloseCom", "CustomDatetimeIncrementalSync"]
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def request_params(
stream_slice: Mapping[str, Any] = None,
next_page_token: Mapping[str, Any] = None,
) -> MutableMapping[str, Any]:

params = {}
if self.number_of_items_per_page:
params.update({"_limit": self.number_of_items_per_page})
Expand All @@ -69,6 +68,21 @@ def request_params(

return params

def get_custom_field_schema(self) -> Mapping[str, Any]:
"""Get custom field schema if it exists."""
if self.path() not in {"lead", "contact", "opportunity", "activity"}:
return {}
resp = requests.request("GET", url=f"{self.url_base}/custom_field/{self.path()}/", headers=self.authenticator.get_auth_header())
resp.raise_for_status()
resp_json: Mapping[str, Any] = resp.json()["data"]
return {f"custom.{data['id']}": {"type": ["null", "string", "number", "boolean"]} for data in resp_json}

def get_json_schema(self):
"""Override default get_json_schema method to add custom fields to schema."""
schema = super().get_json_schema()
schema["properties"].update(self.get_custom_field_schema())
return schema

def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
yield from response.json()["data"]

Expand All @@ -88,7 +102,6 @@ def backoff_time(self, response: requests.Response) -> Optional[float]:


class IncrementalCloseComStream(CloseComStream):

cursor_field = "date_updated"

def get_updated_state(
Expand Down
5 changes: 3 additions & 2 deletions docs/integrations/sources/close-com.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ The Close.com connector is subject to rate limits. For more information on this

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------------------------------|
| 0.4.3 | 2023-10-28 | [31534](https://github.com/airbytehq/airbyte/pull/31534) | Fixed Email Activities Stream Pagination |
| 0.4.2 | 2023-08-08 | [29206](https://github.com/airbytehq/airbyte/pull/29206) | Fixed the issue with `DatePicker` format for `start date` |
| 0.5.0 | 2023-11-30 | [32984](https://github.com/airbytehq/airbyte/pull/32984) | Add support for custom fields |
| 0.4.3 | 2023-10-28 | [31534](https://github.com/airbytehq/airbyte/pull/31534) | Fixed Email Activities Stream Pagination |
| 0.4.2 | 2023-08-08 | [29206](https://github.com/airbytehq/airbyte/pull/29206) | Fixed the issue with `DatePicker` format for `start date` |
| 0.4.1 | 2023-07-04 | [27950](https://github.com/airbytehq/airbyte/pull/27950) | Add human readable titles to API Key and Start Date fields |
| 0.4.0 | 2023-06-27 | [27776](https://github.com/airbytehq/airbyte/pull/27776) | Update the `Email Followup Tasks` stream schema |
| 0.3.0 | 2023-05-12 | [26024](https://github.com/airbytehq/airbyte/pull/26024) | Update the `Email sequences` stream schema |
Expand Down

0 comments on commit b505d92

Please sign in to comment.