Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source ZohoCRM: Update api version and default optional fields to None #27423

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-zoho-crm/Dockerfile
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.1.2
LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.name=airbyte/source-zoho-crm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 4942d392-c7b5-4271-91f9-3b4f4e51eb3e
dockerImageTag: 0.1.2
dockerImageTag: 0.1.3
dockerRepository: airbyte/source-zoho-crm
githubIssueLabel: source-zoho-crm
icon: zohocrm.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ZohoAPI:
)
_API_ENV_TO_URL_PREFIX = MappingProxyType({"production": "", "developer": "developer", "sandbox": "sandbox"})
_CONCURRENCY_API_LIMITS = MappingProxyType({"Free": 5, "Standard": 10, "Professional": 15, "Enterprise": 20, "Ultimate": 25})
_API_VERSION = "v4"

def __init__(self, config: Mapping[str, Any]):
self.config = config
Expand Down Expand Up @@ -76,16 +77,16 @@ def _json_from_path(self, path: str, key: str, params: MutableMapping[str, str]
return response.json()[key]

def module_settings(self, module_name: str) -> List[MutableMapping[Any, Any]]:
return self._json_from_path(f"/crm/v2/settings/modules/{module_name}", key="modules")
return self._json_from_path(f"/crm/{self._API_VERSION}/settings/modules/{module_name}", key="modules")

def modules_settings(self) -> List[MutableMapping[Any, Any]]:
return self._json_from_path("/crm/v2/settings/modules", key="modules")
return self._json_from_path(f"/crm/{self._API_VERSION}/settings/modules", key="modules")

def fields_settings(self, module_name: str) -> List[MutableMapping[Any, Any]]:
return self._json_from_path("/crm/v2/settings/fields", key="fields", params={"module": module_name})
return self._json_from_path(f"/crm/{self._API_VERSION}/settings/fields", key="fields", params={"module": module_name})

def check_connection(self) -> Tuple[bool, Any]:
path = "/crm/v2/settings/modules"
path = f"/crm/{self._API_VERSION}/settings/modules"
response = requests.get(url=f"{self.api_url}{path}", headers=self.authenticator.get_auth_header())
try:
response.raise_for_status()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
yield from data

def path(self, *args, **kwargs) -> str:
return f"/crm/v2/{self.module.api_name}"
fields = ",".join([field.api_name for field in self.module.fields][0:50]) # Note, limited to 50 fields at max
return f"/crm/v4/{self.module.api_name}?fields={fields}"
Comment on lines +47 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fields = ",".join([field.api_name for field in self.module.fields][0:50]) # Note, limited to 50 fields at max
return f"/crm/v4/{self.module.api_name}?fields={fields}"
if len(self.module) > 50:
logger.warn("ZohoCRM only allow maximum of 50 parameter per query, the connector will drop: self.module.fields[50:]")
fields = ",".join([field.api_name for field in self.module.fields][0:50])
return f"/crm/v4/{self.module.api_name}?fields={fields}"


def get_json_schema(self) -> Optional[Dict[Any, Any]]:
try:
Expand Down Expand Up @@ -92,16 +93,6 @@ def read_records(self, *args, **kwargs) -> Iterable[Mapping[str, Any]]:
self.state = {self.cursor_field: new_cursor_value.isoformat("T", "seconds")}
yield record

def request_headers(
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
) -> Mapping[str, Any]:
last_modified = stream_state.get(self.cursor_field, self._start_datetime)
# since API filters inclusively, we add 1 sec to prevent duplicate reads
last_modified_dt = datetime.datetime.fromisoformat(last_modified)
last_modified_dt += datetime.timedelta(seconds=1)
last_modified = last_modified_dt.isoformat("T", "seconds")
return {"If-Modified-Since": last_modified}
Comment on lines -95 to -103
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing this?



class ZohoStreamFactory:
def __init__(self, config: Mapping[str, Any]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ class AutoNumberDict(FromDictMixin):
@dataclasses.dataclass
class FieldMeta(FromDictMixin):
json_type: str
length: Optional[int]
api_name: str
data_type: str
decimal_place: Optional[int]
system_mandatory: bool
display_label: str
pick_list_values: Optional[List[ZohoPickListItem]]
decimal_place: Optional[int] = None
pick_list_values: Optional[List[ZohoPickListItem]] = None
length: Optional[int] = None
auto_number: Optional[AutoNumberDict] = AutoNumberDict(prefix="", suffix="")

def _default_type_kwargs(self) -> Dict[str, str]:
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/zoho-crm.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Make sure to complete the auth flow quickly, as the initial token granted by Zoh

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------|
| 0.1.3 | 2023-07-03 | [23906](https://github.com/airbytehq/airbyte/pull/27423) | Updated api to use v4, fixed optional params being required bug
| 0.1.2 | 2023-03-09 | [23906](https://github.com/airbytehq/airbyte/pull/23906) | added support for the latest CDK, fixed SAT |
| 0.1.1 | 2023-03-13 | [23818](https://github.com/airbytehq/airbyte/pull/23818) | Set airbyte type to string for zoho autonumbers when they include prefix or suffix |
| 0.1.0 | 2022-03-30 | [11193](https://github.com/airbytehq/airbyte/pull/11193) | Initial release |