Last active 13 hours ago

trello.st Raw Playground
1Conf: <-[ secrets.json: File .slurp JSON .parse do[
2 api-key: fn[ get[ Trello: APIKey: ] ]
3 api-token: fn[ get[ Trello: APIToken: ] ]
4
5 auth-kv: fn[ key: api-key token: api-token ]
6
7 main-board: fn[ get[ Boards: main: ] ]
8 archive-board: fn[ get[ Boards: archive: ] ]
9
10 day-list-template: fn[ get[ Lists: day-list-template: ] ]
11
12 ]
13]
14
15TrelloEndpoints: is-obj[
16 API-BASE: <-[ "https://api.trello.com/1" ]
17 get-lists-on-board: fn[ let[ id ]
18 URL .of[
19 API-BASE /boards/: id /lists/:
20 ?[ Conf .auth-kv ]
21 ]
22 ]
23
24 new-list: fn[ let[ name onBoard ]
25 URL .of[
26 API-BASE /lists/:
27 ?[ Conf .auth-kv name: name idBoard: onBoard ] ]
28 ]
29 new-list-at: fn[ let[ name pos onBoard ]
30 URL .of[
31 API-BASE /lists/:
32 ?[ Conf .auth-kv
33 name: name idBoard: onBoard pos: pos ]
34 ]
35 ]
36 list-from-template-at: fn[ let[ name pos onBoard templateId ]
37 URL .of[
38 API-BASE /lists/:
39 ?[ Conf .auth-kv
40 name: name idBoard: onBoard
41 pos: pos idListSource: templateId ]
42 ]
43 ]
44
45 move-list-to-board: fn[ let[ listId toBoard ]
46 URL .of[
47 API-BASE /lists/: listId /idBoard:
48 ?[ value: toBoard Conf .auth-kv ] ]
49 ]
50]
51
52trello-list: module[ use[ simple-wrapper ] temp[ gets props ]
53 props[ id name closed color idBoard pos subscribed ] ]
54
55Trello: is-obj[
56 get-lists-on-board: fn[ NB[ board-id ]
57 TrelloEndpoints .get-lists-on-board
58 HTTP .get .json .value
59 Array .from-raw .map[ cell do[ use[ trello-list ] ] ]
60 ]
61
62 move-list-to-board: fn[ NB[ listId toBoard ]
63 TrelloEndpoints .move-list-to-board "" HTTP .put .utf8 /l
64 ]
65 list-from-template-at: fn[ NB[ name pos onBoard templateId ]
66 TrelloEndpoints .list-from-template-at "" HTTP .post .utf8 /l
67 ]
68
69 archive-list: fn[ Conf .archive-board move-list-to-board ]
70]
71
72
73test: fn[
74 Conf .main-board Trello .get-lists-on-board .filter[
75 .name String .[ "*" contains? ] NB true
76 ] in-each[ name /l pos /l ]
77]
78
79cleanup: fn[
80 Conf .main-board Trello .get-lists-on-board .filter[
81 .name String .[ "*" contains? ]
82 ] each[ .id Trello .archive-list ]
83]
84
85setup: fn[
86 "Needs to be updated before running again!" error
87 /#[
88 "Friday 2/20"
89 "Thursday 2/19"
90 "Wednesday 2/18"
91 "Tuesday 2/17"
92 "Monday 2/16"
93 ] each[
94 6 Conf .[ main-board day-list-template ] Trello .list-from-template-at
95 ]
96]
97