🗃️ Trello Card fetcher
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
[Trello]
|
||||
TrelloAPIKey=
|
||||
APIKey=
|
||||
APIToken=
|
||||
BoardID=
|
||||
|
||||
[SMTP]
|
||||
Server=
|
||||
|
44
main.py
44
main.py
@ -1,5 +1,12 @@
|
||||
from configparser import ConfigParser
|
||||
from shutil import copy
|
||||
from requests import request
|
||||
|
||||
### Constants
|
||||
|
||||
TRELLO_API_CARDS_URL = "https://api.trello.com/1/boards/{id}/cards"
|
||||
|
||||
###
|
||||
|
||||
# TODO: Set up actual logging
|
||||
def log(text: str):
|
||||
@ -36,16 +43,43 @@ def read_config() -> dict:
|
||||
|
||||
return config_dict
|
||||
|
||||
def get_trello_cards(config: dict) -> list[dict]:
|
||||
"""
|
||||
Returns a list of every card in the Trello board, each a dict.
|
||||
"""
|
||||
url = TRELLO_API_CARDS_URL.format(id=config["Trello"]["boardid"])
|
||||
query = {
|
||||
'key': config["Trello"]["apikey"],
|
||||
'token': config["Trello"]["apitoken"]
|
||||
}
|
||||
|
||||
# Calling the API
|
||||
response = request(
|
||||
"GET",
|
||||
url,
|
||||
params=query
|
||||
)
|
||||
|
||||
# Making a list of cards with relevant information
|
||||
cards = [
|
||||
{
|
||||
"id": card["id"],
|
||||
"name": card["name"],
|
||||
"lastActivity": card["dateLastActivity"],
|
||||
"memberIDs": card["idMembers"],
|
||||
"labels": [label["name"] for label in card["labels"]]
|
||||
}
|
||||
for card in response.json()
|
||||
]
|
||||
|
||||
return cards
|
||||
|
||||
def main():
|
||||
# Reading the config file
|
||||
config = read_config()
|
||||
|
||||
# Step 2:
|
||||
# Get data from Trello API
|
||||
# - Time each card has been in the step it's in
|
||||
# - Escalation level
|
||||
# - Who is assigned (as well as their email)
|
||||
# Getting the cards from Trello
|
||||
submissions = get_trello_cards(config)
|
||||
|
||||
# Step 3:
|
||||
# For each card, compare to escalation rules to see if it's at the step
|
||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
requests==2.32.3
|
Reference in New Issue
Block a user