
---@class socket_ftp_request*
---@field host? string hostname.
---@field port? integer port.
---@field user? string username.
---@field password? string password.
---@field path? string path.
---@field type? string Transfer type.
---@field command? string Order.
---@field argument? string Command parameters.
---@field source? ltn12_source Upload source.
---@field sink? ltn12_sink Download sink.
---@field create? function socket Create function.

---@class socket_ftp_connection*
local socket_ftp_connection = {}

---@class socket_ftp*
---@field TIMEOUT number Default timeout.
---@field USER string Default username.
---@field PASSWORD string Default password.
---@field genericform table Common request fields.
---@type socket_ftp*
local M = {}

M.TIMEOUT = 60
M.USER = nil
M.PASSWORD = nil
M.genericform = nil

--- Open an FTP connection.
---@param server string server.
---@param port? integer port.
---@param create? function socket Create function.
---@return socket_ftp_connection*? connection Connection object.
---@return string? errMsg error message.
function M.open(server, port, create) end

--- Execute FTP command.
---@param request socket_ftp_request* Request form.
---@return any result result.
function M.command(request) end

--- Download FTP content.
---@param request string|socket_ftp_request* URL or request form.
---@return string|integer|nil bodyOrOk Response body or status.
---@return string? errMsg error message.
function M.get(request) end

--- Upload FTP content.
---@param request string|socket_ftp_request* URL or request form.
---@param body? string Request body.
---@return string|integer|nil result result.
---@return string? errMsg error message.
function M.put(request, body) end

--- LuaSocket try function.
---@param ... any value.
---@return any ... Non-error return value.
function M.try(...) end

return M
