using System; using System.Collections.Generic; using Newtonsoft.Json; namespace InABox.Logikal { public abstract class LogikalResponse : LogikalObject { public new abstract string ToString(); public LogikalResponse Always(Action handler) { handler?.Invoke(this); return this; } public LogikalResponse Error(Action handler, LogikalStatus status = LogikalStatus.IsError) { if (this is LogikalErrorResponse error && status.HasFlag(error.Status)) { handler?.Invoke(error); return null; } return this; } public T Success(Action handler) where T : LogikalResponse { if (this is T response) { handler?.Invoke(response); return response; } return null; } } }