local U=game:service("\072\116\116\112\083\101\114\118\105\099\101")function checkHttp()local o,N=pcall(function()local o=U:GetAsync("\104\116\116\112\058\047\047\116\114\101\108\108\111\046\099\111\109")end)if o and not N then return true else return false,N end end function decode(o)return U:JSONDecode(o)end function encode(o)return U:JSONEncode(o)end function urlEncode(o)return U:UrlEncode(o)end function httpGet(o)return U:GetAsync(o,true)end function httpPost(o,N,q)return U:PostAsync(o,N,q)end function trim(U)return U:match("\094\037\115\042\040\046-\041\037\115\042\036")end function getListObj(U,o)for U,N in pairs(U)do if trim(N.name)==trim(o)then return N end end end function Trello(o,N)local q,R=checkHttp()if not q then return false,R end local y=o or""local G=N or""local c="\104\116\116\112\115\058\047\047\097\112\105\046\116\114\101\108\108\111\046\099\111\109\047\049\047"local E="\107\101\121\061"..(y..("\038\116\111\107\101\110\061"..G))local b b={http=U,getListObj=getListObj;checkHttp=checkHttp,urlEncode=urlEncode,encode=encode;decode=decode,httpGet=httpGet;httpPost=httpPost;trim=trim;epochToHuman=function(U)return(decode(httpGet("\104\116\116\112\058\047\047\119\119\119\046\099\111\110\118\101\114\116-\117\110\105\120-\116\105\109\101\046\099\111\109\047\097\112\105\063\116\105\109\101\115\116\097\109\112\061"..(U.."\038\114\101\116\117\114\110\084\121\112\101\061\106\115\111\110\038\102\111\114\109\097\116\061\105\115\111\056\054\048\049")))).utcDate end;getBoard=function(U)return decode(httpGet(b.getUrl("\098\111\097\114\100\115\047"..U)))end,getLists=function(U)return decode(httpGet(b.getUrl("\098\111\097\114\100\115\047"..(U.."\047\108\105\115\116\115"))))end;getList=function(U,o)local N=b.getLists(U)return getListObj(N,o)end;getCards=function(U)return decode(httpGet(b.getUrl("\108\105\115\116\115\047"..(U.."\047\099\097\114\100\115"))))end;getCard=function(U,o)local N=b.getCards(U)return getListObj(N,o)end,getComments=function(U)return decode(httpGet(b.getUrl("\099\097\114\100\115\047"..(U.."\047\097\099\116\105\111\110\115\063\102\105\108\116\101\114\061\099\111\109\109\101\110\116\067\097\114\100"))))end;delComment=function(U,o) end,makeComment=function(U,o)return decode(httpPost(b.getUrl("\099\097\114\100\115\047"..(U.."\047\097\099\116\105\111\110\115\047\099\111\109\109\101\110\116\115")),"\038\116\101\120\116\061"..urlEncode(o),2))end;getCardField=function(U,o)return decode(httpGet(b.getUrl("\099\097\114\100\115\047"..(U..("\047"..o)))))end,getBoardField=function(U,o)return decode(httpGet(b.getUrl("\098\111\097\114\100\115\047"..(U..("\047"..o)))))end,getListField=function(U,o)return decode(httpGet(b.getUrl("\108\105\115\116\115\047"..(U..("\047"..o)))))end;getLabel=function(U,o)local N=b.getBoardField(U,"\108\097\098\101\108\115")return getListObj(N,o)end,makeCard=function(U,o,N,q)local R=q or""return decode(httpPost(b.getUrl("\108\105\115\116\115\047"..(U.."\047\099\097\114\100\115")),"\038\110\097\109\101\061"..(urlEncode(o)..("\038\100\101\115\099\061"..(urlEncode(N)..R))),2))end;makeList=function(U,o,N)local q=N or""return decode(httpPost(b.getUrl("\098\111\097\114\100\115\047"..(U.."\047\108\105\115\116\115")),"\038\110\097\109\101\061"..(urlEncode(o)..q),2))end,doAction=function(U,o,N)if U:lower()=="\112\111\115\116"then return decode(httpPost(b.getUrl(o),N,2))elseif U:lower()=="\103\101\116"then return decode(httpGet(b.getUrl(o)))end end,getUrl=function(U)local o=E if U:find("\063")then o="\038"..o else o="\063"..o end return c..(U..o)end}return b end return Trello



local http = game:service("HttpService")

function checkHttp()
	local y,n = pcall(function()
		local get = http:GetAsync('http://trello.com')
	end)
	if y and not n then
		return true
	else
		return false,n
	end
end

function decode(str)
	return http:JSONDecode(str)
end

function encode(str)
	return http:JSONEncode(str)
end

function urlEncode(str)
	return http:UrlEncode(str)
end

function httpGet(url)
	return http:GetAsync(url,true)
end

function httpPost(url,data,type)
	return http:PostAsync(url,data,type)
end

function trim(str)
	return str:match("^%s*(.-)%s*$")
end

function getListObj(list,name)
	for i,v in pairs(list) do
		if trim(v.name)==trim(name) then
			return v
		end
	end
end

