endpoints.comments.Comments.fetch()   A
last analyzed

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 Resource
2
3
4
# =======================================================
5
# Comments
6
# =======================================================
7
class Comments(Resource):
8
    def fetch(self,
9
              ticket_id: int):
10
        return self._get("/tickets/{ticket_id}/comments".format(ticket_id=ticket_id))
11
12
    def create(self,
13
               ticket_id:       str,
14
               content:         str,
15
               attachment_ids:  list = None,
16
               content_as_html: bool = False):
17
        comment = {
18
            "content": {
19
                "html" if content_as_html else "text": content,
20
            }
21
        }
22
23
        if attachment_ids is not None:
24
            comment["attachment_ids"] = ",".join(attachment_ids)
25
26
        self._post("/tickets/{ticket_id}/comments".format(ticket_id=ticket_id), data={"comment": comment})
27