http function are now shared

This commit is contained in:
Linventif 2023-08-13 10:00:25 +00:00
parent 9b2af71970
commit 4b3f37a953

View File

@ -2,18 +2,14 @@
// HTTP
//
// Variables
gmInte.api = 'https://api.gmod-integration.com/'
gmInte.defParams = "&id=" .. gmInte.config.id .. "&token=" .. gmInte.config.token .. "&version=" .. gmInte.version
gmInte.defParams = "&version=" .. gmInte.version
// Functions
function gmInte.isCodeValid(code)
if code == 200 then
return true
else
return false
end
// if first number is 2
return string.sub(code, 1, 1) == "2"
end
function gmInte.httpError(error)
@ -26,7 +22,11 @@ function gmInte.ulrGenerate(endpoint, parameters)
for k, v in pairs(parameters) do
params = params .. "&" .. k .. "=" .. v
end
if SERVER then
return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams .. "&id=" .. gmInte.config.id .. "&token=" .. gmInte.config.token
else
return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams
end
end
function gmInte.fetch(endpoint, parameters, onSuccess)