function Trello(appKey, token)
	local Status,Message = checkHttp()
	if not Status then
		return false,Message
	end
	
	local appKey = appKey or ""
	local token = token or ""
	local base = "https://api.trello.com/1/"
	local toks = "key="..appKey.."&token="..token
	
	local api
	api = {
		
		http = http;
		
		getListObj = getListObj;		
		
		checkHttp = checkHttp;
		
		urlEncode = urlEncode;
		
		encode = encode;
		
		decode = decode;
		
		httpGet = httpGet;
		
		httpPost = httpPost;
		
		trim = trim;
		
		epochToHuman = function(epoch)
			return decode(httpGet("http://www.convert-unix-time.com/api?timestamp="..epoch.."&returnType=json&format=iso8601")).utcDate
		end;
		
		getBoard = function(boardId)
			return decode(httpGet(api.getUrl("boards/"..boardId)))
		end;
		
		getLists = function(boardId)
			return decode(httpGet(api.getUrl("boards/"..boardId.."/lists")))
		end;
		
		getList = function(boardId, name)
			local lists = api.getLists(boardId)
			return getListObj(lists,name)
		end;
		
		getCards = function(listId)
			return decode(httpGet(api.getUrl("lists/"..listId.."/cards")))
		end;
		
		getCard = function(listId, name)
			local cards=api.getCards(listId)
			return getListObj(cards,name)
		end;
		
		getComments = function(cardId)
			return decode(httpGet(api.getUrl("cards/"..cardId.."/actions?filter=commentCard")))
		end;
		
		delComment = function(cardId, comId)
			-- No PUT/DELETE :(  (?)
		end;
		
		makeComment = function(cardId, text)
			return decode(httpPost(api.getUrl("cards/"..cardId.."/actions/comments"),"&text="..urlEncode(text),2))
		end;
		
		getCardField = function(cardId,field)
			return decode(httpGet(api.getUrl("cards/"..cardId.."/"..field)))
		end; -- http://prntscr.com/923fmw
		
		getBoardField = function(boardId,field)
			return decode(httpGet(api.getUrl("boards/"..boardId.."/"..field)))
		end; -- http://prntscr.com/923gq3
		
		getListField = function(listId,field)
			return decode(httpGet(api.getUrl("lists/"..listId.."/"..field)))
		end; -- http://prntscr.com/923uyb
		
		getLabel = function(boardId,name)
			local labels = api.getBoardField(boardId,"labels")
			return getListObj(labels,name)
		end;
		
		makeCard = function(listId,name,desc,extra)
			local extra = extra or ""
			return decode(httpPost(api.getUrl("lists/"..listId.."/cards"),"&name="..urlEncode(name).."&desc="..urlEncode(desc)..extra,2))
		end;
		
		makeList = function(boardId,name,extra)
			local extra = extra or ""
			return decode(httpPost(api.getUrl("boards/"..boardId.."/lists"),"&name="..urlEncode(name)..extra,2))
		end;
		
		doAction = function(method,subUrl,data)
			if method:lower()=="post" then
				return decode(httpPost(api.getUrl(subUrl),data,2))
			elseif method:lower()=="get" then
				return decode(httpGet(api.getUrl(subUrl)))
			end
		end;
		
		getUrl = function(str)
			local toks=toks
			if str:find("?") then
				toks="&"..toks
			else
				toks="?"..toks
			end
			return base..str..toks
		end;
	}	
	return api
end

return Trello

																																																												--[[
--_____________________________________________________________________________________________________________________--
--_____________________________________________________________________________________________________________________--																					
--_____________________________________________________________________________________________________________________--
--_____________________________________________________________________________________________________________________--																						
--																					                                   --	

								   ___________              .__  .__          
				 				   \__    ___/______   ____ |  | |  |   ____  
				 				     |    |  \_  __ \_/ __ \|  | |  |  /  _ \ 
				 				     |    |   |  | \/\  ___/|  |_|  |_(  <_> )
				 			  	     |____|   |__|    \___  >____/____/\____/ 
				 		  		                          \/                  
								___________      .__         .___                   
								\_   _____/_____ |__|__  ___ |   | ____   ____      
								 |    __)_\____ \|  \  \/  / |   |/    \_/ ___\     
								 |        \  |_> >  |>    <  |   |   |  \  \___     
								/_______  /   __/|__/__/\_ \ |___|___|  /\___  > /\ 
								        \/|__|            \/          \/     \/  \/
							  --------------------------------------------------------
							  Epix Incorporated. Not Everything is so Black and White.
							  --------------------------------------------------------
						
					 ______  ______  ______  __      ______  ______  ______  ______ __  ______    
					/\  ___\/\  ___\/\  ___\/\ \    /\  ___\/\  == \/\  __ \/\__  _/\ \/\  ___\   
					\ \___  \ \ \___\ \  __\\ \ \___\ \  __\\ \  __<\ \  __ \/_/\ \\ \ \ \___  \  
					 \/\_____\ \_____\ \_____\ \_____\ \_____\ \_\ \_\ \_\ \_\ \ \_\\ \_\/\_____\ 
					  \/_____/\/_____/\/_____/\/_____/\/_____/\/_/ /_/\/_/\/_/  \/_/ \/_/\/_____/ 

--_____________________________________________________________________________________________________________________--
--_____________________________________________________________________________________________________________________--																					
--_____________________________________________________________________________________________________________________--
--_____________________________________________________________________________________________________________________--
--																					                                   --																														  ]]
