todoist_interface/todoist_interface/mantishub.py

27 lines
887 B
Python
Raw Normal View History

2021-11-06 21:27:27 +01:00
import requests
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()
return self.convert_to_todoist(tickets)
def convert_to_todoist(self, tickets):
2021-11-06 21:38:25 +01:00
# TODO: add a function to convert mantis priority to todoist priority
# TODO: add a function to create the url
2021-11-06 21:27:27 +01:00
tasks = []
2021-11-06 21:38:25 +01:00
for ticket in tickets:
url = "https:mantishub.com"
content = "[{title}]({url})".format(title=ticket["summary"],
url=url)
tasks.append({"content": content, "label_ids": [2158784659, ]})
2021-11-06 21:27:27 +01:00
return tasks