using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; namespace RudderSdk.Core; /// A scenario notification node. posts the output callback. public sealed class NotificationEffect { private readonly EffectHandle _handle; internal NotificationEffect(EffectHandle handle) => _handle = handle; /// Run id. public string RunId => _handle.RunId; /// Scenario id. public string ScenarioId => _handle.ScenarioId; /// Node id. public string NodeId => _handle.NodeId; /// Notification title. public string Title => _handle.Get("title", string.Empty); /// Notification message. public string Message => _handle.Get("message", string.Empty); /// Node data payload. public JObject Data => _handle.Data; /// Reads a typed value from the node data. public T Get(string key, T defaultValue = default!) => _handle.Get(key, defaultValue); /// Posts the output callback. public Task DoneAsync(CancellationToken cancellationToken = default) => _handle.CompleteAsync("output", cancellationToken); /// Posts the output callback (fire-and-forget). public void Done() => _handle.Complete("output"); }