Skip to content

Commit 0c49832

Browse files
authored
✨Source Iterable: Migrate to low code (#36231)
1 parent 98478f0 commit 0c49832

18 files changed

+837
-520
lines changed

airbyte-integrations/connectors/source-iterable/metadata.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data:
1010
connectorSubtype: api
1111
connectorType: source
1212
definitionId: 2e875208-0c0b-4ee4-9e92-1cb3156ea799
13-
dockerImageTag: 0.4.0
13+
dockerImageTag: 0.5.0
1414
dockerRepository: airbyte/source-iterable
1515
documentationUrl: https://docs.airbyte.com/integrations/sources/iterable
1616
githubIssueLabel: source-iterable
@@ -31,5 +31,5 @@ data:
3131
supportLevel: certified
3232
tags:
3333
- language:python
34-
- cdk:python
34+
- cdk:low-code
3535
metadataSpecVersion: "1.0"

airbyte-integrations/connectors/source-iterable/poetry.lock

+26-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

airbyte-integrations/connectors/source-iterable/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "0.4.0"
6+
version = "0.5.0"
77
name = "source-iterable"
88
description = "Source implementation for Iterable."
99
authors = [ "Airbyte <[email protected]>",]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
import json
6+
from dataclasses import dataclass
7+
from io import StringIO
8+
9+
import requests
10+
from airbyte_cdk.sources.declarative.extractors.dpath_extractor import DpathExtractor
11+
from airbyte_cdk.sources.declarative.types import Config, Record, StreamSlice, StreamState
12+
13+
14+
@dataclass
15+
class XJsonRecordExtractor(DpathExtractor):
16+
def extract_records(self, response: requests.Response) -> list[Record]:
17+
return [json.loads(record) for record in response.iter_lines()]
18+
19+
20+
@dataclass
21+
class ListUsersRecordExtractor(DpathExtractor):
22+
def extract_records(self, response: requests.Response) -> list[Record]:
23+
return [{"email": record.decode()} for record in response.iter_lines()]
24+
25+
26+
@dataclass
27+
class EventsRecordExtractor(DpathExtractor):
28+
common_fields = ("itblInternal", "_type", "createdAt", "email")
29+
30+
def extract_records(self, response: requests.Response) -> list[Record]:
31+
jsonl_records = StringIO(response.text)
32+
records = []
33+
for record in jsonl_records:
34+
record_dict = json.loads(record)
35+
record_dict_common_fields = {}
36+
for field in self.common_fields:
37+
record_dict_common_fields[field] = record_dict.pop(field, None)
38+
39+
records.append({**record_dict_common_fields, "data": record_dict})
40+
41+
return records

0 commit comments

Comments
 (0)