Skip to content

Commit

Permalink
✨Source Iterable: Migrate to low code (#36231)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazebnyi committed Apr 15, 2024
1 parent 98478f0 commit 0c49832
Show file tree
Hide file tree
Showing 18 changed files with 837 additions and 520 deletions.
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 @@ -31,5 +31,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 <contact@airbyte.io>",]
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

0 comments on commit 0c49832

Please sign in to comment.