From 9d8fb29a7cd9e59f2361f60b9522ab94064d63ca Mon Sep 17 00:00:00 2001 From: edmand46 Date: Thu, 13 Aug 2026 12:10:09 +0300 Subject: [PATCH] quests: ReportProgressAsync + generated DTOs --- Quests/ReportQuestProgressRequest.cs | 16 ++++++++++++++++ Quests/ReportQuestProgressResponse.cs | 13 +++++++++++++ Services/QuestsService.cs | 12 ++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 Quests/ReportQuestProgressRequest.cs create mode 100644 Quests/ReportQuestProgressResponse.cs 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(); + } }