| Total Complexity | 9 |
| Total Lines | 45 |
| 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 | content_as_html: bool = False): |
||
| 21 | reply = { |
||
| 22 | "content": { |
||
| 23 | "html" if content_as_html else "text": content, |
||
| 24 | }, |
||
| 25 | } |
||
| 26 | |||
| 27 | if cc is not None: |
||
| 28 | reply["cc"] = cc |
||
| 29 | if bcc is not None: |
||
| 30 | reply["bcc"] = bcc |
||
| 31 | if attachment_ids is not None: |
||
| 32 | reply["content"]["attachment_ids"] = attachment_ids |
||
| 33 | |||
| 34 | if on_behalf_of_id is not None: |
||
| 35 | reply["on_behalf_of"] = {"id": on_behalf_of_id} |
||
| 36 | elif on_behalf_of_email is not None: |
||
| 37 | reply["on_behalf_of"] = {"email": on_behalf_of_email} |
||
| 38 | |||
| 39 | return self._post("/tickets/{ticket_id}/replies".format(ticket_id=ticket_id), data={"reply": reply}) |
||
| 40 | |||
| 41 | def get(self, |
||
| 42 | ticket_id: int, |
||
| 43 | reply_id: int): |
||
| 44 | return self._get("/tickets/{ticket_id}/replies/{reply_id}".format(ticket_id=ticket_id, reply_id=reply_id)) |
||
| 45 |