diff --git a/Quests/ReportQuestProgressRequest.cs b/Quests/ReportQuestProgressRequest.cs new file mode 100644 index 0000000..93c6d96 --- /dev/null +++ b/Quests/ReportQuestProgressRequest.cs @@ -0,0 +1,16 @@ +// Code generated by apigen. DO NOT EDIT. +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.Collections.Generic; + +namespace RudderSdk.Core.Models.Quests; + +public class ReportQuestProgressRequest +{ + [JsonProperty("amount")] + public long Amount { get; set; } + + [JsonProperty("metric")] + public string Metric { get; set; } + +} diff --git a/Quests/ReportQuestProgressResponse.cs b/Quests/ReportQuestProgressResponse.cs new file mode 100644 index 0000000..ed76646 --- /dev/null +++ b/Quests/ReportQuestProgressResponse.cs @@ -0,0 +1,13 @@ +// Code generated by apigen. DO NOT EDIT. +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.Collections.Generic; + +namespace RudderSdk.Core.Models.Quests; + +public class ReportQuestProgressResponse +{ + [JsonProperty("completedQuestIds")] + public List CompletedQuestIds { get; set; } + +} diff --git a/Services/QuestsService.cs b/Services/QuestsService.cs index e53e49d..ec98fb8 100644 --- a/Services/QuestsService.cs +++ b/Services/QuestsService.cs @@ -34,4 +34,16 @@ public sealed class QuestsService "/sdk/v1/quests/claim", new ClaimQuestRequest { QuestId = questId }, 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?.CompletedQuestIds ?? new List(); + } }