-
Notifications
You must be signed in to change notification settings - Fork 1
/
tapi.py
72 lines (56 loc) · 1.4 KB
/
tapi.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def get_boards(auth_values: list):
import requests
from json import loads
key = auth_values[0]
token = auth_values[1]
params = {
'fields': 'id,name,shortLink',
'key': key,
'token': token
}
boards = loads(requests.get('https://api.trello.com/1/members/me/boards', params=params).text)
return boards
def get_lists(auth_values, board_id):
import requests
from json import loads
key = auth_values[0]
token = auth_values[1]
url = "https://api.trello.com/1/boards/" + board_id + "/lists"
query = {
'key': key,
'token': token,
'fields': 'id,name'
}
response = requests.request(
"GET",
url,
params=query
)
return loads(response.text)
def create_card(auth_values, list_id, name, description, due, complete: bool):
import requests
key = auth_values[0]
token = auth_values[1]
if complete:
dueComplete = "true"
else:
dueComplete = "false"
url = "https://api.trello.com/1/cards"
query = {
'key': key,
'token': token,
'idList': list_id,
'name': name,
'desc': description,
'due': due,
'dueComplete': dueComplete
}
response = requests.request(
"POST",
url,
params=query
)
if response.status_code == 200:
return 0
else:
return 1