1
0
mirror of synced 2025-12-21 11:01:41 -05:00
Files
airbyte/airbyte-integrations/connectors/source-iterable/source_iterable/source.py
Vadym 17504e978e 🎉 Source Iterable: Add email validation to list_users stream method execution (#8380)
* Update iterable.md docs.

* Update `Events` stream to use `export/userEvents` endpoint.
Update `events` stream schema.
Add `test_events_parse_response` unit test.

* Update events parse_response data collection.
Update events stream unit tests.
Update events stream schema.

* Bump docker version
2021-12-06 21:07:51 +02:00

71 lines
2.6 KiB
Python

#
# Copyright (c) 2021 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 .api import (
Campaigns,
CampaignsMetrics,
Channels,
EmailBounce,
EmailClick,
EmailComplaint,
EmailOpen,
EmailSend,
EmailSendSkip,
EmailSubscribe,
EmailUnsubscribe,
Events,
Lists,
ListUsers,
MessageTypes,
Metadata,
Templates,
Users,
)
class SourceIterable(AbstractSource):
"""
Note: there are some redundant endpoints
(e.g. [`export/userEvents`](https://api.iterable.com/api/docs#export_exportUserEvents)
and [`events/{email}`](https://api.iterable.com/api/docs#events_User_events)).
In this case it's better to use the one which takes params as a query param rather than as part of the url param.
"""
def check_connection(self, logger, config) -> Tuple[bool, any]:
try:
list_gen = Lists(api_key=config["api_key"]).read_records(sync_mode=SyncMode.full_refresh)
next(list_gen)
return True, None
except Exception as e:
return False, f"Unable to connect to Iterable API with the provided credentials - {e}"
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
return [
Campaigns(api_key=config["api_key"]),
CampaignsMetrics(api_key=config["api_key"], start_date=config["start_date"]),
Channels(api_key=config["api_key"]),
EmailBounce(api_key=config["api_key"], start_date=config["start_date"]),
EmailClick(api_key=config["api_key"], start_date=config["start_date"]),
EmailComplaint(api_key=config["api_key"], start_date=config["start_date"]),
EmailOpen(api_key=config["api_key"], start_date=config["start_date"]),
EmailSend(api_key=config["api_key"], start_date=config["start_date"]),
EmailSendSkip(api_key=config["api_key"], start_date=config["start_date"]),
EmailSubscribe(api_key=config["api_key"], start_date=config["start_date"]),
EmailUnsubscribe(api_key=config["api_key"], start_date=config["start_date"]),
Events(api_key=config["api_key"]),
Lists(api_key=config["api_key"]),
ListUsers(api_key=config["api_key"]),
MessageTypes(api_key=config["api_key"]),
Metadata(api_key=config["api_key"]),
Templates(api_key=config["api_key"], start_date=config["start_date"]),
Users(api_key=config["api_key"], start_date=config["start_date"]),
]