Skip to content

Commit

Permalink
feat: zoho crm connector
Browse files Browse the repository at this point in the history
  • Loading branch information
andyh565 committed Oct 15, 2024
1 parent 444967d commit 91c7ecc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
pypi:
enabled: true
packageName: airbyte-source-zoho-crm
registryOverrides:
registries:
cloud:
enabled: true
oss:
Expand All @@ -27,10 +27,6 @@ data:
- language:python
- cdk:python
connectorTestSuitesOptions:
- suite: liveTests
testConnections:
- name: zoho-crm_config_dev_null
id: 0000da93-11f4-4e8f-8ede-42b9789b974d
- suite: unitTests
- suite: integrationTests
testSecrets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Any, Dict, Iterable, List, Mapping, MutableMapping, Optional

import requests
from airbyte_cdk.entrypoint import logger
from airbyte_cdk.sources.streams.http import HttpStream

from .api import ZohoAPI
Expand Down Expand Up @@ -109,14 +110,28 @@ def __init__(self, config: Mapping[str, Any]):
self._config = config

def _init_modules_meta(self) -> List[ModuleMeta]:
modules_meta_json = self.api.modules_settings()
contacts_modules_meta_json = self.api.module_settings("Contacts")
leads_modules_meta_json = self.api.module_settings("Leads")

modules_meta_json = contacts_modules_meta_json + leads_modules_meta_json
modules = [ModuleMeta.from_dict(module) for module in modules_meta_json]
return list(filter(lambda module: module.api_supported, modules))
return list(filter(lambda module: module.api_name == "Contacts" or module.api_name == "Leads", modules))

def _populate_fields_meta(self, module: ModuleMeta):
fields_meta_json = self.api.fields_settings(module.api_name)
fields_meta = []
for field in fields_meta_json:
'''
Skipping this field for now, as it is a bug in Zoho's V2 API.
The alternative is to update the API version to v5, but then the number of fields that can be fetched per record is limited to 50.
If the API version is updated to v5, we will need to do one of the following:
- make multiple API requests to fetch the complete record data (req 1: get first 50 fields, req 2: get next 50 fields), then aggregate the records.
- fetch field data using v5, fetch records using v2 (mixing API versions is a bad idea)
- pass in the fields as connection params that the user wants to fetch and limit it to 50 fields
'''
if 'json_type' not in field:
logger.warn(f"Unsupported Zoho field {field['api_name']} found")
continue
pick_list_values = field.get("pick_list_values", [])
if pick_list_values:
field["pick_list_values"] = [ZohoPickListItem.from_dict(pick_list_item) for pick_list_item in field["pick_list_values"]]
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]]
length: Optional[int] = None
decimal_place: Optional[int] = None
pick_list_values: Optional[List[ZohoPickListItem]] = None
auto_number: Optional[AutoNumberDict] = AutoNumberDict(prefix="", suffix="")

def _default_type_kwargs(self) -> Dict[str, str]:
Expand Down Expand Up @@ -155,7 +155,6 @@ def _string_field(self) -> FieldType:
elif self.data_type == ZohoDataType.bigint:
typedef["airbyte_type"] = "big_integer"
elif self.data_type == ZohoDataType.autonumber:
print(self.auto_number)
if self.auto_number.get("prefix") or self.auto_number.get("suffix"):
typedef["format"] = "string"
else:
Expand Down

0 comments on commit 91c7ecc

Please sign in to comment.