2021-11-06 21:27:27 +01:00
|
|
|
import requests
|
|
|
|
|
|
|
|
|
2021-12-29 11:10:56 +01:00
|
|
|
def convert_to_todoist(tickets):
|
|
|
|
# TODO: add a function to convert mantis priority to todoist priority
|
|
|
|
tasks = []
|
|
|
|
for ticket in tickets:
|
|
|
|
url = ("https://contria.mantishub.io/view.php?id="
|
|
|
|
+ str(ticket["id"]))
|
|
|
|
content = "[{title}]({url})".format(title=ticket["summary"],
|
|
|
|
url=url)
|
|
|
|
tasks.append({"content": content, "label_ids": [2158784659, ]})
|
|
|
|
return tasks
|
|
|
|
|
|
|
|
|
2021-11-06 21:27:27 +01:00
|
|
|
class MantishubAPI:
|
|
|
|
url = "https://contria.mantishub.io/api/rest/"
|
|
|
|
|
|
|
|
def __init__(self, token: str):
|
|
|
|
self.token = token
|
|
|
|
|
|
|
|
def get_tickets(self):
|
|
|
|
response = requests.get(
|
|
|
|
self.url + "issues?filter_id=assigned",
|
|
|
|
headers={"Authorization": self.token})
|
|
|
|
tickets = response.json()
|
2021-12-29 11:10:56 +01:00
|
|
|
return convert_to_todoist(tickets["issues"])
|