-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚨🚨 Migrate
source-zendesk-talk
to low code (#35780)
Co-authored-by: Serhii Lazebnyi <serhii.lazebnyi@globallogic.com> Co-authored-by: Alexandre Girard <alexandre@airbyte.io>
- Loading branch information
1 parent
7cdf69e
commit 0405990
Showing
14 changed files
with
1,898 additions
and
979 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 67 additions & 66 deletions
133
airbyte-integrations/connectors/source-zendesk-talk/poetry.lock
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
airbyte-integrations/connectors/source-zendesk-talk/source_zendesk_talk/components.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
|
||
from dataclasses import dataclass | ||
from typing import Any, List, Mapping | ||
|
||
import requests | ||
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator | ||
from airbyte_cdk.sources.declarative.auth.token import BasicHttpAuthenticator, BearerAuthenticator | ||
from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor | ||
from airbyte_cdk.sources.declarative.types import Record | ||
|
||
|
||
@dataclass | ||
class IVRMenusRecordExtractor(RecordExtractor): | ||
def extract_records(self, response: requests.Response) -> List[Record]: | ||
ivrs = response.json().get("ivrs", []) | ||
records = [] | ||
for ivr in ivrs: | ||
for menu in ivr.get("menus", []): | ||
records.append({"ivr_id": ivr["id"], **menu}) | ||
return records | ||
|
||
|
||
@dataclass | ||
class IVRRoutesRecordExtractor(RecordExtractor): | ||
def extract_records(self, response: requests.Response) -> List[Record]: | ||
ivrs = response.json().get("ivrs", []) | ||
records = [] | ||
for ivr in ivrs: | ||
for menu in ivr.get("menus", []): | ||
for route in menu.get("routes", []): | ||
records.append({"ivr_id": ivr["id"], "ivr_menu_id": menu["id"], **route}) | ||
return records | ||
|
||
|
||
@dataclass | ||
class ZendeskTalkAuthenticator(DeclarativeAuthenticator): | ||
config: Mapping[str, Any] | ||
legacy_basic_auth: BasicHttpAuthenticator | ||
basic_auth: BasicHttpAuthenticator | ||
oauth: BearerAuthenticator | ||
|
||
def __new__(cls, legacy_basic_auth, basic_auth, oauth, config, *args, **kwargs): | ||
credentials = config.get("credentials", {}) | ||
if config.get("access_token", {}) and config.get("email", {}): | ||
return legacy_basic_auth | ||
elif credentials["auth_type"] == "api_token": | ||
return basic_auth | ||
elif credentials["auth_type"] == "oauth2.0": | ||
return oauth | ||
else: | ||
raise Exception(f"Missing valid authenticator for auth_type: {credentials['auth_type']}") |
Oops, something went wrong.