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

public class Put : MonoBehaviour
{
    private void Start()
    {
        // Example URLs for GET, POST, PUT, and DELETE requests
        string getUrl = "https://jsonplaceholder.typicode.com/posts/1";

        // Example custom headers
        var headers = new Dictionary<string, string>
        {
            { "Authorization", "Bearer your_token_here" },
            { "Custom-Header", "custom_value" },
            { "User-Agent", "CustomUserAgent/1.0" }
        };

        // Perform the request example
        PerformPutRequest(getUrl, headers);
    }

    // Example function to perform a PUT request with custom headers and data
    private void PerformPutRequest(string url, Dictionary<string, string> headers)
    {
        // Example JSON data for PUT request
        var putData = "{\"id\":1,\"title\":\"foo\",\"body\":\"bar\",\"userId\":1}";

        QuickRequest.Put(url, putData, headers,
            // Success callback
            response =>
            {
                Debug.Log($"PUT Request Successful.\nResponse: {response}");
            },
            // Error callback
            error =>
            {
                Debug.LogError($"PUT Request Failed.\nError: {error}");
            });
    }
}
