#include <spdlog/spdlog.h>
#include "./unregister_capability.hpp"
#include "../../protocol/transform/facade.hpp"

namespace lsp::provider::client
{
    std::string UnregisterCapability::GetMethod() const
    {
        return "client/unregisterCapability";
    }

    std::string UnregisterCapability::GetProviderName() const
    {
        return "ClientUnregisterCapability";
    }

    std::string UnregisterCapability::ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context)
    {
        static_cast<void>(context);
        spdlog::debug("UnregisterCapabilityProvider: Providing response for method {}", request.method);
        protocol::ResponseMessage response;
        response.id = request.id;
        response.result = std::nullopt;

        std::optional<std::string> json = transform::Serialize(response);
        if (!json.has_value())
            return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Internal error");
        return json.value();
    }
}
