Skip to content

Commit

Permalink
🎉 Source Typeform: support pulling data from a select set of forms
Browse files Browse the repository at this point in the history
* Source Typeform #6319 - add form_ids to spec for specifying set of forms

* Source Typeform #6319 - improving description in spec, verifying if forms inputted by the user are valid

* Source Typeform #6319 - fixing check connections

* Source Typeform #6319 - improving form ids validation error message

* Source Typeform #6319 - bump and update changelog
  • Loading branch information
vitaliizazmic authored Oct 12, 2021
1 parent 51a2e45 commit 6a28488
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sourceDefinitionId": "e7eff203-90bf-43e5-a240-19ea3056c474",
"name": "Typeform",
"dockerRepository": "airbyte/source-typeform",
"dockerImageTag": "0.1.1",
"dockerImageTag": "0.1.2",
"documentationUrl": "https://docs.airbyte.io/integrations/sources/typeform"
}
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
- sourceDefinitionId: e7eff203-90bf-43e5-a240-19ea3056c474
name: Typeform
dockerRepository: airbyte/source-typeform
dockerImageTag: 0.1.1
dockerImageTag: 0.1.2
documentationUrl: https://docs.airbyte.io/integrations/sources/typeform
sourceType: api
- sourceDefinitionId: bb1a6d31-6879-4819-a2bd-3eed299ea8e2
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-typeform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.name=airbyte/source-typeform
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ def request_params(

class TrimFormsMixin:
def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, any]]]:
for item in TrimForms(**self.config).read_records(sync_mode=SyncMode.full_refresh):
yield {"form_id": item["id"]}
form_ids = self.config.get("form_ids", [])
if form_ids:
for item in form_ids:
yield {"form_id": item}
else:
for item in TrimForms(**self.config).read_records(sync_mode=SyncMode.full_refresh):
yield {"form_id": item["id"]}

yield from []

Expand Down Expand Up @@ -196,10 +201,14 @@ def request_params(
class SourceTypeform(AbstractSource):
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:
try:
url = f"{TypeformStream.url_base}/forms"
auth_headers = {"Authorization": f"Bearer {config['token']}"}
session = requests.get(url, headers=auth_headers)
session.raise_for_status()
form_ids = config.get("form_ids", []).copy()
auth = TokenAuthenticator(token=config["token"])
# verify if form inputted by user is valid
for form in TrimForms(authenticator=auth, **config).read_records(sync_mode=SyncMode.full_refresh):
if form.get("id") in form_ids:
form_ids.remove(form.get("id"))
if form_ids:
return False, f"Cannot find forms with IDs: {form_ids}. Please make sure they are valid form IDs and try again."
return True, None
except requests.exceptions.RequestException as e:
return False, e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"type": "string",
"description": "The API Token for a Typeform account.",
"airbyte_secret": true
},
"form_ids": {
"title": "Form IDs to replicate",
"description": "When this parameter is set, the connector will replicate data only from the input forms. Otherwise, all forms in your Typeform account will be replicated. You can find form IDs in your form URLs. For example, in the URL \"https://mysite.typeform.com/to/u6nXL7\" the form_id is u6nXL7. You can find form URLs on Share panel",
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/typeform.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ API rate limits \(2 requests per second\): [https://developer.typeform.com/get-s

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.2 | 2021-10-11 | [6571](https://github.com/airbytehq/airbyte/pull/6571) | Support pulling data from a select set of forms |
| 0.1.1 | 2021-09-06 | [5799](https://github.com/airbytehq/airbyte/pull/5799) | Add missed choices field to responses schema |
| 0.1.0 | 2021-07-10 | [4541](https://github.com/airbytehq/airbyte/pull/4541) | Initial release for Typeform API supporting Forms and Responses streams |

0 comments on commit 6a28488

Please sign in to comment.