using System.Net.Http;
using System.Text;
using System.Text.Json;

namespace HardwareAgent
{
    public static class ApiClient
    {
        private static readonly string SERVER_URL =
            "http://technicalsams.my.id/monitoring/api/monitoring/receive.php";

        private static readonly string API_KEY = "SECRET_API_KEY_ANDA";

        public static async void Send(object data)
        {
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("Authorization", $"Bearer {API_KEY}");

                string json = JsonSerializer.Serialize(data);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                await client.PostAsync(SERVER_URL, content);
            }
        }
    }
}
