using BHJD.DBdll.Public;
using Cysharp.Threading.Tasks;

namespace SimulationServer.Utils;

public class HttpManager
{
    public static async UniTask<string> Post(string url, string json)
    {
        HttpClient client = new HttpClient();
        HttpContent content = new StringContent(json);
        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
        HttpResponseMessage response = await client.PostAsync(url, content);
        return await response.Content.ReadAsStringAsync();
    }
    
    public static string Get(string url, List<string> key,List<string> value)
    {
        IHttpHelper.HttpCmd type = new IHttpHelper.HttpCmd
        {
            m_RequestType = IHttpHelper.HttpRequestType.GET,
            m_Addr = url,
            m_Args = key
        };
        
        HttpHelper httpHelper = new HttpHelper();
        return httpHelper.Request(type, value);
    }
}