using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using RudderSdk.Core.Models.Quests; namespace RudderSdk.Core; /// /// Global quests (list + claim), distinct from scenario quest nodes which /// advance through . /// public sealed class QuestsService { private readonly RudderClient _client; internal QuestsService(RudderClient client) => _client = client; /// Lists the player's quests with per-objective progress and rewards. public async Task> ListAsync(CancellationToken cancellationToken = default) { var response = await _client.SendAsync( "POST", "/sdk/v1/quests/list", cancellationToken).ConfigureAwait(false); return response?.Quests ?? new List(); } /// Claims a completed quest's rewards (idempotent server-side). public Task ClaimAsync(string questSlug, CancellationToken cancellationToken = default) => _client.SendAsync( "POST", "/sdk/v1/quests/claim", new ClaimQuestRequest { QuestSlug = questSlug }, cancellationToken); /// Reports progress for a metric and returns the ids of quests completed by this report. public async Task> ReportProgressAsync(string metric, long amount, CancellationToken cancellationToken = default) { var response = await _client.SendAsync( "POST", "/sdk/v1/quests/progress", new ReportQuestProgressRequest { Metric = metric, Amount = amount }, cancellationToken).ConfigureAwait(false); return response?.CompletedQuestSlugs ?? new List(); } }