From 495032cc7d0fa6d8d7390bb9c513f971a054bb76 Mon Sep 17 00:00:00 2001 From: Sakura Akeno Isayeki Date: Sun, 1 Sep 2024 12:03:49 +0200 Subject: [PATCH] feat(dto): Add SupportTicketStatus field to PlayerPostDTO + Mappings This commit adds a new field, SupportTicketStatus, to the PlayerPostDTO class in the WowsKarma.Common project. The SupportTicketStatus field represents the status of the Customer Support ticket associated with the post when applicable. Additionally, mappings are configured in the Conversions utility class to map the CustomerSupportTicketId property of Post to TicketId property of SupportTicketStatus in PlayerPostDTO. This allows for seamless conversion between Post and PlayerPostDTO objects while preserving the relevant information about Customer Support tickets. --- WowsKarma.Api/Utilities/Conversions.cs | 16 +++++++++--- WowsKarma.Common/Models/DTOs/PlayerPostDTO.cs | 25 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/WowsKarma.Api/Utilities/Conversions.cs b/WowsKarma.Api/Utilities/Conversions.cs index edf1928..c69d72d 100644 --- a/WowsKarma.Api/Utilities/Conversions.cs +++ b/WowsKarma.Api/Utilities/Conversions.cs @@ -15,12 +15,17 @@ public static class Conversions public static void ConfigureMapping() { TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileWithDebugInfo(); - + TypeAdapterConfig .NewConfig() .IgnoreNullValues(true) .Ignore(dest => dest.Author) - .Ignore(dest => dest.Player); + .Ignore(dest => dest.Player) + .Map( + dest => dest.CustomerSupportTicketId, + src => src.SupportTicketStatus.TicketId, + srcCond => srcCond.SupportTicketStatus.TicketId != null + ); TypeAdapterConfig .NewConfig() @@ -34,7 +39,12 @@ public static void ConfigureMapping() : ReplayState.Processing ) .Map(dest => dest.Author.Clan, src => src.Author.ClanMember.Clan) - .Map(dest => dest.Player.Clan, src => src.Player.ClanMember.Clan); + .Map(dest => dest.Player.Clan, src => src.Player.ClanMember.Clan) + .Map(dest => dest.SupportTicketStatus, src => new PlayerPostDTO.CustomerSupportStatus + { + HasTicket = src.CustomerSupportTicketId != null, + TicketId = src.CustomerSupportTicketId + }); TypeAdapterConfig .NewConfig() diff --git a/WowsKarma.Common/Models/DTOs/PlayerPostDTO.cs b/WowsKarma.Common/Models/DTOs/PlayerPostDTO.cs index 87693cd..489f5c8 100644 --- a/WowsKarma.Common/Models/DTOs/PlayerPostDTO.cs +++ b/WowsKarma.Common/Models/DTOs/PlayerPostDTO.cs @@ -26,4 +26,29 @@ public record PlayerPostDTO // Computed by DB Engine (hopefully) public DateTimeOffset? CreatedAt { get; init; } public DateTimeOffset? UpdatedAt { get; init; } + + /// + /// The status of the Customer Support ticket associated with the post when applicable. + /// + public CustomerSupportStatus SupportTicketStatus { get; init; } + + /// + /// Defines the status of the Customer Support ticket associated with the post when applicable. + /// + public struct CustomerSupportStatus + { + /// + /// Whether the post has an associated Customer Support ticket. + /// + public bool HasTicket { get; init; } + + /// + /// The Customer Support ticket ID associated with this post. + /// + /// + /// This is only available when is , + /// and only visible to the post's author, platform staff, and Wargaming staff. + /// + public int? TicketId { get; init; } + } }