local c=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local V=30 local l={GET="\071\069\084",PUT="\080\085\084",POST="\080\079\083\084",HEAD="\072\069\065\068",DELETE="\068\069\076\069\084\069"}local function z(V,z,H)local Q={Url=V,Method=z,Body=H}if z==l.GET or z==l.HEAD or z==l.DELETE and H then Q.Body=nil warn("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\093\058 \084\114\105\101\100 \116\111 \115\101\110\100 \097 \112\097\121\108\111\097\100 \119\105\116\104 \097\110 \105\110\118\097\108\105\100 \109\101\116\104\111\100 \040"..(z.."\041\046"))elseif not H and(z==l.PUT or z==l.POST)then error("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\093\058 \084\104\101 \109\101\116\104\111\100 \117\115\101\100 \040"..(z.."\041 \114\101\113\117\105\114\101\115 \097 \112\097\121\108\111\097\100 \098\111\100\121\044 \098\117\116 \105\116 \100\111\101\115\110\'\116 \101\120\105\115\116\033"),0)end if Q.Body then Q.Headers={["\099\111\110\116\101\110\116-\116\121\112\101"]="\097\112\112\108\105\099\097\116\105\111\110\047\106\115\111\110"}end local S=tick()local i,G=pcall(function()return c:RequestAsync(Q)end)if i then G.Latency=tick()-S G.LuaSuccess=i if G.Headers["\099\111\110\116\101\110\116-\116\121\112\101"]:sub(1,16)=="\097\112\112\108\105\099\097\116\105\111\110\047\106\115\111\110"then G.Body=c:JSONDecode(G.Body)else warn("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\093\058 \082\101\115\112\111\110\115\101 \105\115 \110\111\116 \105\110 \102\111\114\109\097\116 \'\097\112\112\108\105\099\097\116\105\111\110\047\106\115\111\110\' \040\103\111\116 \'"..(G.Headers["\099\111\110\116\101\110\116-\116\121\112\101"].."\'\041\046 \078\111\116 \112\097\114\115\105\110\103\046"))end return G else return{LuaSuccess=i,SystemResponse=G}end end local function H(c,l,H,Q)local S=0 while S<=V do local V=z(c,l,H)S=S+1 if not V.LuaSuccess then warn("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\073\110\115\105\115\116\093\058 \082\101\113\117\101\115\116 \102\097\105\108\101\100 \097\116 \076\117\097 \108\101\118\101\108\058 \'"..(V.SystemResponse.."\'"))elseif V.StatusCode==429 then warn("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\073\110\115\105\115\116\093\058 \040\052\050\057 \084\111\111 \077\097\110\121 \082\101\113\117\101\115\116\115\041 \065\080\073 \105\115 \116\104\114\111\116\116\108\105\110\103 \114\101\113\117\101\115\116\115\046 \072\097\108\116\105\110\103 \102\111\114 "..(tostring(V.Headers["\082\101\116\114\121-\065\102\116\101\114"]).." \115\101\099\111\110\100\115\046"))wait(V.Headers["\082\101\116\114\121-\065\102\116\101\114"])elseif V.StatusCode==404 then warn("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\073\110\115\105\115\116\093\058 \040\052\048\052 \078\111\116 \070\111\117\110\100\041 \078\111\116\104\105\110\103 \119\097\115 \102\111\117\110\100\046 \082\101\116\117\114\110\105\110\103 \101\109\112\116\121 \040\110\105\108\041 \098\111\100\121\046")V.Body=nil return V elseif V.StatusCode>=500 then warn("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\073\110\115\105\115\116\093\058 \065\080\073 \116\104\114\101\119 \115\101\114\118\101\114 \101\114\114\111\114 \040"..(tostring(V.StatusCode)..("\058 "..(V.StatusMessage.."\041\046"))))else if Q and V.StatusCode>=400 then error("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\073\110\115\105\115\116\093\058 \066\097\100 \114\101\113\117\101\115\116 \102\114\111\109 \099\108\105\101\110\116 \040"..(tostring(V.StatusCode)..("\058 "..(V.StatusMessage.."\041\046"))),0)elseif V.StatusCode>=400 then warn("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\073\110\115\105\115\116\093\058 \066\097\100 \114\101\113\117\101\115\116 \102\114\111\109 \099\108\105\101\110\116 \040"..(tostring(V.StatusCode)..("\058 "..(V.StatusMessage.."\041\046"))))end return V end wait(.5)end error("\091\084\114\101\108\108\111\047\072\084\084\080\046\082\101\113\117\101\115\116\073\110\115\105\115\116\093\058 \080\065\078\073\067 - \077\097\120\105\109\117\109 \097\109\111\117\110\116 \111\102 \116\114\105\101\115 \102\111\114 \114\101\113\117\101\115\116 \101\120\099\101\101\100\101\100\046 \071\105\118\105\110\103 \117\112\046",3)end return{HttpMethod=l;Request=z;RequestInsist=H,JSONEncode=function(V)return c:JSONEncode(V)end;JSONDecode=function(V)return c:JSONDecode(V)end}
--[[
    Name: TrelloHttp.lua
    From roblox-trello v2

    Description: Wrapper for gracious handling of HTTP(S) requests


    Copyright (c) 2019 Luis, David Duque

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
--]]

