Skip to content

Commit 6e353d3

Browse files
authored
Merge pull request #1 from MarletteFunding/feature/zendesk-adding-attributes-to-catalog
Feature/zendesk adding attributes to catalog
2 parents 1d8a633 + 73e181f commit 6e353d3

11 files changed

+185
-19
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ config.json
8989
!.vscode/launch.json
9090
!.vscode/extensions.json
9191
*.code-workspace
92+
93+
94+
.idea/

tap_zendesk_chat/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import singer
33
from singer.utils import handle_top_exception, parse_args
44

5-
from .context import Context
6-
from .discover import discover
7-
from .sync import sync
5+
from tap_zendesk_chat.context import Context
6+
from tap_zendesk_chat.discover import discover
7+
from tap_zendesk_chat.sync import sync
88

99
REQUIRED_CONFIG_KEYS = ["start_date", "access_token"]
1010
LOGGER = singer.get_logger()

tap_zendesk_chat/context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from singer import Catalog, write_state
55
from singer.utils import now
66

7-
from .http import Client
7+
from tap_zendesk_chat.http_client import Client
88

99

1010
class Context:

tap_zendesk_chat/discover.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from singer.catalog import Catalog
44
from singer.metadata import get_standard_metadata, to_list, to_map, write
55

6-
from .http import Client
7-
from .streams import STREAMS
8-
from .utils import load_schema
6+
from tap_zendesk_chat.http_client import Client
7+
from tap_zendesk_chat.streams import STREAMS
8+
from tap_zendesk_chat.utils import load_schema
99

1010
LOGGER = singer.get_logger()
1111

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"properties": {
3+
"id": {
4+
"type": [
5+
"string"
6+
]
7+
},
8+
"started_by": {
9+
"type": [
10+
"null",
11+
"string"
12+
]
13+
},
14+
"agent_id": {
15+
"type": [
16+
"null",
17+
"string"
18+
]
19+
},
20+
"agent_name": {
21+
"type": [
22+
"null",
23+
"string"
24+
]
25+
},
26+
"agent_full_name": {
27+
"type": [
28+
"null",
29+
"string"
30+
]
31+
},
32+
"department_id": {
33+
"type": [
34+
"null",
35+
"string"
36+
]
37+
},
38+
"assigned": {
39+
"type": [
40+
"null",
41+
"boolean"
42+
]
43+
},
44+
"accepted": {
45+
"type": [
46+
"null",
47+
"boolean"
48+
]
49+
},
50+
"rating": {
51+
"type": [
52+
"null",
53+
"string"
54+
]
55+
},
56+
"comment": {
57+
"type": [
58+
"null",
59+
"string"
60+
]
61+
},
62+
"skills_requested": {
63+
"items": {
64+
"type": [
65+
"null",
66+
"string"
67+
]
68+
},
69+
"type": [
70+
"null",
71+
"array"
72+
]
73+
},
74+
"skills_fulfilled": {
75+
"type": [
76+
"null",
77+
"boolean"
78+
]
79+
},
80+
"timestamp": {
81+
"type": [
82+
"null",
83+
"string"
84+
],
85+
"format": "date-time"
86+
},
87+
"duration": {
88+
"type": [
89+
"null",
90+
"string"
91+
]
92+
},
93+
"response_time": {
94+
"$ref": "chat_response_time"
95+
},
96+
"count": {
97+
"$ref": "chat_count"
98+
}
99+
},
100+
"type": [
101+
"null",
102+
"object"
103+
]
104+
}

tap_zendesk_chat/schemas/chats.json

