using RetroDev.Networking;
using System.Collections.Generic;
using UnityEngine;

public class Post : MonoBehaviour
{

    public void Start()
    {
        // Test endpoints
        string jsonTestUrl = "https://jsonplaceholder.typicode.com/posts";
        string plainTextUrl = "https://httpbin.org/post";

        // Basic headers 
        var headers = new Dictionary<string, string>
        {
            {"Accept", "*/*"},
            {"User-Agent", "Eidolon-Networking-Test"}
        };

        // 1. JSON POST with mixed data types
        var jsonData = new Dictionary<string, object>
        {
            {"title", "Test Post"},
            {"body", "This is a test post with multiple data types"},
            {"userId", 1},  // Integer
            {"isPublished", true},  // Boolean
            {"rating", 4.5f},  // Float
            {"tags", new string[] {"test", "example", "json"}}  // Array
        };

        QuickRequest.Post(
            jsonTestUrl,
            jsonData,
            ContentType.Json,
            headers,
            response => Debug.Log($"JSON POST Success: {response}"),
            error => Debug.LogError($"JSON POST Error: {error}")
        );

        // 2. Plain Text POST with mixed data types
        var plainTextData = new Dictionary<string, object>
        {
            {"message", "Hello from Eidolon"},
            {"timestamp", System.DateTime.Now.ToString()},
            {"requestNumber", 12345},
            {"temperature", 98.6f}
        };

        QuickRequest.Post(
            plainTextUrl,
            plainTextData,
            ContentType.PlainText,
            headers,
            response => Debug.Log($"Plain Text POST Success: {response}"),
            error => Debug.LogError($"Plain Text POST Error: {error}")
        );

        // 3. Complex JSON POST with nested data
        var complexJsonData = new Dictionary<string, object>
        {
            {"user", new Dictionary<string, object> {
                {"id", 1},
                {"name", "Test User"},
                {"stats", new Dictionary<string, object> {
                    {"level", 42},
                    {"experience", 9999},
                    {"achievements", new int[] {1, 2, 3, 4, 5}}
                }}
            }},
            {"gameState", new Dictionary<string, object> {
                {"currentLevel", 5},
                {"health", 100.0f},
                {"inventory", new string[] {"sword", "shield", "potion"}},
                {"position", new float[] {123.4f, 567.8f, 910.1f}}
            }}
        };

        QuickRequest.Post(
            jsonTestUrl,
            complexJsonData,
            ContentType.Json,
            headers,
            response => Debug.Log($"Complex JSON POST Success: {response}"),
            error => Debug.LogError($"Complex JSON POST Error: {error}")
        );
    }
}
