using Microsoft.Extensions.Configuration;
using RestSharp;

namespace LazyBear.MCP.Services.Confluence;

public static class ConfluenceClientFactory
{
    public static RestClient CreateClient(IConfiguration configuration)
    {
        var confluenceUrl = configuration["Confluence:Url"] ?? "";

        if (string.IsNullOrWhiteSpace(confluenceUrl))
        {
            throw new Exception("Confluence:Url нe задан");
        }

        var config = new RestClientOptions(confluenceUrl)
        {
            UserAgent = "LazyBear-Confluence-MCP",
            Timeout = TimeSpan.FromMilliseconds(30000)
        };

        return new RestClient(config);
    }
}
