trello.st
· 2.3 KiB · Smalltalk
Bruto
Playground
Conf: <-[ secrets.json: File .slurp JSON .parse do[
api-key: fn[ get[ Trello: APIKey: ] ]
api-token: fn[ get[ Trello: APIToken: ] ]
auth-kv: fn[ key: api-key token: api-token ]
main-board: fn[ get[ Boards: main: ] ]
archive-board: fn[ get[ Boards: archive: ] ]
day-list-template: fn[ get[ Lists: day-list-template: ] ]
]
]
TrelloEndpoints: is-obj[
API-BASE: <-[ "https://api.trello.com/1" ]
get-lists-on-board: fn[ let[ id ]
URL .of[
API-BASE /boards/: id /lists/:
?[ Conf .auth-kv ]
]
]
new-list: fn[ let[ name onBoard ]
URL .of[
API-BASE /lists/:
?[ Conf .auth-kv name: name idBoard: onBoard ] ]
]
new-list-at: fn[ let[ name pos onBoard ]
URL .of[
API-BASE /lists/:
?[ Conf .auth-kv
name: name idBoard: onBoard pos: pos ]
]
]
list-from-template-at: fn[ let[ name pos onBoard templateId ]
URL .of[
API-BASE /lists/:
?[ Conf .auth-kv
name: name idBoard: onBoard
pos: pos idListSource: templateId ]
]
]
move-list-to-board: fn[ let[ listId toBoard ]
URL .of[
API-BASE /lists/: listId /idBoard:
?[ value: toBoard Conf .auth-kv ] ]
]
]
trello-list: module[ use[ simple-wrapper ] temp[ gets props ]
props[ id name closed color idBoard pos subscribed ] ]
Trello: is-obj[
get-lists-on-board: fn[ NB[ board-id ]
TrelloEndpoints .get-lists-on-board
HTTP .get .json .value
Array .from-raw .map[ cell do[ use[ trello-list ] ] ]
]
move-list-to-board: fn[ NB[ listId toBoard ]
TrelloEndpoints .move-list-to-board "" HTTP .put .utf8 /l
]
list-from-template-at: fn[ NB[ name pos onBoard templateId ]
TrelloEndpoints .list-from-template-at "" HTTP .post .utf8 /l
]
archive-list: fn[ Conf .archive-board move-list-to-board ]
]
test: fn[
Conf .main-board Trello .get-lists-on-board .filter[
.name String .[ "*" contains? ] NB true
] in-each[ name /l pos /l ]
]
cleanup: fn[
Conf .main-board Trello .get-lists-on-board .filter[
.name String .[ "*" contains? ]
] each[ .id Trello .archive-list ]
]
setup: fn[
"Needs to be updated before running again!" error
/#[
"Friday 2/20"
"Thursday 2/19"
"Wednesday 2/18"
"Tuesday 2/17"
"Monday 2/16"
] each[
6 Conf .[ main-board day-list-template ] Trello .list-from-template-at
]
]
| 1 | Conf: <-[ 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 | |
| 15 | TrelloEndpoints: 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 | |
| 52 | trello-list: module[ use[ simple-wrapper ] temp[ gets props ] |
| 53 | props[ id name closed color idBoard pos subscribed ] ] |
| 54 | |
| 55 | Trello: 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 | |
| 73 | test: 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 | |
| 79 | cleanup: fn[ |
| 80 | Conf .main-board Trello .get-lists-on-board .filter[ |
| 81 | .name String .[ "*" contains? ] |
| 82 | ] each[ .id Trello .archive-list ] |
| 83 | ] |
| 84 | |
| 85 | setup: 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 |