Skip to content

Commit

Permalink
🎉 Source Intercom: Added conversation_id field to conversation_part r…
Browse files Browse the repository at this point in the history
…ecords (#11206)
  • Loading branch information
lgomezm authored Mar 25, 2022
1 parent 6662ccb commit 787daa9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
- name: Intercom
sourceDefinitionId: d8313939-3782-41b0-be29-b3ca20d8dd3a
dockerRepository: airbyte/source-intercom
dockerImageTag: 0.1.15
dockerImageTag: 0.1.16
documentationUrl: https://docs.airbyte.io/integrations/sources/intercom
icon: intercom.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3633,7 +3633,7 @@
oauthFlowInitParameters: []
oauthFlowOutputParameters:
- - "access_token"
- dockerImage: "airbyte/source-intercom:0.1.15"
- dockerImage: "airbyte/source-intercom:0.1.16"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/intercom"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-intercom/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ COPY source_intercom ./source_intercom
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.15
LABEL io.airbyte.version=0.1.16
LABEL io.airbyte.name=airbyte/source-intercom
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ class ConversationParts(ChildStreamMixin, IncrementalIntercomStream):
def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
return f"/conversations/{stream_slice['id']}"

def parse_response(self, response: requests.Response, stream_state: Mapping[str, Any], **kwargs) -> Iterable[Mapping]:
records = super().parse_response(response, stream_state, **kwargs)
conversation_id = response.json().get("id")
for conversation_part in records:
conversation_part.setdefault("conversation_id", conversation_id)
yield conversation_part


class Segments(IncrementalIntercomStream):
"""Return list of all segments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import requests
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources.streams.http.auth import NoAuth
from source_intercom.source import Companies, Contacts, IntercomStream
from source_intercom.source import Companies, Contacts, ConversationParts, IntercomStream

test_data = [
(
Expand Down Expand Up @@ -76,3 +76,35 @@ def test_switch_to_standard_endpoint_if_scroll_expired(requests_mock):
records += list(stream1.read_records(sync_mode=SyncMode, stream_slice=slice))

assert stream1._endpoint_type == Companies.EndpointType.standard


def test_conversation_part_has_conversation_id(requests_mock):
"""
Test shows that conversation_part records include the `conversation_id` field.
"""

response_body = {
"type": "conversation",
"id": "151272900024304",
"created_at": 1647365706,
"updated_at": 1647366443,
"conversation_parts": {
"type": "conversation_part.list",
"conversation_parts": [
{"type": "conversation_part", "id": "13740311965"},
{"type": "conversation_part", "id": "13740312024"},
],
"total_count": 2,
},
}
url = "https://api.intercom.io/conversations/151272900024304"
requests_mock.get(url, json=response_body)

stream1 = ConversationParts(authenticator=NoAuth())

record_count = 0
for record in stream1.read_records(sync_mode=SyncMode.incremental, stream_slice={"id": "151272900024304"}):
assert record["conversation_id"] == "151272900024304"
record_count += 1

assert record_count == 2
1 change: 1 addition & 0 deletions docs/integrations/sources/intercom.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Please read [How to get your Access Token](https://developers.intercom.com/build

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.16 | 2022-03-23 | [11206](https://github.com/airbytehq/airbyte/pull/11206) | Added conversation_id field to conversation_part records |
| 0.1.15 | 2022-03-22 | [11176](https://github.com/airbytehq/airbyte/pull/11176) | Correct `check_connection` URL |
| 0.1.14 | 2022-03-16 | [11208](https://github.com/airbytehq/airbyte/pull/11208) | Improve 'conversations' incremental sync speed |
| 0.1.13 | 2022-01-14 | [9513](https://github.com/airbytehq/airbyte/pull/9513) | Added handling of scroll param when it expired |
Expand Down

0 comments on commit 787daa9

Please sign in to comment.