Skip to content

Commit

Permalink
feat(dto): Add SupportTicketStatus field to PlayerPostDTO + Mappings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SakuraIsayeki committed Sep 1, 2024
1 parent 3a8426a commit 495032c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
16 changes: 13 additions & 3 deletions WowsKarma.Api/Utilities/Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ public static class Conversions
public static void ConfigureMapping()
{
TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileWithDebugInfo();

TypeAdapterConfig<PlayerPostDTO, Post>
.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<Post, PlayerPostDTO>
.NewConfig()
Expand All @@ -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<PostModActionDTO, PostModAction>
.NewConfig()
Expand Down
25 changes: 25 additions & 0 deletions WowsKarma.Common/Models/DTOs/PlayerPostDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,29 @@ public record PlayerPostDTO
// Computed by DB Engine (hopefully)
public DateTimeOffset? CreatedAt { get; init; }
public DateTimeOffset? UpdatedAt { get; init; }

/// <summary>
/// The status of the Customer Support ticket associated with the post when applicable.
/// </summary>
public CustomerSupportStatus SupportTicketStatus { get; init; }

/// <summary>
/// Defines the status of the Customer Support ticket associated with the post when applicable.
/// </summary>
public struct CustomerSupportStatus
{
/// <summary>
/// Whether the post has an associated Customer Support ticket.
/// </summary>
public bool HasTicket { get; init; }

/// <summary>
/// The Customer Support ticket ID associated with this post.
/// </summary>
/// <remarks>
/// This is only available when <see cref="HasTicket"/> is <see langword="true"/>,
/// and only visible to the post's author, platform staff, and Wargaming staff.
/// </remarks>
public int? TicketId { get; init; }
}
}

0 comments on commit 495032c

Please sign in to comment.