Passed
Branch test (567fee)
by Alexis
01:21
created

comments.Comments.fetch()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
from base import *
2
3
# =======================================================
4
# Comments
5
# =======================================================
6
class Comments(Resource):
7
    def fetch(self,
8
              ticket_id: int):
9
        return self._get("/tickets/{ticket_id}/comments".format(ticket_id=ticket_id))
10
11
    def create(self,
12
               ticket_id:       str,
13
               content:         str,
14
               attachment_ids:  list = None,
15
               content_as_html: bool = False):
16
        comment = {
17
            "content": {
18
                "html" if content_as_html else "text": content,
19
            }
20
        }
21
22
        if attachment_ids is not None:
23
            comment["attachment_ids"] = ",".join(attachment_ids)
24
25
        self._post("/tickets/{ticket_id}/comments".format(ticket_id=ticket_id), data={"comment": comment})
26