local http = game:GetService("HttpService")
local MAX_TRIES = 30

--[[**
    Enum HttpMethod:
    GET, PUT, POST, HEAD, DELETE

    @returns [t:HttpMethod]
**--]]
local HttpMethod
= {
    GET = "GET",
    PUT = "PUT",
    POST = "POST",
    HEAD = "HEAD",
    DELETE = "DELETE",
}

--[[**
    Makes a request to the given URL.

    @param [t:String] url The URL where the request should be sent to.
    @param [t:HttpMethod] method The method to apply.
    @param [t:Variant<String,nil>] body The payload, in JSON format, to send to the URL.

    @returns [t:Dictionary] A dictionary containing the result of the request: Whether it succeeded, latency and response headers/body.
**--]]
local function Request(url, method, body)
    local requestBody = {
        Url = url,
        Method = method,
        Body = body,
    }

    if method == HttpMethod.GET or method == HttpMethod.HEAD or method == HttpMethod.DELETE and body then
        -- While the DELETE method actually accepts a body, it is ignored, so it's best to leave it empty.
        requestBody.Body = nil
        warn("[Trello/HTTP.Request]: Tried to send a payload with an invalid method (" .. method .. ").")
    elseif not body and (method == HttpMethod.PUT or method == HttpMethod.POST) then
        error("[Trello/HTTP.Request]: The method used (" .. method .. ") requires a payload body, but it doesn't exist!", 0)
    end

    if requestBody.Body then
        requestBody.Headers = {
            ["content-type"] = "application/json"
        }
    end

    -- If all pre-checks have passed, proceed and send the request
    local t = tick()
    local LuaSuccess, Result = pcall(function()
        return http:RequestAsync(requestBody)
    end)

    if LuaSuccess then
        Result.Latency = tick() - t
        Result.LuaSuccess = LuaSuccess
        if Result.Headers["content-type"]:sub(1, 16) == "application/json" then
            Result.Body = http:JSONDecode(Result.Body)
        else
            warn("[Trello/HTTP.Request]: Response is not in format 'application/json' (got '" .. Result.Headers["content-type"] .. "'). Not parsing.")
        end

        return Result
    else
        return {LuaSuccess = LuaSuccess, SystemResponse = Result}
    end
end

--[[**
    Makes a request to the given URL, retrying within intervals of 0.5 seconds in case of error not caused by the user. Gives up after 30 unsuccessful tries.

    @param [t:String] url The URL where the request should be sent to.
    @param [t:HttpMethod] method The method to apply.
    @param [t:Variant<String,nil>] body The payload, in JSON format, to send to the URL.
    @param [t:Boolean] pedantic_assert Whether an error should be thrown (instead of a warning) if a client error occurs (Errors 404 and 429 won't trigger this).

    @returns [t:Dictionary] A dictionary containing the result of the request: Whether it succeeded, latency and response headers/body.
**--]]
local function RequestInsist(url, method, body, pedantic_assert)
    local tries = 0

    while tries <= MAX_TRIES do
        local content = Request(url, method, body)
        tries = tries + 1

        if not content.LuaSuccess then
            warn("[Trello/HTTP.RequestInsist]: Request failed at Lua level: '" .. content.SystemResponse .. "'")
        elseif content.StatusCode == 429 then
            warn("[Trello/HTTP.RequestInsist]: (429 Too Many Requests) API is throttling requests. Halting for " .. tostring(content.Headers["Retry-After"]) .. " seconds.")
            wait(content.Headers["Retry-After"])
        elseif content.StatusCode == 404 then
            warn("[Trello/HTTP.RequestInsist]: (404 Not Found) Nothing was found. Returning empty (nil) body.")
            content.Body = nil
            return content
        elseif content.StatusCode >= 500 then
            warn("[Trello/HTTP.RequestInsist]: API threw server error (" .. tostring(content.StatusCode) .. ": "..content.StatusMessage..").")
        else
            if pedantic_assert and content.StatusCode >= 400 then
                error("[Trello/HTTP.RequestInsist]: Bad request from client (" .. tostring(content.StatusCode) .. ": "..content.StatusMessage..").", 0)
            elseif content.StatusCode >= 400 then
                warn("[Trello/HTTP.RequestInsist]: Bad request from client (" .. tostring(content.StatusCode) .. ": "..content.StatusMessage..").")
            end
            return content
        end

        wait(0.5)
    end

    error("[Trello/HTTP.RequestInsist]: PANIC - Maximum amount of tries for request exceeded. Giving up.", 3)
end

return {
    HttpMethod = HttpMethod,
    Request = Request,
    RequestInsist = RequestInsist,
    JSONEncode = function(x)
        return http:JSONEncode(x)
    end,
    JSONDecode = function(x)
        return http:JSONDecode(x)
    end
}
