using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace InABox.Integration.Logikal
{
    public abstract class LogikalResponse : LogikalObject
    {


        public new abstract string ToString();

        public LogikalResponse Always(Action<LogikalResponse> handler)
        {
            handler?.Invoke(this);
            return this;
        }

        public LogikalResponse Error(Action<LogikalErrorResponse> handler, LogikalStatus status = LogikalStatus.IsError)
        {
            if (this is LogikalErrorResponse error && status.HasFlag(error.Status))
                handler?.Invoke(error);
            return this;
        }

        public LogikalResponse Success<T>(Action<T> handler) where T : LogikalResponse
        {
            if (this is T response)
                handler?.Invoke(response);
            return this;
        }




    }
}