Initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using RudderSdk.Core.Models.Quests;
|
||||
|
||||
namespace RudderSdk.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Global quests (list + claim), distinct from scenario quest nodes which
|
||||
/// advance through <see cref="QuestSession"/>.
|
||||
/// </summary>
|
||||
public sealed class QuestsService
|
||||
{
|
||||
private readonly RudderClient _client;
|
||||
|
||||
internal QuestsService(RudderClient client) => _client = client;
|
||||
|
||||
/// <summary>Lists the player's quests with per-objective progress and rewards.</summary>
|
||||
public async Task<IReadOnlyList<Quest>> ListAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var response = await _client.SendAsync<ListQuestsRequest, ListQuestsResponse>(
|
||||
"POST",
|
||||
"/sdk/v1/quests/list",
|
||||
new ListQuestsRequest(),
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response?.Quests ?? new List<Quest>();
|
||||
}
|
||||
|
||||
/// <summary>Claims a completed quest's rewards (idempotent server-side).</summary>
|
||||
public Task<ClaimQuestResponse> ClaimAsync(string questId, CancellationToken cancellationToken = default)
|
||||
=> _client.SendAsync<ClaimQuestRequest, ClaimQuestResponse>(
|
||||
"POST",
|
||||
"/sdk/v1/quests/claim",
|
||||
new ClaimQuestRequest { QuestId = questId },
|
||||
cancellationToken);
|
||||
}
|
||||
Reference in New Issue
Block a user