using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; namespace RudderSdk.Core; /// /// A scenario battle-pass-level node — a single claimable tier. /// posts onComplete, which the server accepts /// only once the player has reached the node's configured level. /// public sealed class BattlePassLevelEffect { private readonly EffectHandle _handle; internal BattlePassLevelEffect(EffectHandle handle) => _handle = handle; /// Run id. public string RunId => _handle.RunId; /// Scenario id. public string ScenarioSlug => _handle.ScenarioSlug; /// Node id. public string NodeId => _handle.NodeId; /// The tier level this node claims. public int Level => _handle.Get("levelNumber", 0); /// 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); /// Claims this tier; posts onComplete. public Task ClaimAsync(CancellationToken cancellationToken = default) => _handle.CompleteAsync("onComplete", cancellationToken); /// Claims this tier (fire-and-forget). public void Claim() => _handle.Complete("onComplete"); }