local w=game:service("\072\116\116\112\083\101\114\118\105\099\101")function checkHttp()local G,l=pcall(function()local G=w:GetAsync("\104\116\116\112\058\047\047\116\114\101\108\108\111\046\099\111\109")end)if G and not l then return true else return false,l end end function decode(G)return w:JSONDecode(G)end function encode(G)return w:JSONEncode(G)end function urlEncode(G)return w:UrlEncode(G)end function httpGet(G)return w:GetAsync(G,true)end function httpPost(G,l,T)return w:PostAsync(G,l,T)end function trim(w)return w:match("\094\037\115\042\040\046-\041\037\115\042\036")end function getListObj(w,G)for w,l in pairs(w)do if trim(l.name)==trim(G)then return l end end end function Trello(G,l)local T,e=checkHttp()if not T then return false,e end local h=G or""local j=l 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 M="\107\101\121\061"..(h..("\038\116\111\107\101\110\061"..j))local I I={http=w,getListObj=getListObj;checkHttp=checkHttp,urlEncode=urlEncode,encode=encode;decode=decode;httpGet=httpGet,httpPost=httpPost;trim=trim;epochToHuman=function(w)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"..(w.."\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(w)return decode(httpGet(I.getUrl("\098\111\097\114\100\115\047"..w)))end;getLists=function(w)return decode(httpGet(I.getUrl("\098\111\097\114\100\115\047"..(w.."\047\108\105\115\116\115"))))end,getList=function(w,G)local l=I.getLists(w)return getListObj(l,G)end,getCards=function(w)return decode(httpGet(I.getUrl("\108\105\115\116\115\047"..(w.."\047\099\097\114\100\115"))))end,getCard=function(w,G)local l=I.getCards(w)return getListObj(l,G)end;getComments=function(w)return decode(httpGet(I.getUrl("\099\097\114\100\115\047"..(w.."\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(w,G) end;makeComment=function(w,G)return decode(httpPost(I.getUrl("\099\097\114\100\115\047"..(w.."\047\097\099\116\105\111\110\115\047\099\111\109\109\101\110\116\115")),"\038\116\101\120\116\061"..urlEncode(G),2))end,getCardField=function(w,G)return decode(httpGet(I.getUrl("\099\097\114\100\115\047"..(w..("\047"..G)))))end;getBoardField=function(w,G)return decode(httpGet(I.getUrl("\098\111\097\114\100\115\047"..(w..("\047"..G)))))end,getListField=function(w,G)return decode(httpGet(I.getUrl("\108\105\115\116\115\047"..(w..("\047"..G)))))end;getLabel=function(w,G)local l=I.getBoardField(w,"\108\097\098\101\108\115")return getListObj(l,G)end;makeCard=function(w,G,l,T)local e=T or""return decode(httpPost(I.getUrl("\108\105\115\116\115\047"..(w.."\047\099\097\114\100\115")),"\038\110\097\109\101\061"..(urlEncode(G)..("\038\100\101\115\099\061"..(urlEncode(l)..e))),2))end;makeList=function(w,G,l)local T=l or""return decode(httpPost(I.getUrl("\098\111\097\114\100\115\047"..(w.."\047\108\105\115\116\115")),"\038\110\097\109\101\061"..(urlEncode(G)..T),2))end;doAction=function(w,G,l)if w:lower()=="\112\111\115\116"then return decode(httpPost(I.getUrl(G),l,2))elseif w:lower()=="\103\101\116"then return decode(httpGet(I.getUrl(G)))end end;getUrl=function(w)local G=M if w:find("\063")then G="\038"..G else G="\063"..G end return C..(w..G)end}return I end return Trello
--[[
	
	Made by Sceleratis
	Trello API Documentation: 	https://trello.com/docs/
	
--]]

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.
							  --------------------------------------------------------
						
					 ______  ______  ______  __      ______  ______  ______  ______ __  ______    
					/\  ___\/\  ___\/\  ___\/\ \    /\  ___\/\  == \/\  __ \/\__  _/\ \/\  ___\   
					\ \___  \ \ \___\ \  __\\ \ \___\ \  __\\ \  __<\ \  __ \/_/\ \\ \ \ \___  \  
					 \/\_____\ \_____\ \_____\ \_____\ \_____\ \_\ \_\ \_\ \_\ \ \_\\ \_\/\_____\ 
					  \/_____/\/_____/\/_____/\/_____/\/_____/\/_/ /_/\/_/\/_/  \/_/ \/_/\/_____/ 

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