using System; using System.Threading; using System.Threading.Tasks; namespace RudderSdk.Core; /// Session of a scenario leaderboard node. public sealed class LeaderboardSession { internal LeaderboardSession(ScenarioNodeContext context) => Context = context; /// Underlying node context. public ScenarioNodeContext Context { get; } /// Node id. public string Id => Context.NodeId; /// Reads a typed value from the node data. public T Get(string key, T defaultValue = default!) => Context.Get(key, defaultValue); /// Advances the run through the onEnd handle. public Task EndAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onEnd", cancellationToken); /// Advances the run through the onEnd handle (fire-and-forget). public void End() => Context.Complete("onEnd"); /// Advances the run through the onClaim handle. The server matches live rank to a place. public Task ClaimAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onClaim", cancellationToken); /// Advances the run through the onClaim handle (fire-and-forget). public void Claim() => Context.Complete("onClaim"); /// Advances the run through the onClaim handle. [Obsolete("Use ClaimAsync. Removed in the next SDK version.")] public Task RewardClaimedAsync(CancellationToken cancellationToken = default) => ClaimAsync(cancellationToken); /// Advances the run through the onClaim handle (fire-and-forget). [Obsolete("Use Claim. Removed in the next SDK version.")] public void RewardClaimed() => Claim(); }