-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrello.lua
46 lines (37 loc) · 1.11 KB
/
trello.lua
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
--[[
LUA library for webscript.io
Calls for Trello API
--]]
trello = {}
function trello.call(key,token,method,endpoint,params,data)
function callout(req_url,req_method,req_params,req_data)
return http.request {
url = req_url, method = req_method,
headers = req_headers,
params = req_params,
data = req_data
}
end
prefix = 'https://api.trello.com/1/'
return callout(prefix..endpoint,method,params,data)
end
function trello.find_board(orgId,boardName,key,token)
--[[
Function to find a named Trello board in a specified organisation
and to return the board id if found (nil otherwise)
--]]
--list all boards for an Organization
-- /organization/[Org Id]/boards
r= trello.call(key,token,'GET','/organization/'..orgId..'/boards/',{key=key,token=token})
j=json.parse(r.content)
-- trawl through all boards (open and closed) for this organisation
-- return the id of the first board with a matching name that is found
for k,v in ipairs(j) do
if (v.name == boardName) then
-- return id of matching board name
return v.id
end
end
-- no matching board name found
return nil
end