Skip to content

Commit

Permalink
Issue airbytehq#1016: resolve tag #ref for mailchimp schemas (airbyte…
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhenii-ldv authored Nov 24, 2020
1 parent 8cd660d commit 16c5536
Show file tree
Hide file tree
Showing 9 changed files with 2,712 additions and 1,744 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sourceDefinitionId": "b03a9f3e-22a5-11eb-adc1-0242ac120002",
"name": "Mailchimp",
"dockerRepository": "airbyte/source-mailchimp",
"dockerImageTag": "0.1.3",
"dockerImageTag": "0.1.4",
"documentationUrl": "https://hub.docker.com/r/airbyte/source-mailchimp"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ COPY $CODE_PATH ./$CODE_PATH
COPY setup.py ./
RUN pip install ".[main]"

LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.version=0.1.4
LABEL io.airbyte.name=airbyte/source-mailchimp
4 changes: 2 additions & 2 deletions airbyte-integrations/connectors/source-mailchimp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
python main_dev.py spec
python main_dev.py check --config secrets/config.json
python main_dev.py discover --config secrets/config.json
python main_dev.py read --config secrets/config.json --catalog sample_files/catalog.json
python main_dev.py read --config secrets/config.json --catalog integration_tests/catalog.json
```

### Unit Tests
Expand All @@ -41,7 +41,7 @@ pytest unit_tests
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-mailchimp/sample_files:/sample_files airbyte/source-mailchimp:dev spec
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-mailchimp/sample_files:/sample_files airbyte/source-mailchimp:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-mailchimp/sample_files:/sample_files airbyte/source-mailchimp:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-mailchimp/sample_files:/sample_files airbyte/source-mailchimp:dev read --config /secrets/config.json --catalog /sample_files/catalog.json
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-mailchimp/sample_files:/sample_files airbyte/source-mailchimp:dev read --config /secrets/config.json --catalog /integration_tests/catalog.json
```

### Integration Tests
Expand Down

Large diffs are not rendered by default.

1,018 changes: 0 additions & 1,018 deletions airbyte-integrations/connectors/source-mailchimp/sample_files/catalog.json

This file was deleted.

2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-mailchimp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"pydantic==1.6.1",
"mailchimp3==3.0.14",
],
package_data={"": ["*.json"]},
package_data={"": ["*.json", "schemas/*.json"]},
setup_requires=["pytest-runner"],
tests_require=["pytest"],
extras_require={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
SOFTWARE.
"""

import requests
import json
import pkgutil

from airbyte_protocol import AirbyteStream
from mailchimp3 import MailChimp
from mailchimp3.mailchimpclient import MailChimpError
Expand All @@ -31,28 +33,12 @@


class Client:
API_MAILCHIMP_URL = "https://api.mailchimp.com/schema/3.0/Definitions/{}/Response.json"
PAGINATION = 100

def __init__(self, username: str, apikey: str):
self._client = MailChimp(mc_api=apikey, mc_user=username)
self._entities = ["Lists", "Campaigns"]

""" TODO:
Authorized Apps
Automations
Campaign Folders
Chimp Chatter Activity
Connected Sites
Conversations
E-Commerce Stores
Facebook Ads
Files
Landing Pages
Ping
Reports
"""

def health_check(self):
try:
self._client.ping.get()
Expand All @@ -62,9 +48,9 @@ def health_check(self):

def get_streams(self):
streams = []
for entity in self._entities:
json_schema = requests.get(self.API_MAILCHIMP_URL.format(entity)).json()
streams.append(AirbyteStream(name=entity, json_schema=json_schema))
for schema in self._entities:
raw_schema = json.loads(pkgutil.get_data(self.__class__.__module__.split(".")[0], f"schemas/{schema}.json"))
streams.append(AirbyteStream(name=schema, json_schema=raw_schema))
return streams

def lists(self):
Expand Down
Loading

0 comments on commit 16c5536

Please sign in to comment.