namespace ScadaLink.Commons.Messages.InboundApi;

/// <summary>
/// Request routed from Inbound API to a site to invoke a script on an instance.
/// Used by Route.To("instanceCode").Call("scriptName", params).
/// </summary>
public record RouteToCallRequest(
    string CorrelationId,
    string InstanceUniqueName,
    string ScriptName,
    IReadOnlyDictionary<string, object?>? Parameters,
    DateTimeOffset Timestamp);

/// <summary>
/// Response from a Route.To() call.
/// </summary>
public record RouteToCallResponse(
    string CorrelationId,
    bool Success,
    object? ReturnValue,
    string? ErrorMessage,
    DateTimeOffset Timestamp);

/// <summary>
/// Request to read attribute(s) from a remote instance.
/// </summary>
public record RouteToGetAttributesRequest(
    string CorrelationId,
    string InstanceUniqueName,
    IReadOnlyList<string> AttributeNames,
    DateTimeOffset Timestamp);

/// <summary>
/// Response containing attribute values from a remote instance.
/// </summary>
public record RouteToGetAttributesResponse(
    string CorrelationId,
    IReadOnlyDictionary<string, object?> Values,
    bool Success,
    string? ErrorMessage,
    DateTimeOffset Timestamp);

/// <summary>
/// Request to write attribute(s) on a remote instance.
/// </summary>
public record RouteToSetAttributesRequest(
    string CorrelationId,
    string InstanceUniqueName,
    IReadOnlyDictionary<string, string> AttributeValues,
    DateTimeOffset Timestamp);

/// <summary>
/// Response confirming attribute writes on a remote instance.
/// </summary>
public record RouteToSetAttributesResponse(
    string CorrelationId,
    bool Success,
    string? ErrorMessage,
    DateTimeOffset Timestamp);
