Skip to content

Commit

Permalink
Source Close.com: add custom fields (airbytehq#34286)
Browse files Browse the repository at this point in the history
Co-authored-by: James Truty <jtruty@gmail.com>
  • Loading branch information
2 people authored and jatinyadav-cc committed Feb 26, 2024
1 parent fbb4fb4 commit 39923b1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 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 @@ -8,7 +8,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: dfffecb7-9a13-43e9-acdc-b92af7997ca9
dockerImageTag: 0.4.3
dockerImageTag: 0.5.0
dockerRepository: airbyte/source-close-com
documentationUrl: https://docs.airbyte.com/integrations/sources/close-com
githubIssueLabel: source-close-com
Expand Down
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 Down Expand Up @@ -87,8 +86,24 @@ def backoff_time(self, response: requests.Response) -> Optional[float]:
return backoff_time


class IncrementalCloseComStream(CloseComStream):
class CloseComStreamCustomFields(CloseComStream):
"""Class to get custom fields for close objects that support them."""

def get_custom_field_schema(self) -> Mapping[str, Any]:
"""Get custom field schema if it exists."""
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


class IncrementalCloseComStream(CloseComStream):
cursor_field = "date_updated"

def get_updated_state(
Expand All @@ -105,6 +120,10 @@ def get_updated_state(
return {self.cursor_field: max(latest_record.get(self.cursor_field, ""), current_stream_state.get(self.cursor_field, ""))}


class IncrementalCloseComStreamCustomFields(CloseComStreamCustomFields, IncrementalCloseComStream):
"""Class to get custom fields for close objects using incremental stream."""


class CloseComActivitiesStream(IncrementalCloseComStream):
"""
General class for activities. Define request params based on cursor_field value.
Expand Down Expand Up @@ -233,7 +252,7 @@ def request_params(self, stream_state=None, **kwargs):
return params


class Leads(IncrementalCloseComStream):
class Leads(IncrementalCloseComStreamCustomFields):
"""
Get leads on a specific date
API Docs: https://developer.close.com/#leads
Expand Down Expand Up @@ -404,7 +423,7 @@ def path(self, **kwargs) -> str:
return "user"


class Contacts(CloseComStream):
class Contacts(CloseComStreamCustomFields):
"""
Get contacts for Close.com account organization
API Docs: https://developer.close.com/#contacts
Expand All @@ -416,7 +435,7 @@ def path(self, **kwargs) -> str:
return "contact"


class Opportunities(IncrementalCloseComStream):
class Opportunities(IncrementalCloseComStreamCustomFields):
"""
Get opportunities on a specific date
API Docs: https://developer.close.com/#opportunities
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 39923b1

Please sign in to comment.