1
0
mirror of synced 2026-01-10 09:04:48 -05:00
Files
airbyte/airbyte-integrations/connectors/source-lemlist/source_lemlist/source.py
Cole Snodgrass 2e099acc52 update headers from 2022 -> 2023 (#22594)
* It's 2023!

* 2022 -> 2023

---------

Co-authored-by: evantahler <evan@airbyte.io>
2023-02-08 13:01:16 -08:00

42 lines
1.3 KiB
Python

#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from typing import Any, List, Mapping, Tuple
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream
from source_lemlist.auth import HttpBasicAuthenticator
from .streams import Activities, Campaigns, Team, Unsubscribes
class SourceLemlist(AbstractSource):
def check_connection(self, logger, config) -> Tuple[bool, any]:
try:
auth = HttpBasicAuthenticator(
(
"",
config["api_key"],
),
)
team_stream = Team(authenticator=auth)
team_gen = team_stream.read_records(sync_mode=SyncMode.full_refresh)
next(team_gen)
return True, None
except Exception as error:
return False, f"The provided API key {config['api_key']} is invalid. - {repr(error)}"
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
auth = HttpBasicAuthenticator(
(
"",
config["api_key"],
),
)
return [Team(authenticator=auth), Campaigns(authenticator=auth), Activities(authenticator=auth), Unsubscribes(authenticator=auth)]