#include "chatapi.h"

#include <QJsonDocument>
#include <QJsonObject>
#include <QUrlQuery>
#include <QVariantMap>

namespace ChatApi {

QFuture<HttpResponse> createRoom(const QString& roomName, const QString& description, int maxUsers)
{
    QJsonObject jsonData;
    jsonData["roomName"] = roomName;
    
    if (!description.isEmpty()) {
        jsonData["description"] = description;
    }
    
    jsonData["maxUsers"] = maxUsers;
    QJsonDocument doc(jsonData);

    return TC::RequestClient::globalInstance()->postAsync("/api/rooms", doc);
}

QFuture<HttpResponse> getRoomList(int page, int pageSize)
{
    QVariantMap params;
    params["page"] = page;
    params["pageSize"] = pageSize;

    return TC::RequestClient::globalInstance()->getAsync("/api/rooms", params);
}

} // namespace ChatApi
