Skip to content

Commit 103e003

Browse files
authored
🐛 Source Delighted: Fix pagination for survey_responses, bounces and unsubscribes streams (#9275)
* 9271 Fix pagination for delighted source * 9271 Implement change request * 9271 Implement change request * 9271 Bump connector's version
1 parent 5be2424 commit 103e003

File tree

7 files changed

+48
-50
lines changed

7 files changed

+48
-50
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
- name: Delighted
148148
sourceDefinitionId: cc88c43f-6f53-4e8a-8c4d-b284baaf9635
149149
dockerRepository: airbyte/source-delighted
150-
dockerImageTag: 0.1.0
150+
dockerImageTag: 0.1.1
151151
documentationUrl: https://docs.airbyte.io/integrations/sources/delighted
152152
icon: delighted.svg
153153
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@
12801280
supportsNormalization: false
12811281
supportsDBT: false
12821282
supported_destination_sync_modes: []
1283-
- dockerImage: "airbyte/source-delighted:0.1.0"
1283+
- dockerImage: "airbyte/source-delighted:0.1.1"
12841284
spec:
12851285
documentationUrl: "https://docsurl.com"
12861286
connectionSpecification:

airbyte-integrations/connectors/source-delighted/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.1.0
15+
LABEL io.airbyte.version=0.1.1
1616
LABEL io.airbyte.name=airbyte/source-delighted

airbyte-integrations/connectors/source-delighted/acceptance-test-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tests:
1515
- config_path: "secrets/config.json"
1616
configured_catalog_path: "integration_tests/configured_catalog.json"
1717
empty_streams: ["bounces"]
18-
incremental: # TODO if your connector does not implement incremental sync, remove this block
18+
incremental:
1919
- config_path: "secrets/config.json"
2020
configured_catalog_path: "integration_tests/configured_catalog.json"
2121
future_state_path: "integration_tests/abnormal_state.json"

airbyte-integrations/connectors/source-delighted/source_delighted/schemas/survey_responses.json

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@
2727
"type": ["null", "integer"]
2828
},
2929
"person_properties": {
30-
"type": "object"
30+
"type": ["object", "null"],
31+
"properties": {
32+
"Delighted Source": {
33+
"type": ["null", "string"]
34+
},
35+
"Delighted Device Type": {
36+
"type": ["null", "string"]
37+
},
38+
"Delighted Operating System": {
39+
"type": ["null", "string"]
40+
},
41+
"Delighted Browser": {
42+
"type": ["null", "string"]
43+
}
44+
}
3145
},
3246
"notes": {
3347
"type": "array",
@@ -76,12 +90,10 @@
7690
"text": {
7791
"type": "string"
7892
}
79-
},
80-
"required": ["id", "text"]
93+
}
8194
}
8295
}
83-
},
84-
"required": ["free_response", "scale", "select_one", "select_many"]
96+
}
8597
},
8698
"question": {
8799
"type": "object",
@@ -95,26 +107,10 @@
95107
"text": {
96108
"type": "string"
97109
}
98-
},
99-
"required": ["id", "type", "text"]
110+
}
100111
}
101-
},
102-
"required": ["id", "value", "question"]
112+
}
103113
}
104114
}
105-
},
106-
"required": [
107-
"id",
108-
"person",
109-
"survey_type",
110-
"score",
111-
"comment",
112-
"permalink",
113-
"created_at",
114-
"updated_at",
115-
"person_properties",
116-
"notes",
117-
"tags",
118-
"additional_answers"
119-
]
115+
}
120116
}

airbyte-integrations/connectors/source-delighted/source_delighted/source.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DelightedStream(HttpStream, ABC):
2323

2424
# Page size
2525
limit = 100
26+
page = 1
2627

2728
# Define primary key to all streams as primary key
2829
primary_key = "id"
@@ -32,12 +33,10 @@ def __init__(self, since: int, **kwargs):
3233
self.since = since
3334

3435
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
35-
# Getting next page link
36-
next_page = response.links.get("next", None)
37-
if next_page:
38-
return dict(parse_qsl(urlparse(next_page.get("url")).query))
39-
else:
40-
return None
36+
response_data = response.json()
37+
if len(response_data) == self.limit:
38+
self.page += 1
39+
return {"page": self.page}
4140

4241
def request_params(
4342
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None
@@ -49,8 +48,7 @@ def request_params(
4948
return params
5049

5150
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
52-
records = response.json()
53-
yield from records
51+
yield from response.json()
5452

5553

5654
class IncrementalDelightedStream(DelightedStream, ABC):
@@ -77,38 +75,36 @@ def request_params(self, stream_state=None, **kwargs):
7775

7876

7977
class People(IncrementalDelightedStream):
80-
def path(
81-
self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
82-
) -> str:
78+
def path(self, **kwargs) -> str:
8379
return "people.json"
8480

81+
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
82+
# Getting next page link
83+
next_page = response.links.get("next", None)
84+
if next_page:
85+
return {"page_info": dict(parse_qsl(urlparse(next_page.get("url")).query)).get("page_info")}
86+
8587

8688
class Unsubscribes(IncrementalDelightedStream):
8789
cursor_field = "unsubscribed_at"
8890
primary_key = "person_id"
8991

90-
def path(
91-
self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
92-
) -> str:
92+
def path(self, **kwargs) -> str:
9393
return "unsubscribes.json"
9494

9595

9696
class Bounces(IncrementalDelightedStream):
9797
cursor_field = "bounced_at"
9898
primary_key = "person_id"
9999

100-
def path(
101-
self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
102-
) -> str:
100+
def path(self, **kwargs) -> str:
103101
return "bounces.json"
104102

105103

106104
class SurveyResponses(IncrementalDelightedStream):
107105
cursor_field = "updated_at"
108106

109-
def path(
110-
self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
111-
) -> str:
107+
def path(self, **kwargs) -> str:
112108
return "survey_responses.json"
113109

114110
def request_params(self, stream_state=None, **kwargs):
@@ -148,4 +144,9 @@ def check_connection(self, logger, config) -> Tuple[bool, any]:
148144
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
149145
auth = self._get_authenticator(config)
150146
args = {"authenticator": auth, "since": config["since"]}
151-
return [People(**args), Unsubscribes(**args), Bounces(**args), SurveyResponses(**args)]
147+
return [
148+
Bounces(**args),
149+
People(**args),
150+
SurveyResponses(**args),
151+
Unsubscribes(**args),
152+
]

docs/integrations/sources/delighted.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ This connector supports `API PASSWORD` as the authentication method.
3737

3838
| Version | Date | Pull Request | Subject |
3939
| :--- | :--- | :--- | :--- |
40-
| 0.1.0 | 2021-10-27 | [4551](https://github.com/airbytehq/airbyte/pull/4551) | Add Delighted source connector |
40+
| 0.1.1 | 2022-01-04 | [9275](https://github.com/airbytehq/airbyte/pull/9275) | Fix pagination handling for `survey_responses`, `bounces` and `unsubscribes` streams |
41+
| 0.1.0 | 2021-10-27 | [4551](https://github.com/airbytehq/airbyte/pull/4551) | Add Delighted source connector |

0 commit comments

Comments
 (0)