Skip to content

✨Source Iterable: Migrate to low code #36231

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

Merged
merged 16 commits into from
Apr 15, 2024
Merged
4 changes: 2 additions & 2 deletions airbyte-integrations/connectors/source-iterable/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 2e875208-0c0b-4ee4-9e92-1cb3156ea799
dockerImageTag: 0.4.0
dockerImageTag: 0.5.0
dockerRepository: airbyte/source-iterable
documentationUrl: https://docs.airbyte.com/integrations/sources/iterable
githubIssueLabel: source-iterable
Expand All @@ -30,5 +30,5 @@ data:
supportLevel: certified
tags:
- language:python
- cdk:python
- cdk:low-code
metadataSpecVersion: "1.0"
54 changes: 26 additions & 28 deletions airbyte-integrations/connectors/source-iterable/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "0.4.0"
version = "0.5.0"
name = "source-iterable"
description = "Source implementation for Iterable."
authors = [ "Airbyte <[email protected]>",]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

import json
from dataclasses import dataclass
from io import StringIO

import requests
from airbyte_cdk.sources.declarative.extractors.dpath_extractor import DpathExtractor
from airbyte_cdk.sources.declarative.types import Config, Record, StreamSlice, StreamState


@dataclass
class XJsonRecordExtractor(DpathExtractor):
def extract_records(self, response: requests.Response) -> list[Record]:
return [json.loads(record) for record in response.iter_lines()]


@dataclass
class ListUsersRecordExtractor(DpathExtractor):
def extract_records(self, response: requests.Response) -> list[Record]:
return [{"email": record.decode()} for record in response.iter_lines()]


@dataclass
class EventsRecordExtractor(DpathExtractor):
common_fields = ("itblInternal", "_type", "createdAt", "email")

def extract_records(self, response: requests.Response) -> list[Record]:
jsonl_records = StringIO(response.text)
records = []
for record in jsonl_records:
record_dict = json.loads(record)
record_dict_common_fields = {}
for field in self.common_fields:
record_dict_common_fields[field] = record_dict.pop(field, None)

records.append({**record_dict_common_fields, "data": record_dict})

return records
Loading
Loading