· 6 years ago · Apr 14, 2020, 08:02 AM
1 local key =
2--[[
3 IF YOU DONT KNOW HOW TO SCRIPT GET OUT YOU WONT KNOW HOW TO USE THIS! -Dont mean to be rude, but it's true
4
5 I suggest you move the script and take it out of the model then put the TrelloAPI into the ServerScriptService as exploiters will not be able to acess it in most cases, but thats just me. - nstrike159
6
7 There is a test script in here for those of you who want to test your configuration to use it MAKE SURE TO DISABLE IT!
8
9 When something returns a table try running a recruisive function or loop to see what is inside the table
10 EX:
11 function printTable(tab)
12 local recrlimit=20--Sets recrusive limit so you do not crash studio if u want this off set it to some rediculous value like 10000
13 local inarray=false
14 local rep=0
15 local function printArrInfo(arr)
16 if #arr>recrlimit and inarray then
17 return
18 end
19 for i,v in next,arr do
20 if type(v)=="table" then
21 print(string.rep("\t",rep)..tostring(i).."={")
22 inarray=true
23 rep=rep+1
24 printArrInfo(v)
25 else
26 print(string.rep("\t",rep)..tostring(i).."=".."\""..tostring(v).."\"")
27 end
28 end
29 if inarray then
30 rep=rep-1
31 print(string.rep("\t",rep).."}")
32 inarray=false
33 end
34 end
35 printArrInfo(tab)
36 end
37
38 --HINT: Use the above function if you want to find out whats inside a table returned!
39
40-Instructions
41 1. Go to this link and click allow: ]]--[[
42 2. Copy & Paste your API Key from https://trello.com/app-key into ]] "Here!"; --[[
43 3. Authorize the application by substituting API-KEY in the link bellow with the api key from https://trello.com/app-key
44 https://trello.com/1/authorize?key=[API-KEY]&name=Roblox+Api&expiration=never&response_type=token&scope=read,write
45 4. Copy the random numbers and letters in the page sent to you
46 5. Paste the random numbers and letters in the Value of Token (or make a variable named "token" in your script and put the value there)
47 6. If anywhere an error occurs when in use with "Unauthorized" you didnt copy the full link!(or you added a space in the beggining)
48
49-Functions
50 --------------
51 GetBoardID([Board Name]) return Board ID
52 --------------
53 GetListID([List Name],[Board ID]) return List ID
54 --------------
55 GetCardID([Name],[Board ID]) returns Card ID
56 --------------
57 GetBoardInfo([Board ID]) returns a table like this except not JSON
58 {
59 "id": "4eea4ffc91e31d1746000046",
60 "name": "Example Board",
61 "desc": "This board is used in the API examples",
62 "lists": [{
63 "id": "4eea4ffc91e31d174600004a",
64 "name": "To Do Soon"
65 }, {
66 "id": "4eea4ffc91e31d174600004b",
67 "name": "Doing"
68 }, {
69 "id": "4eea4ffc91e31d174600004c",
70 "name": "Done"
71 }]
72 }
73 --------------
74 GetCardInfo([Card ID],[Board ID]) returns an table
75 EX: {name="cardName",desc="cardDescription",...}
76 -----------
77 GetLists([Board ID]) returns a table
78 ------------
79 AddCard([Name],[Decription],[List ID],Optional[AddUrl],Optional[Position **Valid Values: A position. top, bottom, or a positive number.**],Optional[Due*Default=null*],Optional[Label**Valid Values: all or a comma-separated list of: blue,green,orange,purple,red,yellow**],Optional[CardToCopyID]) returns a Table CardID is a property called "id" in this table
80 ------------
81 EditCard([CardID],[Name],[Decription],[List ID],Optional[AddUrl],Optional[Position **Valid Values: A position. top, bottom, or a positive number.**],Optional[Due*Default=null*],Optional[Label**Valid Values: all or a comma-separated list of: blue,green,orange,purple,red,yellow**],Optional[CardToCopyID]) returns a Table --Made by sloss2003 (https://github.com/Sloss2003)
82 ------------
83 DeleteCard([CardID])Deletes the card --made by sloss2003 (https://github.com/Sloss2003)
84 ------------
85 AddList([Name],[Board ID],Optional[List to Copy],Optional[Position *Valid Values: position. top, bottom, or a positive number.*])
86 ------------
87 *DEPRICATED*AddBoard([Name],[Description]) Use CreateBoard Instead
88 ------------
89 AddCardAtt([Card ID],[Name],[File,URL],[Value])
90 ------------
91 AddLabel([Name],[Color],[Board ID]) returns Label ID
92 ------------
93 AddCardLabel([Card ID],[Label ID])
94 ------------
95 GetLabels([Board ID]) returns a table such as bellow
96 EX: [{"id":"559adc5e19ad3a5dc2b9c003", "idBoard":"559adc5e9ad91e64b569a4d9", "name":"", "color":"green", "uses":0},
97 {"id":"559adc5e19ad3a5dc2b9c004", "idBoard":"559adc5e9ad91e64b569a4d9", "name":"", "color":"yellow", "uses":0},
98 {"id":"559adc5e19ad3a5dc2b9c006", "idBoard":"559adc5e9ad91e64b569a4d9", "name":"", "color":"red", "uses":0},
99 {"id":"559adc5e19ad3a5dc2b9c007", "idBoard":"559adc5e9ad91e64b569a4d9", "name":"", "color": "purple", "uses":0},
100 {"id":"559adc5e19ad3a5dc2b9c008", "idBoard":"559adc5e9ad91e64b569a4d9", "name":"", "color": "blue", "uses":0}]
101 ------------
102 GetCardsInList([List ID]) returns a table containing the cards in the list
103 EX: [{name="cardName",desc="cardDescription",...},{name="cardName",desc="cardDescription",...}]
104 ------------
105 PostComment([Card ID],Text)
106 ------------
107 AddCheckList()
108 ------------
109 GetLabelID(LabelName, BoardID)
110 ------------
111 GetMemberBoards(Username) returns a table containing the boards a member is in
112 ------------
113 GetBoardMembers(BoardID) returns the members of a board in a array like this
114 EX: [{"id":"4ee7df1be582acdec80000ae", "fullName":"Bob Tester", "username":"bobtester"},
115 {"id":"4ee7df74e582acdec80000b6", "fullName":"David Tester", "username":"davidtester"},
116 {"id": "4ee7deffe582acdec80000ac", "fullName": "Joe Tester", "username": "joetester"}]
117 ------------
118 CreateBoard(Name,[Optional]desc,[Optional]{"private","public"}) returns the information about a board and creates a board
119 ------------
120 GetAllBoards() returns a array of BoardIDs of ALL boards you are in without board names!
121 ------------
122 GetBoardNameFromId([Board ID]) gets the board name from the id
123 ------------
124 AddCustomCard(Array/Dictionary,[List ID]) Here is a example Array using all valid values you could have in the array
125 {
126 name="CardName",
127 desc="CardDescription", --REMEMBER THIS IS IN MARKDOWN SO IT IS RECOMENDED TO USE [[ INSTEAD OF "
128 pos="bottom", --Valid Values: A position. top, bottom, or a positive number in a string.
129 due="2016-12-25", --Valid Values: A date, or nil
130 labels="all", --Valid Values: all or a comma-separated list of: blue, green, orange, purple, red, yellow REMEMBER THIS IS NOT NEEDED YOU CAN LEAVE THIS OUT!
131 idMembers="54d77d9a7559e423tf23g2e7", --Valid Values: A comma-separated list of member IDs,
132 idLabels="1a2b3c4d5e6f7g8h9i10j11k12l", --Valid Values: A comma-separated list of labelIds
133 urlSource="http://assetgame.roblox.com/Thumbs/Avatar.ashx?username=Shedletsky", --Valid Values: a url starting with http:// or https:// or nil
134 fileSource="some.website.com/something.php", --Valid Values: a file
135 idCardSource="4eea4ffc91e31d174600004a", --Valid Values: The id of the card to copy into a new card.
136 keepFromSource="all" --Valid Values: all or a comma-seperated list of: name, desc, pos, due, labels, idMembers, idLabels, urlSource, fileSource
137 }
138-Events
139 ------------
140 .CardAdded(ListID,[Optional]Refresh_Time_In_Seconds,[Optional]Iterate_Through_All_Cards_First)
141 :connect(FUNCTION) --Function has argument of a table of the cards information like function cardAdded(Card)
142 :disconnect()
143 .CarRemoved(ListID,[Optional]Refresh_Time_In_Seconds,[Optional]Iterate_Through_All_Cards_First)
144 :connect(FUNCTION)
145 :disconnect()
146 EXAMPLE:
147 '''
148 function cardAdded(card)
149 print(card.name)
150 end
151 function cardRemoved(card)
152 print(card.name)
153 end
154 local api=require(script.Parent.TrelloAPI)
155 local boardid=api:GetBoardID("TestBoard")--The board id is different from the link you see when you go to a board
156 local listid=api:GetListID("Testing",boardid)
157 api.CardAdded(listid):connect(cardAdded) OUCH MY BACK!
158 api.CardRemoved(listid):connect(cardRemoved)
159 '''
160--]]--]]-- ]]--]]
161local suc,err=pcall(function()
162 if game.Players.LocalPlayer~=nil then
163 warn("It is unsafe to have the api in a local enviorment pleasae move it to ServerScriptService and ONLY use it from Server Scripts!")
164 end
165end)
166if not script:IsDescendantOf(game.ServerScriptService) then
167 warn("It is unsafe to have the api in a local enviorment pleasae move it to ServerScriptService and ONLY use it from Server Scripts!")
168end
169local Private=true
170local addon
171local HS={}
172function UrlEncode_Not_Like_Roblox(tab)
173 local ret=""
174 local c=0
175 for i,v in next,tab do
176
177
178 ret=ret.."&"..(tostring(i)).."="..(tostring(v));
179 end
180 return ret
181end
182function HS:PostAsync(url,jsonData)
183 local rhs=game:GetService("HttpService");
184 local data
185 local thread=coroutine.create(function(u,j)
186
187 local suc,msg=false,"";
188 repeat
189 suc,msg=pcall(function()
190 data=rhs:PostAsync(u,j)
191 end)
192 --print(err)
193 wait(3)
194 until suc
195 coroutine.yield(data)
196 end)
197 local status,d=coroutine.resume(thread,url,jsonData);
198 while data==nil do
199 wait()
200 end
201 return data
202end
203function HS:GetAsync(url,cache)
204 local rhs=game:GetService("HttpService");
205 local data
206 local thread=coroutine.create(function(u,j)
207
208 local suc,msg=false,"";
209 repeat
210 suc,msg=pcall(function()
211 data=rhs:GetAsync(u,j)
212 end)
213 --print(data)
214 wait(3)
215 until suc
216 coroutine.yield(data)
217 end)
218 local status,d=coroutine.resume(thread,url,cache);
219 while data==nil do
220 wait()
221 end
222 return data
223end
224function HS:JSONEncode(tab)
225 local rhs=game:GetService("HttpService");
226 return rhs:JSONEncode(tab)
227end
228function HS:JSONDecode(tab)
229 local rhs=game:GetService("HttpService");
230 return rhs:JSONDecode(tab)
231end
232local IS=game:GetService("InsertService")
233local T = {}
234if script:FindFirstChild("Token")==nil and key=="Here!" and getfenv(0).token==nil then
235 error("No token or API-KEY available please set one using this link and putting the random numbers and letters into "..script:GetFullName().." or put it in a global variable in the script calling the TrelloAPI named 'token' (ignore the warning you get when creating a script if you do this) \nhttps://trello.com/1/authorize?key=[Your api key is at https://trello.com/app-key]&name=Roblox+Api&expiration=never&response_type=token&scope=read,write")
236end --Thanks to iRexBot for Pointing out my Typo!
237while script:FindFirstChild("Token")==nil and getfenv(0).token==nil do
238 wait()
239end
240local token=script.Token.Value..""
241script.Token:Destroy()
242function getAddon()
243 if token~="" then
244 addon="?key="..key.."&token="..token
245 elseif getfenv(0).token~=nil then
246 local val=getfenv(0).token
247 addon="?key="..key.."&token="..val
248 else
249 error([[-Instructions.
250 1. Go to this link and click allow: https://trello.com/1/authorize?key=[Your api key is at https://trello.com/app-key]&name=Roblox+Api&expiration=never&response_type=token&scope=read,write
251 2. Copy the token in the page sent to you
252 3. Paste the token in the Value of Token]])
253 end
254 return "&key="..key.."&token="..token
255end
256--[[
257 POST /1/cards/[card id or shortlink]/actions/comments
258 Required permissions: comments
259 Arguments
260 text (required)
261 Valid Values: a string with a length from 1 to 16384
262--]]--]]
263function T:PostComment(cid,t)
264 local url
265 if Private then
266 getAddon()
267 url="https://api.trello.com/1/cards/"..tostring(cid).."/actions/comments"..addon
268 else
269 url="https://api.trello.com/1/cards/"..tostring(cid).."/actions/comments"..addon
270 end
271 local dat={
272 text=t
273 }
274 local data=HS:JSONEncode(dat)
275 local re=HS:PostAsync(url,data)
276 local red=HS:JSONDecode(re)
277 return red
278end
279--/1/lists/[idList]/cards
280--[[
281 [{
282 "id": "4eea503791e31d1746000080",
283 "checkItemStates": [],
284 "closed": false,
285 "dateLastActivity": "2011-12-15T19:53:27.228Z",
286 "desc": "",
287 "descData": null,
288 "email": null,
289 "idAttachmentCover": null,
290 "idBoard": "",
291 "idLabels": [],
292 "idList": "",
293 "idMembersVoted": [],
294 "idShort": 3,
295 "manualCoverAttachment": false,
296 "name": "Finish my awesome application",
297 "pos": 65536,
298 "shortLink": "XlG8S7ll",
299 "badges": {
300 "votes": 0,
301 "viewingMemberVoted": false,
302 "subscribed": false,
303 "fogbugz": "",
304 "checkItems": 0,
305 "checkItemsChecked": 0,
306 "comments": 0,
307 "attachments": 0,
308 "description": false,
309 "due": null
310 },
311 "due": null,
312 "idChecklists": [],
313 "idMembers": [],
314 "labels": [],
315 "shortUrl": "",
316 "subscribed": false,
317 "url": ""
318}
319]]--]]--]]--]]
320 function T:GetCardsInList(lid)
321 local url
322 if Private then
323 getAddon()
324 url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon
325 else
326 getAddon()
327 url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon
328 end
329 local re=HS:GetAsync(url,true)
330 local dat=HS:JSONDecode(re)
331 return dat
332 end
333--[[
334 POST /1/labels
335 Required permissions: write
336 Arguments
337 name (required)
338 Valid Values: a string with a length from 0 to 16384
339 color (required)
340 Valid Values: A valid label color or null
341 idBoard (required)
342 Valid Values: An id
343--]]--]]
344function T:AddLabel(nae,col,boardid)
345 local url
346 if Private then
347 getAddon()
348 url="https://api.trello.com/1/labels"..addon
349 else
350 url="https://api.trello.com/1/labels"..addon
351 end
352 local dat={
353 name=nae,
354 color=col,
355 idBoard=boardid
356 }
357 local data=HS:JSONEncode(dat)
358 local re=HS:PostAsync(url,data)
359 --print(re)
360 return (HS:JSONDecode(re)).id
361end
362--[[
363 GET /1/boards/[board_id]
364
365Required permissions: read
366Arguments Show
367Examples
368https://api.trello.com/1/boards/4eea4ffc91e31d1746000046?lists=open&list_fields=name&fields=name,desc&key=[application_key]&token=[optional_auth_token]
369{
370 "id": "4eea4ffc91e31d1746000046",
371 "name": "Example Board",
372 "desc": "This board is used in the API examples",
373 "lists": [{
374 "id": "4eea4ffc91e31d174600004a",
375 "name": "To Do Soon"
376 }, {
377 "id": "4eea4ffc91e31d174600004b",
378 "name": "Doing"
379 }, {
380 "id": "4eea4ffc91e31d174600004c",
381 "name": "Done"
382 }]
383}
384--]]--]]
385function T:GetBoardNameFromId(id)
386 getAddon()
387 local ret=HS:GetAsync("https://api.trello.com/1/boards/"..id..addon,true)
388 local data=HS:JSONDecode(ret)
389 return data["name"]
390end
391--[[
392GET /1/tokens/[token]/member
393
394Required permissions: read
395Arguments Show]]--]]--
396function T:GetAllBoards()
397 getAddon()
398 local dat=HS:GetAsync("https://api.trello.com/1/tokens/"..token.."/member"..addon,true)
399 local data=HS:JSONDecode(dat)
400
401 return data["idBoards"]
402end
403--[[
404 POST /1/cards/[card id or shortlink]/idLabels
405 Required permissions: write
406 Arguments
407 value (required)
408 Valid Values: The id of the label to add
409--]]--]]
410 function T:AddCardLabel(card,lid)
411 local url
412 local cardi=tostring(card)
413 if Private then
414 getAddon()
415 url="https://api.trello.com/1/cards/"..cardi.."/idLabels"..addon
416 else
417 url="https://api.trello.com/1/cards/"..cardi.."/idLabels"..addon
418 end
419 --print(card,"IS THE CARD ID \n",lid,"IS THE LABEL ID")
420 local da={
421 value=lid
422 }
423 local dat=HS:JSONEncode(da)
424 local data=HS:PostAsync(url,dat)
425 --print(data)
426 return HS:JSONDecode(data)
427 end
428 --[[
429 POST /1/boards
430 Required permissions: write
431 Arguments
432 name (required)
433 Valid Values: a string with a length from 1 to 16384
434 desc (optional)
435 Valid Values: a string with a length from 0 to 16384
436 idOrganization (optional)
437 Valid Values: The id or name of the organization to add the board to.
438 idBoardSource (optional)
439 Valid Values: The id of the board to copy into the new board
440 keepFromSource (optional)
441 Default: all
442 Valid Values: Components of the source board to copy.
443 powerUps (optional)
444 Valid Values: all or a comma-separated list of:
445 calendar
446 cardAging
447 recap
448 voting
449 prefs_permissionLevel (optional)
450 Default: private
451 Valid Values: One of:
452 org
453 private
454 public
455 prefs_voting (optional)
456 Default: disabled
457 Valid Values: One of:
458 disabled
459 members
460 observers
461 org
462 public
463 prefs_comments (optional)
464 Default: members
465 Valid Values: One of:
466 disabled
467 members
468 observers
469 org
470 public
471 prefs_invitations (optional)
472 Default: members
473 Valid Values: One of:
474 admins
475 members
476 prefs_selfJoin (optional)
477 Default: true
478 Valid Values:
479 true
480 false
481 prefs_cardCovers (optional)
482 Default: true
483 Valid Values:
484 true
485 false
486 prefs_background (optional)
487 Default: blue
488 Valid Values: a string with a length from 0 to 16384
489 prefs_cardAging (optional)
490 Default: regular
491 Valid Values: One of:
492 pirate
493 regular
494 --]]--]]
495 function T:AddBoard(nae,dec)
496 local url
497 if Private then
498 getAddon()
499 url="https://api.trello.com/1/boards"..addon
500 else
501 getAddon()
502 url="https://api.trello.com/1/boards"..addon
503 end
504 local dat={
505 name=nae,
506 desc=dec
507 }
508 local data=HS:JSONEncode(dat)
509 local re=HS:PostAsync(url,data)
510 local red=HS:JSONDecode(re)
511 return red
512 end
513 function T:GetCardID(name,boardid)
514 local url
515 if Private then
516 getAddon()
517 url="https://api.trello.com/1/boards/"..boardid.."/cards"..addon
518 else
519 getAddon()
520 url="https://api.trello.com/1/boards/"..boardid.."/cards"..addon
521 end
522 local tab=HS:GetAsync(url,true)
523 local tabl=HS:JSONDecode(tab)
524 for k,ta in pairs(tabl) do
525 for p,t in pairs(ta) do
526 if p=="name" and t==name then
527 return ta.id
528 end
529 end
530 end
531 end
532 function T:GetCardInfo(cardid)
533 --/1/boards/[board_id]/cards/[idCard]
534 local url
535 if Private then
536 getAddon()
537 url="https://api.trello.com/1/cards/"..cardid..""..addon
538 else
539 getAddon()
540 url="https://api.trello.com/1/cards/"..cardid..""..addon
541 end
542 local re=HS:GetAsync(url,true)
543 local tab=HS:JSONDecode(re)
544 return tab
545 end
546 function T:GetBoardInfo(boardid)
547 local url
548 if Private then
549 getAddon()
550 url="https://api.trello.com/1/boards/"..boardid.."?lists=all&cards=all&card_checklists=all&labels=all&memberships=all&members=all&membersInvited=all&checklists=all&organization_memberships=all&fields=all"..getAddon()
551 else
552 getAddon()
553 url="https://api.trello.com/1/boards/"..boardid.."?lists=all&cards=all&card_checklists=all&labels=all&memberships=all&members=all&membersInvited=all&checklists=all&organization_memberships=all&fields=all"..getAddon()
554 end
555 local re=HS:GetAsync(url,true)
556 local data=HS:JSONDecode(re)
557 return data
558 end
559 function T:GetLists(boardid)
560 local url
561 if Private then
562 getAddon()
563 url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
564 else
565 getAddon()
566 url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
567 end
568 local re=HS:GetAsync(url,true)
569 local data=HS:JSONDecode(re)
570 return data
571 end
572 function T:GetMemberBoards(name)
573 local url
574 if Private then
575 getAddon()
576 url="https://api.trello.com/1/members/"..name.."/boards"..addon
577 else
578 getAddon()
579 url="https://api.trello.com/1/members/"..name.."/boards"..addon
580 end
581 local re=HS:GetAsync(url,true)
582 local data=HS:JSONDecode(re)
583 return data
584 end
585 function T:GetBoardMembers(boardid)
586 local url
587 if Private then
588 getAddon()
589 url="https://api.trello.com/1/boards/"..boardid.."/members"..addon
590 else
591 getAddon()
592 url="https://api.trello.com/1/boards/"..boardid.."/members"..addon
593 end
594 local re=HS:GetAsync(url,true)
595 local data=HS:JSONDecode(re)
596 return data
597 end
598--[[
599 POST /1/boards
600
601Required permissions: write
602Arguments Hide
603name (required)
604Valid Values: a string with a length from 1 to 16384
605desc (optional)
606Valid Values: a string with a length from 0 to 16384
607idOrganization (optional)
608Valid Values: The id or name of the organization to add the board to.
609idBoardSource (optional)
610Valid Values: The id of the board to copy into the new board
611keepFromSource (optional)
612Default: all
613Valid Values: Components of the source board to copy.
614powerUps (optional)
615Valid Values: all or a comma-separated list of:
616calendar
617cardAging
618recap
619voting
620prefs_permissionLevel (optional)
621Default: private
622Valid Values: One of:
623org
624private
625public
626prefs_voting (optional)
627Default: disabled
628Valid Values: One of:
629disabled
630members
631observers
632org
633public
634prefs_comments (optional)
635Default: members
636Valid Values: One of:
637disabled
638members
639observers
640org
641public
642prefs_invitations (optional)
643Default: members
644Valid Values: One of:
645admins
646members
647prefs_selfJoin (optional)
648Default: true
649Valid Values:
650true
651false
652prefs_cardCovers (optional)
653Default: true
654Valid Values:
655true
656false
657prefs_background (optional)
658Default: blue
659Valid Values: a string with a length from 0 to 16384
660prefs_cardAging (optional)
661Default: regular
662Valid Values: One of:
663pirate
664regular
665 ]]--]]
666 function T:CreateBoard(nam,...)
667 local opt={...}
668 local tab={
669 name=nam
670 }
671 for i,v in next,opt do
672 local arg="none"
673 if i==1 then
674 tab["desc"]=v
675 elseif i==2 then
676 tab["prefs_permissionLevel"]=v
677 end
678 end
679 local tabl=HS:JSONEncode(tab)
680 local ret=HS:PostAsync("https://api.trello.com/1/boards",tabl)
681 return HS:JSONDecode(ret)
682 end
683 function T:GetBoardID(name)
684 local url
685 if Private then
686 getAddon()
687 url="https://api.trello.com/1/members/me/boards"..addon
688 else
689 getAddon()
690 url="https://api.trello.com/1/members/me/boards"..addon
691 end
692 local tball=HS:GetAsync(url,true)
693 local dt=HS:JSONDecode(tball)
694 for _,tab in pairs(dt) do
695 for p,it in pairs(tab) do
696 if p=="name" and it==name then
697 return tab.id
698 end
699 end
700 end
701 error(name.." not found!")
702 return nil
703 end
704 --[[
705POST /1/cards
706 Required permissions: write
707 Arguments
708 name (optional)
709 Valid Values: The name of the new card. It isn't required if the name is being copied from provided by a URL, file or card that is being copied.
710 desc (optional)
711 Valid Values: a string with a length from 0 to 16384
712 pos (optional)
713 Default: bottom
714 Valid Values: A position. top, bottom, or a positive number.
715 due (required)
716 Valid Values: A date, or null
717 labels (optional)
718 Valid Values: all or a comma-separated list of:
719 blue
720 green
721 orange
722 purple
723 red
724 yellow
725 idList (required)
726 Valid Values: id of the list that the card should be added to
727 idMembers (optional)
728 Valid Values: A comma-separated list of objectIds, 24-character hex strings
729 idLabels (optional)
730 Valid Values: A comma-separated list of objectIds, 24-character hex strings
731 urlSource (required)
732 Valid Values: A URL starting with http:// or https:// or null
733 fileSource (optional)
734 Valid Values: A file
735 idCardSource (optional)
736 Valid Values: The id of the card to copy into a new card.
737 keepFromSource (optional)
738 Default: all
739 Valid Values: Properties of the card to copy over from the source.
740
741 --]]--]]
742 function T:AddCard(...)
743 local url
744 local args={...}
745 local dat=nil
746 if #args==3 then
747 local nam,des,lid=args[1],args[2],args[3]
748 dat={
749 name=nam,
750 desc=des.."",
751 idList=lid,
752 urlSource=nil,
753 due=nil
754 }
755 elseif #args==4 then
756 local nam,des,lid,url=args[1],args[2],args[3],args[4]
757 dat={
758 name=nam,
759 desc=""..des,
760 idList=lid,
761 urlSource=url,
762 due=nil
763 }
764 elseif #args==5 then
765 local nam,des,lid,url,po=args[1],args[2],args[3],args[4],args[5]
766 dat={
767 name=nam,
768 desc=""..des,
769 idList=lid,
770 urlSource=url,
771 pos=po,
772 due=nil
773 }
774 elseif #args==6 then
775 local nam,des,lid,url,po,de=args[1],args[2],args[3],args[4],args[5],args[6]
776 dat={
777 name=nam,
778 desc=""..des,
779 idList=lid,
780 urlSource=url,
781 pos=po,
782 due=de
783 }
784 elseif #args==7 then
785 local nam,des,lid,url,po,de,label=args[1],args[2],args[3],args[4],args[5],args[6],args[7]
786 dat={
787 name=nam,
788 desc=""..des,
789 idList=lid,
790 urlSource=url,
791 pos=po,
792 due=de,
793 labels=label
794 }
795 elseif #args==8 then
796 local nam,des,lid,url,po,de,label,cc=args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]
797 dat={
798 name=nam,
799 desc=""..des,
800 idList=lid,
801 urlSource=url,
802 pos=po,
803 due=de,
804 labels=label,
805 idCardSource=cc
806 }
807 end
808 local data
809 if dat~= nil then
810 data=HS:JSONEncode(dat)
811 else
812 error("No Parameters Found!")
813 return false
814 end
815 if Private then
816 getAddon()
817 url="https://api.trello.com/1/cards"..addon
818 else
819 getAddon()
820 url="https://api.trello.com/1/cards"..addon
821 end
822 local re=HS:PostAsync(url,data)
823 return HS:JSONDecode(re)
824 end
825 --[[
826POST /1/cards
827 Required permissions: write
828 Arguments
829 name (optional)
830 Valid Values: The name of the new card. It isn't required if the name is being copied from provided by a URL, file or card that is being copied.
831 desc (optional)
832 Valid Values: a string with a length from 0 to 16384
833 pos (optional)
834 Default: bottom
835 Valid Values: A position. top, bottom, or a positive number.
836 due (required)
837 Valid Values: A date, or null
838 labels (optional)
839 Valid Values: all or a comma-separated list of:
840 blue
841 green
842 orange
843 purple
844 red
845 yellow
846 idList (required)
847 Valid Values: id of the list that the card should be added to
848 idMembers (optional)
849 Valid Values: A comma-separated list of objectIds, 24-character hex strings
850 idLabels (optional)
851 Valid Values: A comma-separated list of objectIds, 24-character hex strings
852 urlSource (required)
853 Valid Values: A URL starting with http:// or https:// or null
854 fileSource (optional)
855 Valid Values: A file
856 idCardSource (optional)
857 Valid Values: The id of the card to copy into a new card.
858 keepFromSource (optional)
859 Default: all
860 Valid Values: Properties of the card to copy over from the source.
861
862 --]]--]]
863 function AddCustomCard(array, ListID)
864 if array["due"]==nil then
865 array["due"]=nil
866 end
867 if array["urlSource"]==nil then
868 array["urlSource"]=nil
869 end
870 array["idList"]=ListID
871 getAddon()
872 local ret=HS:PostAsync("https://api.trello.com/1/cards"..addon, HS:JSONEncode(array))
873 local data=HS:JSONDecode(ret)
874 return data
875 end
876 --[[
877POST /1/cards/[card id or shortlink]/attachments
878 Required permissions: write
879 Arguments
880 file (optional)
881 Valid Values: A file
882 url (optional)
883 Valid Values: A URL starting with http:// or https:// or null
884 name (optional)
885 Valid Values: a string with a length from 0 to 256
886 mimeType (optional)
887 Valid Values: a string with a length from 0 to 256
888 --]]--]]
889 function T:AddCardAtt(cardid,nae,type,value)
890 local url
891 local dat
892 if string.lower(type)=="file" then
893 dat={
894 name=nae,
895 file=value
896 }
897 elseif string.lower(type)=="url" then
898 dat={
899 name=nae,
900 url=value
901 }
902 elseif string.lower(type)=="mime" then
903 dat={
904 name=nae,
905 mimeType=value
906 }
907 end
908 local cardi=tostring(cardid)
909 if Private then
910 getAddon()
911 url="https://api.trello.com/1/cards/"..cardi.."/attachments"..addon
912 else
913 getAddon()
914 url="https://api.trello.com/1/cards/"..cardi.."/attachments"..addon
915 end
916 local data=HS:JSONEncode(dat)
917 local re=HS:PostAsync(url,data)
918 return re
919 end
920 --[[
921GET /1/boards/[board_id]/labels
922Required permissions: read
923Arguments
924 fields (optional)
925 Default: all
926 Valid Values: all or a comma-separated list of:
927 color
928 idBoard
929 name
930 uses
931 limit (optional)
932 Default: 50
933 Valid Values: a number from 0 to 1000
934 --]]--]]
935 function T:GetLabels(boardid)
936 local url
937 local dat
938 if Private then
939 getAddon()
940 url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
941 else
942 getAddon()
943 url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
944 end
945 local re=HS:GetAsync(url,true)
946 --print(re)
947 local dat=HS:JSONDecode(re)
948 return dat
949 end
950 --[[
951GET /1/boards/[board_id]/labels
952Required permissions: read
953Arguments
954 fields (optional)
955 Default: all
956 Valid Values: all or a comma-separated list of:
957 color
958 idBoard
959 name
960 uses
961 limit (optional)
962 Default: 50
963 Valid Values: a number from 0 to 1000
964 --]]--]]
965 function T:GetLabelID(LabelName,boardid)
966 local url
967 local dat
968 if Private then
969 getAddon()
970 url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
971 else
972 getAddon()
973 url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
974 end
975 local re=HS:GetAsync(url,true)
976 --print(re)
977 local dat=HS:JSONDecode(re)
978 local id
979 for i,v in next,dat do
980 if v.name==LabelName then
981 id=v.id
982 break
983 end
984 end
985 return id
986 end
987
988 --[[
989 GET /1/boards/[board_id]/lists
990 Required permissions: read
991 Arguments
992 cards (optional)
993 Default: none
994 Valid Values: One of:
995 all
996 closed
997 none
998 open
999 visible
1000 card_fields (optional)
1001 Default: all
1002 Valid Values: all or a comma-separated list of:
1003 badges
1004 checkItemStates
1005 closed
1006 dateLastActivity
1007 desc
1008 descData
1009 due
1010 email
1011 idAttachmentCover
1012 idBoard
1013 idChecklists
1014 idLabels
1015 idList
1016 idMembers
1017 idMembersVoted
1018 idShort
1019 labels
1020 manualCoverAttachment
1021 name
1022 pos
1023 shortLink
1024 shortUrl
1025 subscribed
1026 url
1027 filter (optional)
1028 Default: open
1029 Valid Values: One of:
1030 all
1031 closed
1032 none
1033 open
1034 fields (optional)
1035 Default: all
1036 Valid Values: all or a comma-separated list of:
1037 closed
1038 idBoard
1039 name
1040 pos
1041 subscribed
1042 --]]--]]
1043 function T:GetListID(name,boardid)
1044 local url
1045 if Private then
1046 getAddon()
1047 url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
1048 else
1049 getAddon()
1050 url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
1051 end
1052 local tab=HS:GetAsync(url,true)
1053 local tabl=HS:JSONDecode(tab)
1054 for k,ta in pairs(tabl) do
1055 for p,t in pairs(ta) do
1056 if p=="name" and t==name then
1057 return ta.id
1058 end
1059 end
1060 end
1061 end
1062 --[[
1063 POST /1/lists
1064 Required permissions: write
1065 Arguments
1066 name (required)
1067 Valid Values: a string with a length from 1 to 16384
1068 idBoard (required)
1069 Valid Values: id of the board that the list should be added to
1070 idListSource (optional)
1071 Valid Values: The id of the list to copy into a new list.
1072 pos (optional)
1073 Default: top
1074 Valid Values: A position. top, bottom, or a positive number.
1075 --]]--]]
1076 function T:AddList(...)
1077 local args={...}
1078 local nam,boid,idsource,po
1079 local url
1080 local dat
1081 if #args==2 then
1082 nam,boid=args[1],args[2]
1083 dat={name=nam,idBoard=boid}
1084 elseif #args==3 then
1085 nam,boid,idsource=args[1],args[2],args[3]
1086 dat={name=nam,idBoard=boid,idListSource=idsource}
1087 elseif #args==4 then
1088 nam,boid,idsource,po=args[1],args[2],args[3],args[4]
1089 dat={name=nam,idBoard=boid,idListSource=idsource,pos=po}
1090 else
1091 error("Invalid arguments: "..table.concat(args,","))
1092 end
1093 --
1094 if Private then
1095 getAddon()
1096 url="https://api.trello.com/1/lists"..addon
1097 else
1098 getAddon()
1099 url="https://api.trello.com/1/lists"..addon
1100 end
1101 local data=HS:JSONEncode(dat)
1102 local re=HS:PostAsync(url,data)
1103 return re.id
1104 end
1105 --[[
1106 EXAMPLE:
1107 function cardAdded(card)
1108 print(card.name)
1109 end
1110 local api=require(script.Parent.TrelloAPI)
1111 local boardid=api:GetBoardID("TestBoard")--The board id is different from the link you see when you go to a board
1112 local listid=api:GetListID("Testing",boardid)
1113 api.CardAdded(listid):connect(cardAdded)
1114
1115 --]]
1116 function T.CardAdded(ListID,RefreshTimeInSecs,initialIteration)
1117 if RefreshTimeInSecs==nil or RefreshTimeInSecs<30 then
1118 RefreshTimeInSecs=30
1119 end
1120 if initialIteration==nil then
1121 initialIteration=false
1122 end
1123 local Hook={}
1124 local callbackEnded=false
1125 local previousTable={}
1126 if not initialIteration then
1127 previousTable=T:GetCardsInList(ListID)
1128 end
1129 local function refreshCallback(callback)
1130 local newTable=T:GetCardsInList(ListID)
1131 if (#newTable>#previousTable) then
1132 for _,i in next,newTable do
1133 local found=false
1134 for _,v in next,previousTable do
1135 if (v.id==i.id) then
1136 found=true
1137 end
1138 end
1139 if (not found) then
1140 callback(i,ListID)
1141 end
1142 end
1143 end
1144 previousTable=newTable
1145 end
1146 local thread=nil
1147 function Hook:connect(callback)
1148 thread=coroutine.wrap(function(callbackEndedNested,callbackNested)
1149 while ((not callbackEndedNested)) do
1150 local suc,msg = false,""
1151 repeat
1152 suc,msg=pcall(refreshCallback,callbackNested)
1153 until suc
1154 wait(RefreshTimeInSecs)
1155 end
1156 end)
1157 thread(callbackEnded,callback)
1158 end
1159 function Hook:disconnect()
1160 callbackEnded=true
1161 thread(callbackEnded,function()end)
1162 end
1163 return Hook
1164 end
1165
1166 --[[
1167 function cardRemoved(card)
1168 print(card.name)
1169 end
1170 local api=require(script.Parent.TrelloAPI)
1171 local boardid=api:GetBoardID("TestBoard")--The board id is different from the link you see when you go to a board
1172 local listid=api:GetListID("Testing",boardid)
1173 api.CardRemoved(listid):connect(cardRemoved)
1174 --]]
1175 function T.CardRemoved(ListID,RefreshTimeInSecs,initialIteration)
1176 if RefreshTimeInSecs==nil or RefreshTimeInSecs<30 then
1177 RefreshTimeInSecs=30
1178 end
1179 if initialIteration==nil then
1180 initialIteration=false
1181 end
1182 local Hook={}
1183 local callbackEnded=false
1184 local previousTable={}
1185 if not initialIteration then
1186 previousTable=T:GetCardsInList(ListID)
1187 end
1188 local function refreshCallback(callback)
1189 local newTable=T:GetCardsInList(ListID)
1190 if (#newTable<#previousTable) then
1191 for _,i in next,newTable do
1192 local found=false
1193 for _,v in next,previousTable do
1194 if (v.id==i.id) then
1195 found=true
1196 end
1197 end
1198 if (not found) then
1199 callback(i,ListID)
1200 end
1201 end
1202 end
1203 previousTable=newTable
1204 end
1205 local thread=nil
1206 function Hook:connect(callback)
1207 thread=coroutine.wrap(function(callbackEndedNested,callbackNested)
1208 while ((not callbackEndedNested)) do
1209 local suc,msg = false,""
1210 repeat
1211 suc,msg=pcall(refreshCallback,callbackNested)
1212 until suc
1213 wait(RefreshTimeInSecs)
1214 end
1215 end)
1216 thread(callbackEnded,callback)
1217 end
1218 function Hook:disconnect()
1219 callbackEnded=true
1220 thread(callbackEnded,function()end)
1221 end
1222 return Hook
1223 end
1224
1225--[[
1226 GET: DeleteCard
1227 PARAMS: cardid, app, token
1228 CREDITS TO: sloss2003 (https://github.com/mwalden2004)
1229--]]
1230function T:DeleteCard(cid)
1231 local thing
1232 local cardid = "";
1233 if type(cid)=="table" then
1234 cardid=cid.id;
1235 thing = "?cardid="..cid.id.."&token="..token.."&key="..key
1236 else
1237 cardid=cid;
1238 thing = "?cardid="..cid.."&token="..token.."&key="..key
1239 end
1240 print(thing)
1241 local send = game:GetService("HttpService"):RequestAsync({Url = "https://api.trello.com/1/cards/"..cardid..thing, Method="DELETE"})
1242 print(send.Body)
1243 return(send)
1244end
1245
1246
1247--[[
1248 GET: EditCard
1249 PARAMS: cardid token app name desc
1250 CREDITS TO: sloss2003 (https://github.com/mwalden2004)
1251--]]
1252function T:EditCard(...)
1253 local url
1254 local args={...}
1255 local dat=nil;
1256 local cid = args[1];
1257 if #args==3 then
1258 local cid,nam,des,lid=args[1],args[2],args[3]
1259 dat={
1260 cardid=cid,
1261 name=nam,
1262 desc=des.."",
1263 idList=lid,
1264 urlSource=nil,
1265 due=nil
1266 }
1267 elseif #args==4 then
1268 local cid,nam,des,lid,url=args[1],args[2],args[3],args[4]
1269 dat={
1270 cardid=cid,
1271 name=nam,
1272 desc=""..des,
1273 idList=lid,
1274 urlSource=url,
1275 due=nil
1276 }
1277 elseif #args==5 then
1278 local cid,nam,des,lid,url,po=args[1],args[2],args[3],args[4],args[5]
1279 dat={
1280 cardid=cid,
1281 name=nam,
1282 desc=""..des,
1283 idList=lid,
1284 urlSource=url,
1285 pos=po,
1286 due=nil
1287 }
1288 elseif #args==6 then
1289 local cid,nam,des,lid,url,po,de=args[1],args[2],args[3],args[4],args[5],args[6]
1290 dat={
1291 cardid=cid,
1292 name=nam,
1293 desc=""..des,
1294 idList=lid,
1295 urlSource=url,
1296 pos=po,
1297 due=de
1298 }
1299 elseif #args==7 then
1300 local cid,nam,des,lid,url,po,de,label=args[1],args[2],args[3],args[4],args[5],args[6],args[7]
1301 dat={
1302 cardid=cid,
1303 name=nam,
1304 desc=""..des,
1305 idList=lid,
1306 urlSource=url,
1307 pos=po,
1308 due=de,
1309 labels=label
1310 }
1311 elseif #args==8 then
1312 local cid,nam,des,lid,url,po,de,label,cc=args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]
1313 dat={
1314 cardid=cid,
1315 name=nam,
1316 desc=""..des,
1317 idList=lid,
1318 urlSource=url,
1319 pos=po,
1320 due=de,
1321 labels=label,
1322 idCardSource=cc
1323 }
1324 end
1325 local data
1326 if dat~= nil then
1327 data=UrlEncode_Not_Like_Roblox(dat)
1328 else
1329 error("No Parameters Found!")
1330 return false
1331 end
1332 if typeof(cid) == "table" then
1333 cid=cid.id;
1334 end
1335 if Private then
1336 getAddon()
1337 url="https://api.trello.com/1/cards/"..cid.."?key="..key.."&token="..token..data
1338 else
1339 getAddon()
1340 url="https://api.trello.com/1/cards/"..cid..addon..data
1341 end
1342 local re=game:GetService("HttpService"):RequestAsync({Url = url, Method="PUT"})
1343 return HS:JSONDecode(re.Body)
1344
1345 end
1346return