Skip to content

Commit 1e86a1a

Browse files
iirosokkaCopilottobiascadee
authored
add articles stream (#53)
* clean up unnecessary properties * add articles schema * include description Co-authored-by: Copilot <[email protected]> * fix linter errors * fix linter errors take 2 * Update tap_intercom/streams.py Co-authored-by: Tobias Cadée <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Tobias Cadée <[email protected]>
1 parent 3201bc6 commit 1e86a1a

File tree

3 files changed

+88
-71
lines changed

3 files changed

+88
-71
lines changed

tap_intercom/schemas.py

Lines changed: 79 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,41 @@
1010
StringType,
1111
)
1212

13+
# define languages for translated articles content, add here to include
14+
languages = [
15+
"bg",
16+
"cs",
17+
"de",
18+
"en",
19+
"es",
20+
"fr",
21+
"hu",
22+
"it",
23+
"nb",
24+
"nl",
25+
"pl",
26+
"pt",
27+
"pt-BR",
28+
"sk",
29+
"sv",
30+
]
31+
32+
# define translated content articles schema to avoid repetition
33+
translated_content = [
34+
Property(
35+
lang,
36+
ObjectType(
37+
Property("title", StringType),
38+
Property("description", StringType),
39+
Property("author_id", IntegerType),
40+
Property("state", StringType),
41+
Property("created_at", IntegerType),
42+
Property("updated_at", IntegerType),
43+
),
44+
) for lang in languages
45+
]
46+
1347
conversations_schema = PropertiesList(
14-
Property("type", StringType),
1548
Property("id", StringType),
1649
Property("title", StringType),
1750
Property("created_at", IntegerType),
@@ -27,12 +60,10 @@
2760
Property(
2861
"tags",
2962
ObjectType(
30-
Property("type", StringType),
3163
Property(
3264
"tags",
3365
ArrayType(
3466
ObjectType(
35-
Property("type", StringType),
3667
Property("id", StringType),
3768
Property("name", StringType),
3869
Property("applied_at", IntegerType),
@@ -57,15 +88,12 @@
5788
Property(
5889
"contact",
5990
ObjectType(
60-
Property("type", StringType),
6191
Property("id", StringType),
62-
Property("external_id", StringType),
6392
),
6493
),
6594
Property(
6695
"teammate",
6796
ObjectType(
68-
Property("type", StringType),
6997
Property("id", StringType),
7098
),
7199
),
@@ -109,7 +137,6 @@
109137
Property(
110138
"contacts",
111139
ObjectType(
112-
Property("type", StringType),
113140
Property(
114141
"contacts",
115142
ArrayType(
@@ -125,12 +152,10 @@
125152
Property(
126153
"teammates",
127154
ObjectType(
128-
Property("type", StringType),
129155
Property(
130156
"teammates",
131157
ArrayType(
132158
ObjectType(
133-
Property("type", StringType),
134159
Property("id", StringType),
135160
)
136161
),
@@ -148,15 +173,13 @@
148173
Property(
149174
"sla_applied",
150175
ObjectType(
151-
Property("type", StringType),
152176
Property("sla_name", StringType),
153177
Property("sla_status", StringType),
154178
),
155179
),
156180
Property(
157181
"statistics",
158182
ObjectType(
159-
Property("type", StringType),
160183
Property("time_to_assignment", IntegerType),
161184
Property("time_to_admin_reply", IntegerType),
162185
Property("time_to_first_close", IntegerType),
@@ -180,14 +203,11 @@
180203
Property(
181204
"linked_objects",
182205
ObjectType(
183-
Property("type", StringType),
184206
Property("total_count", IntegerType),
185-
Property("has_more", BooleanType),
186207
Property(
187208
"data",
188209
ArrayType(
189210
ObjectType(
190-
Property("type", StringType),
191211
Property("id", StringType),
192212
Property("category", StringType),
193213
)
@@ -201,7 +221,6 @@
201221
Property(
202222
"active_draft",
203223
ObjectType(
204-
Property("type", StringType),
205224
Property(
206225
"instances",
207226
ArrayType(
@@ -216,7 +235,6 @@
216235
Property("has_errors", BooleanType),
217236
),
218237
),
219-
Property("type", StringType),
220238
),
221239
),
222240
),
@@ -231,7 +249,6 @@
231249
Property(
232250
"latest_bought_listings",
233251
ObjectType(
234-
Property("type", StringType),
235252
Property(
236253
"instances",
237254
ArrayType(
@@ -246,7 +263,6 @@
246263
Property("sellerId", StringType),
247264
),
248265
),
249-
Property("type", StringType),
250266
),
251267
),
252268
),
@@ -255,7 +271,6 @@
255271
Property(
256272
"selected_bought_listing",
257273
ObjectType(
258-
Property("type", StringType),
259274
Property(
260275
"instances",
261276
ArrayType(
@@ -270,7 +285,6 @@
270285
Property("sellerId", StringType),
271286
),
272287
),
273-
Property("type", StringType),
274288
),
275289
),
276290
),
@@ -279,7 +293,6 @@
279293
Property(
280294
"last_payout",
281295
ObjectType(
282-
Property("type", StringType),
283296
Property(
284297
"instances",
285298
ArrayType(
@@ -308,7 +321,6 @@
308321
).to_dict()
309322

310323
conversation_parts_schema = PropertiesList(
311-
Property("type", StringType),
312324
Property("id", StringType),
313325
Property("conversation_id", StringType),
314326
Property("part_type", StringType),
@@ -348,19 +360,23 @@
348360
),
349361
Property("external_id", StringType),
350362
Property("redacted", BooleanType),
363+
Property(
364+
"conversation_part_has_body",
365+
BooleanType,
366+
description = (
367+
"Indicates whether this conversation part contains a non-empty body. "
368+
"True if the body field is present and not empty, false otherwise."
369+
),
370+
),
351371
).to_dict()
352372

353373
admins_schema = PropertiesList(
354-
Property("type", StringType),
355374
Property("id", StringType),
356375
Property("name", StringType),
357-
Property("email", StringType),
358-
Property("job_title", StringType),
359376
Property("away_mode_enabled", BooleanType),
360377
Property("away_mode_reassign", BooleanType),
361378
Property("has_inbox_seat", BooleanType),
362379
Property("team_ids", ArrayType(IntegerType)),
363-
Property("avatar", StringType),
364380
Property(
365381
"team_priority_level",
366382
ObjectType(
@@ -371,11 +387,8 @@
371387
).to_dict()
372388

373389
tags_schema = PropertiesList(
374-
Property("type", StringType),
375390
Property("id", StringType),
376391
Property("name", StringType),
377-
Property("applied_at", IntegerType),
378-
Property("applied_by", ObjectType(Property("type", StringType), Property("id", StringType))),
379392
).to_dict()
380393

381394
teams_schema = PropertiesList(
@@ -395,40 +408,11 @@
395408
contacts_schema = PropertiesList(
396409
Property("type", StringType),
397410
Property("id", StringType, description="The unique identifier for the contact"),
398-
Property("workspace_id", StringType, description="The ID of the workspace the contact belongs to"),
399411
Property(
400412
"external_id",
401413
StringType,
402414
description="An external identifier for the contact, set by the integrating application",
403415
),
404-
Property("role", StringType, description="The role of the contact, either user or lead"),
405-
Property("email", StringType, description="The email address of the contact"),
406-
Property("phone", StringType, description="The phone number of the contact"),
407-
Property("name", StringType, description="The name of the contact"),
408-
Property(
409-
"avatar",
410-
ObjectType(
411-
Property("type", StringType, description="The type of object"),
412-
Property("image_url", StringType, description="URL of the contact's avatar image"),
413-
),
414-
),
415-
Property("owner_id", IntegerType, description="The ID of the teammate who owns this contact"),
416-
Property(
417-
"social_profiles",
418-
ObjectType(
419-
Property(
420-
"data",
421-
ArrayType(
422-
ObjectType(
423-
Property("type", StringType),
424-
Property("name", StringType),
425-
Property("url", StringType),
426-
),
427-
),
428-
),
429-
),
430-
description="A list of social profiles associated with the contact",
431-
),
432416
Property(
433417
"has_hard_bounced",
434418
BooleanType,
@@ -479,7 +463,6 @@
479463
),
480464
description="An object containing location meta data about a Intercom contact.",
481465
),
482-
Property("ip", StringType, description="The IP address of the contact"),
483466
Property("utm_source", StringType, description="The UTM source parameter from the contact's signup URL"),
484467
Property("utm_medium", StringType, description="The UTM medium parameter from the contact's signup URL"),
485468
Property("utm_campaign", StringType, description="The UTM campaign parameter from the contact's signup URL"),
@@ -494,13 +477,10 @@
494477
ObjectType(
495478
Property("type", StringType),
496479
Property("id", StringType),
497-
Property("url", StringType),
498480
),
499481
),
500482
),
501-
Property("url", StringType),
502483
Property("total_count", IntegerType),
503-
Property("has_more", BooleanType),
504484
),
505485
description="Tags associated with the contact",
506486
),
@@ -513,24 +493,52 @@
513493
ObjectType(
514494
Property("type", StringType),
515495
Property("id", StringType),
516-
Property("url", StringType),
517496
),
518497
),
519498
),
520-
Property("url", StringType),
521499
Property("total_count", IntegerType),
522-
Property("has_more", BooleanType),
523500
),
524501
description="Notes associated with the contact",
525502
),
503+
Property("custom_attributes", ObjectType(), description="Custom attributes associated with the contact"),
504+
).to_dict()
505+
506+
articles_schema = PropertiesList(
507+
Property("id", StringType),
508+
Property("parent_type", StringType),
509+
Property("parent_ids", ArrayType(IntegerType)),
510+
Property(
511+
"translated_content",
512+
ObjectType(*translated_content),
513+
),
514+
Property("languages", ArrayType(StringType)),
526515
Property(
527-
"companies",
516+
"tags",
528517
ObjectType(
529-
Property("url", StringType),
530-
Property("total_count", IntegerType),
531-
Property("has_more", BooleanType),
518+
Property(
519+
"tags",
520+
ArrayType(
521+
ObjectType(
522+
Property("id", StringType),
523+
Property("name", StringType),
524+
Property("applied_at", IntegerType),
525+
Property(
526+
"applied_by",
527+
ObjectType(
528+
Property("type", StringType),
529+
Property("id", StringType),
530+
),
531+
),
532+
),
533+
),
534+
),
532535
),
533-
description="Notes associated with the contact",
534536
),
535-
Property("custom_attributes", ObjectType(), description="Custom attributes associated with the contact"),
537+
Property("title", StringType),
538+
Property("description", StringType),
539+
Property("body", StringType),
540+
Property("author_id", IntegerType),
541+
Property("state", StringType),
542+
Property("created_at", IntegerType),
543+
Property("updated_at", IntegerType),
536544
).to_dict()

tap_intercom/streams.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from tap_intercom.client import IntercomStream
88
from tap_intercom.schemas import (
99
admins_schema,
10+
articles_schema,
1011
contacts_schema,
1112
conversation_parts_schema,
1213
conversations_schema,
@@ -90,3 +91,10 @@ class ContactsStream(IntercomStream):
9091
replication_key = "updated_at"
9192
http_method = "POST"
9293
schema = contacts_schema
94+
95+
class ArticlesStream(IntercomStream):
96+
"""Stream for Intercom articles."""
97+
98+
name = "articles"
99+
path = "/articles"
100+
schema = articles_schema

tap_intercom/tap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def discover_streams(self) -> list[streams.IntercomStream]:
5757
streams.TagsStream(self),
5858
streams.TeamsStream(self),
5959
streams.ContactsStream(self),
60+
streams.ArticlesStream(self),
6061
]
6162

6263

0 commit comments

Comments
 (0)