flock-core 0.4.0b7__py3-none-any.whl → 0.4.0b8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of flock-core might be problematic. Click here for more details.
- flock/core/tools/zendesk_tools.py +26 -18
- {flock_core-0.4.0b7.dist-info → flock_core-0.4.0b8.dist-info}/METADATA +1 -1
- {flock_core-0.4.0b7.dist-info → flock_core-0.4.0b8.dist-info}/RECORD +6 -6
- {flock_core-0.4.0b7.dist-info → flock_core-0.4.0b8.dist-info}/WHEEL +0 -0
- {flock_core-0.4.0b7.dist-info → flock_core-0.4.0b8.dist-info}/entry_points.txt +0 -0
- {flock_core-0.4.0b7.dist-info → flock_core-0.4.0b8.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"""Tools for interacting with Zendesk."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
from collections.abc import Generator
|
|
5
4
|
|
|
6
5
|
import httpx
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
ZENDESK_API_TOKEN = os.getenv("ZENDESK_API_TOKEN")
|
|
7
|
+
ZENDESK_BEARER_TOKEN = os.getenv("ZENDESK_BEARER_TOKEN")
|
|
10
8
|
|
|
9
|
+
HEADERS = {
|
|
10
|
+
"Authorization": f"Bearer {ZENDESK_BEARER_TOKEN}",
|
|
11
|
+
"Accept": "application/json",
|
|
12
|
+
}
|
|
11
13
|
|
|
12
|
-
AUTH = (f"{ZENDESK_EMAIL}/token", ZENDESK_API_TOKEN)
|
|
13
|
-
HEADERS = {"Accept": "application/json"}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
def get_tickets() -> Generator[dict, None, None]:
|
|
15
|
+
def get_tickets(number_of_tickets: int = 10) -> list[dict]:
|
|
17
16
|
"""Get all tickets."""
|
|
18
17
|
ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_TICKET")
|
|
19
18
|
BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
|
|
20
19
|
url = f"{BASE_URL}/api/v2/tickets.json"
|
|
21
|
-
|
|
22
|
-
with httpx.Client(
|
|
23
|
-
while url:
|
|
20
|
+
all_tickets = []
|
|
21
|
+
with httpx.Client(headers=HEADERS, timeout=30.0) as client:
|
|
22
|
+
while url and len(all_tickets) < number_of_tickets:
|
|
24
23
|
response = client.get(url)
|
|
25
24
|
response.raise_for_status()
|
|
26
25
|
|
|
27
26
|
data = response.json()
|
|
28
27
|
tickets = data.get("tickets", [])
|
|
29
|
-
|
|
28
|
+
all_tickets.extend(tickets)
|
|
30
29
|
|
|
31
30
|
url = data.get("next_page")
|
|
31
|
+
return all_tickets
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def get_ticket_by_id(ticket_id: str) -> dict:
|
|
@@ -36,10 +36,21 @@ def get_ticket_by_id(ticket_id: str) -> dict:
|
|
|
36
36
|
ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_TICKET")
|
|
37
37
|
BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
|
|
38
38
|
url = f"{BASE_URL}/api/v2/tickets/{ticket_id}"
|
|
39
|
-
with httpx.Client(
|
|
39
|
+
with httpx.Client(headers=HEADERS, timeout=30.0) as client:
|
|
40
|
+
response = client.get(url)
|
|
41
|
+
response.raise_for_status()
|
|
42
|
+
return response.json()["ticket"]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_comments_by_ticket_id(ticket_id: str) -> list[dict]:
|
|
46
|
+
"""Get all comments for a ticket."""
|
|
47
|
+
ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_TICKET")
|
|
48
|
+
BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
|
|
49
|
+
url = f"{BASE_URL}/api/v2/tickets/{ticket_id}/comments"
|
|
50
|
+
with httpx.Client(headers=HEADERS, timeout=30.0) as client:
|
|
40
51
|
response = client.get(url)
|
|
41
52
|
response.raise_for_status()
|
|
42
|
-
return response.json()
|
|
53
|
+
return response.json()["comments"]
|
|
43
54
|
|
|
44
55
|
|
|
45
56
|
def get_article_by_id(article_id: str) -> dict:
|
|
@@ -50,10 +61,7 @@ def get_article_by_id(article_id: str) -> dict:
|
|
|
50
61
|
url = (
|
|
51
62
|
f"{BASE_URL}/api/v2/help_center/{ZENDESK_LOCALE}/articles/{article_id}"
|
|
52
63
|
)
|
|
53
|
-
with httpx.Client(
|
|
64
|
+
with httpx.Client(headers=HEADERS, timeout=30.0) as client:
|
|
54
65
|
response = client.get(url)
|
|
55
66
|
response.raise_for_status()
|
|
56
|
-
return response.json()
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# get_ticket_by_id("366354")
|
|
67
|
+
return response.json()["article"]
|
|
@@ -68,7 +68,7 @@ flock/core/tools/azure_tools.py,sha256=hwLnI2gsEq6QzUoWj5eCGDKTdXY1XUf6K-H5Uwva2
|
|
|
68
68
|
flock/core/tools/basic_tools.py,sha256=Ye7nlI4RRkqWRy8nH9CKuItBmh_ZXxUpouGnCOfx0s0,9050
|
|
69
69
|
flock/core/tools/llm_tools.py,sha256=Bdt4Dpur5dGpxd2KFEQyxjfZazvW1HCDKY6ydMj6UgQ,21811
|
|
70
70
|
flock/core/tools/markdown_tools.py,sha256=W6fGM48yGHbifVlaOk1jOtVcybfRbRmf20VbDOZv8S4,6031
|
|
71
|
-
flock/core/tools/zendesk_tools.py,sha256=
|
|
71
|
+
flock/core/tools/zendesk_tools.py,sha256=0JRD48Uu27Hrb3aqVSvIieZ1kK6R-WUr2UzCgo9jDhk,2314
|
|
72
72
|
flock/core/tools/dev_tools/github.py,sha256=a2OTPXS7kWOVA4zrZHynQDcsmEi4Pac5MfSjQOLePzA,5308
|
|
73
73
|
flock/core/util/cli_helper.py,sha256=mbxFhAGDES1AySbz5D672Az-EWk88FIvtFIGJMEp6fc,49800
|
|
74
74
|
flock/core/util/file_path_utils.py,sha256=Odf7uU32C-x1KNighbNERSiMtkzW4h8laABIoFK7A5M,6246
|
|
@@ -439,8 +439,8 @@ flock/workflow/activities.py,sha256=eVZDnxGJl_quNO-UTV3YgvTV8LrRaHN3QDAA1ANKzac,
|
|
|
439
439
|
flock/workflow/agent_activities.py,sha256=NhBZscflEf2IMfSRa_pBM_TRP7uVEF_O0ROvWZ33eDc,963
|
|
440
440
|
flock/workflow/temporal_setup.py,sha256=VWBgmBgfTBjwM5ruS_dVpA5AVxx6EZ7oFPGw4j3m0l0,1091
|
|
441
441
|
flock/workflow/workflow.py,sha256=I9MryXW_bqYVTHx-nl2epbTqeRy27CAWHHA7ZZA0nAk,1696
|
|
442
|
-
flock_core-0.4.
|
|
443
|
-
flock_core-0.4.
|
|
444
|
-
flock_core-0.4.
|
|
445
|
-
flock_core-0.4.
|
|
446
|
-
flock_core-0.4.
|
|
442
|
+
flock_core-0.4.0b8.dist-info/METADATA,sha256=LpE239lDyLKUciiPEGU1ySTsCewH6IMqSMENlm30Ehk,21100
|
|
443
|
+
flock_core-0.4.0b8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
444
|
+
flock_core-0.4.0b8.dist-info/entry_points.txt,sha256=rWaS5KSpkTmWySURGFZk6PhbJ87TmvcFQDi2uzjlagQ,37
|
|
445
|
+
flock_core-0.4.0b8.dist-info/licenses/LICENSE,sha256=iYEqWy0wjULzM9GAERaybP4LBiPeu7Z1NEliLUdJKSc,1072
|
|
446
|
+
flock_core-0.4.0b8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|