-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrello.py.example
More file actions
39 lines (36 loc) · 1.19 KB
/
trello.py.example
File metadata and controls
39 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import secrets
# API url variables
url = 'https://api.trello.com/1/'
url_lists = url + 'lists/'
url_cards = url + 'cards/'
url_members = url + 'members/me/boards'
url_boards = url + 'boards/'
tokens = '?key=%s&token=%s' % (secrets.trello_api_key, secrets.trello_api_token)
# Boards / Lists to check if you need to statically list them
trello_boards = [
{
'name': 'Board Name',
'id': 'Board Id',
'lists': [
{
'name': 'List Name',
'id': 'List Id'
}
]
}
]
# The trello_boards object could be built programmatically if boards and lists are named consistently. An example is below but is not used to pull this report.
def get_trello_boards():
trello_boards = []
boards_json = requests.request('GET', trello.url_members + trello.tokens).json()
for b in boards_json:
if b['name'].startswith('Support -'):
lists_json = requests.request('GET', trello.url_boards + b['id'] + '/lists' + trello.tokens).json()
for l in lists_json:
if 'Waiting' in l['name']:
trello_boards.append({
'name': b['name'], 'id': b['id'], 'lists': [
{'name': l['name'], 'id': l['id']}
]
})
return trello_boards