Total Complexity | 9 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from .base import Resource |
||
2 | |||
3 | |||
4 | # ======================================================= |
||
5 | # Replies |
||
6 | # ======================================================= |
||
7 | class Replies(Resource): |
||
8 | def fetch(self, |
||
9 | ticket_id: int): |
||
10 | return self._get("/tickets/{ticket_id}/replies".format(ticket_id=ticket_id)) |
||
11 | |||
12 | def create(self, |
||
13 | ticket_id: int, |
||
14 | content: str, |
||
15 | cc: str = None, |
||
16 | bcc: str = None, |
||
17 | attachment_ids: str = None, |
||
18 | on_behalf_of_id: str = None, |
||
19 | on_behalf_of_email: str = None, |
||
20 | notify_requester: str = False, |
||
21 | content_as_html: bool = False): |
||
22 | reply = { |
||
23 | "content": { |
||
24 | "html" if content_as_html else "text": content, |
||
25 | }, |
||
26 | "notify_requester": notify_requester |
||
27 | } |
||
28 | |||
29 | if cc is not None: |
||
30 | reply["cc"] = cc |
||
31 | if bcc is not None: |
||
32 | reply["bcc"] = bcc |
||
33 | if attachment_ids is not None: |
||
34 | reply["content"]["attachment_ids"] = attachment_ids |
||
35 | |||
36 | if on_behalf_of_id is not None: |
||
37 | reply["on_behalf_of"] = {"id": on_behalf_of_id} |
||
38 | elif on_behalf_of_email is not None: |
||
39 | reply["on_behalf_of"] = {"email": on_behalf_of_email} |
||
40 | |||
41 | return self._post("/tickets/{ticket_id}/replies".format(ticket_id=ticket_id), data={"reply": reply}) |
||
42 | |||
43 | def get(self, |
||
44 | ticket_id: int, |
||
45 | reply_id: int): |
||
46 | return self._get("/tickets/{ticket_id}/replies/{reply_id}".format(ticket_id=ticket_id, reply_id=reply_id)) |
||
47 |