-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyTrello.py
More file actions
80 lines (63 loc) · 2.33 KB
/
MyTrello.py
File metadata and controls
80 lines (63 loc) · 2.33 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
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
72
73
74
75
76
77
78
79
80
import requests
import json
class myTrello:
def __init__(self, user):
self.user = user
self.boards = []
self.cards = []
self.lists = []
def setBoards(self):
url = "https://api.trello.com/1/members/me/boards"
params = (
('fields', 'name,url'),
('key', self.user.key),
('token', self.user.token),
)
try:
response = requests.get(url, params=params)
except requests.exceptions.RequestException as e: # This is the correct syntax
raise SystemExit(e)
self.boards = json.loads(response.text)
def getBoards(self):
self.setBoards()
return self.boards
# def getBoard(self, boardID):
# url = "https://api.trello.com/1/boards/" + boardID
# params = (
# ('fields', 'name,url'),
# ('key', user.key),
# ('token', user.token),
# )
# try:
# response = requests.get(url, params=params)
# except requests.exceptions.RequestException as e: # This is the correct syntax
# raise SystemExit(e)
def setCards(self, boardID):
url = "https://api.trello.com/1/boards/" + boardID + "/cards"
params = (
('key', self.user.key),
('token', self.user.token),
)
try:
response = requests.get(url, params=params)
except requests.exceptions.RequestException as e: # This is the correct syntax
raise SystemExit(e)
# print(response.text)
self.cards = json.loads(response.text)
def getCards(self, boardID):
self.setCards(boardID)
return self.cards
def setLists(self, boardID):
url = "https://api.trello.com/1/boards/" + boardID + "/lists"
params = (
('key', self.user.key),
('token', self.user.token),
)
try:
response = requests.get(url, params=params)
except requests.exceptions.RequestException as e: # This is the correct syntax
raise SystemExit(e)
self.lists = json.loads(response.text)
def getLists(self, boardID):
self.setLists(boardID)
return self.lists