+59-1
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,75 @@
1212
"string"
1313
]
1414
},
15+
"abandon_time": {
16+
"type": [
17+
"null",
18+
"string"
19+
]
20+
},
1521
"missed": {
1622
"type": [
1723
"null",
1824
"boolean"
1925
]
2026
},
27+
"deleted": {
28+
"type": [
29+
"null",
30+
"boolean"
31+
]
32+
},
33+
"dropped": {
34+
"type": [
35+
"null",
36+
"boolean"
37+
]
38+
},
39+
"proactive": {
40+
"type": [
41+
"null",
42+
"boolean"
43+
]
44+
},
45+
"skills_fulfilled": {
46+
"type": [
47+
"null",
48+
"boolean"
49+
]
50+
},
51+
"skills_requested": {
52+
"items": {
53+
"type": [
54+
"null",
55+
"string"
56+
]
57+
},
58+
"type": [
59+
"null",
60+
"array"
61+
]
62+
},
63+
"updated_timestamp": {
64+
"type": [
65+
"null",
66+
"string"
67+
]
68+
},
2169
"rating": {
2270
"type": [
2371
"null",
2472
"string"
2573
]
2674
},
75+
"engagements": {
76+
"items": {
77+
"$ref": "chat_engagement"
78+
},
79+
"type": [
80+
"null",
81+
"array"
82+
]
83+
},
2784
"conversions": {
2885
"items": {
2986
"$ref": "chat_conversion"
@@ -197,6 +254,7 @@
197254
"chat_history",
198255
"chat_response_time",
199256
"chat_visitor",
200-
"chat_webpath"
257+
"chat_webpath",
258+
"chat_engagement"
201259
]
202260
}

tap_zendesk_chat/streams.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from singer import Transformer, metrics
66
from singer.utils import strptime_to_utc
77

8-
from .utils import break_into_intervals
8+
from tap_zendesk_chat.utils import break_into_intervals
99

1010
LOGGER = singer.get_logger()
1111

@@ -142,20 +142,21 @@ def _pull(self, ctx, chat_type, ts_field, full_sync, schema: Dict, stream_metada
142142
for start_dt, end_dt in break_into_intervals(interval_days, start_time, ctx.now):
143143
while True:
144144
if next_url:
145-
search_resp = ctx.client.request(self.tap_stream_id, url=next_url)
145+
search_resp = ctx.client.request("incremental/" + self.tap_stream_id, url=next_url)
146146
else:
147-
params = {"q": f"type:{chat_type} AND {ts_field}:[{start_dt.isoformat()} TO {end_dt.isoformat()}]"}
148-
search_resp = ctx.client.request(self.tap_stream_id, params=params, url_extra="/search")
147+
# params = {"q": f"type:{chat_type} AND {ts_field}:[{start_dt.isoformat()} TO {end_dt.isoformat()}]"}
148+
params = {"start_time": int(start_dt.timestamp()), "fields": "chats(*)"}
149+
search_resp = ctx.client.request("incremental/" + self.tap_stream_id, params=params)
149150

150-
next_url = search_resp["next_url"]
151+
next_url = search_resp["next_page"]
151152
ctx.set_bookmark(url_offset_key, next_url)
152153
ctx.write_state()
153-
chats = self._bulk_chats(ctx, [r["id"] for r in search_resp["results"]])
154+
chats = search_resp.get("chats", [])
154155
if chats:
155156
chats = [transformer.transform(rec, schema, metadata=stream_metadata) for rec in chats]
156157
self.write_page(chats)
157-
max_bookmark = max(max_bookmark, *[c[ts_field] for c in chats])
158-
if not next_url:
158+
max_bookmark = max(max_bookmark, *[c[ts_field] for c in chats if c.get(ts_field)])
159+
if not chats or not next_url:
159160
break
160161
ctx.set_bookmark(ts_bookmark_key, max_bookmark)
161162
ctx.write_state()

tap_zendesk_chat/sync.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
write_state,
88
)
99

10-
from .streams import STREAMS
10+
from tap_zendesk_chat.streams import STREAMS
1111

1212
LOGGER = get_logger()
1313

tests/unittests/test_auth_discovery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from requests.exceptions import HTTPError
55

66
import tap_zendesk_chat
7-
from tap_zendesk_chat.http import Client
7+
from tap_zendesk_chat.http_client import Client
88

99

1010
# Mock args

tests/unittests/test_http_exceptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
from unittest import mock
33

4-
from tap_zendesk_chat.http import Client, RateLimitException
4+
from tap_zendesk_chat.http_client import Client, RateLimitException
55

66
client = Client({"access_token": ""})
77

0 commit comments

Comments
 (0)