using System;
using System.Collections.Generic;
namespace MCPForUnity.Editor.Helpers
{
///
/// Provides static methods for creating standardized success and error response objects.
/// Ensures consistent JSON structure for communication back to the Python server.
///
public static class Response
{
///
/// Creates a standardized success response object.
///
/// A message describing the successful operation.
/// Optional additional data to include in the response.
/// An object representing the success response.
public static object Success(string message, object data = null)
{
if (data != null)
{
return new
{
success = true,
message = message,
data = data,
};
}
else
{
return new { success = true, message = message };
}
}
///
/// Creates a standardized error response object.
///
/// A message describing the error.
/// Optional additional data (e.g., error details) to include.
/// An object representing the error response.
public static object Error(string errorMessage, object data = null)
{
if (data != null)
{
// Note: The key is "error" for error messages, not "message"
return new
{
success = false,
error = errorMessage,
data = data,
};
}
else
{
return new { success = false, error = errorMessage };
}
}
}
}