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