Skip to content

Commit

Permalink
AnalyticsEvent and all payloads are immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
Bardin08 committed Jun 1, 2024
1 parent 04d8fe4 commit 1dfe6c2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions Trumpee.MassTransit.Messages/Analytics/AnalyticsEvent.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
namespace Trumpee.MassTransit.Messages.Analytics;

public class AnalyticsEvent<TBody>
public record AnalyticsEvent<TBody>
{
private AnalyticsEvent()
{
}

public TBody? Payload { get; set; }
public TBody? Payload { get; init; }

public required string StreamId { get; set; }
public required string Id { get; set; }
public required string Action { get; set; }
public required string Version { get; set; }
public required string Source { get; set; }
public DateTimeOffset Timestamp { get; set; }
public Dictionary<string, string>? Metadata { get; set; }
public required string StreamId { get; init; }
public required string Id { get; init; }
public required string Action { get; init; }
public required string Version { get; init; }
public required string Source { get; init; }
public DateTimeOffset Timestamp { get; init; }
public Dictionary<string, string>? Metadata { get; init; }

internal static AnalyticsEvent<T> Create<T>(
string streamId, string action, string source, T? payload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
/// <summary>
/// Represents the payload for a template filled event.
/// </summary>
public class TemplateFilledPayload
public record TemplateFilledPayload
{
/// <summary>
/// Gets or sets the ID of the template.
/// </summary>
public required string TemplateId { get; set; }
public required string TemplateId { get; init; }

/// <summary>
/// Gets or sets the ID of the notification.
/// </summary>
public required string NotificationId { get; set; }
public required string NotificationId { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
/// <summary>
/// Represents the payload for a template not filled event.
/// </summary>
public class TemplateNotFilledPayload
public record TemplateNotFilledPayload
{
/// <summary>
/// Gets or sets the ID of the template.
/// </summary>
public required string TemplateId { get; set; }
public required string TemplateId { get; init; }

/// <summary>
/// Gets or sets the ID of the notification.
/// </summary>
public required string NotificationId { get; set; }
public required string NotificationId { get; init; }

/// <summary>
/// Gets or sets the list of errors that occurred.
/// </summary>
public IReadOnlyList<string>? Errors { get; set; }
public IReadOnlyList<string>? Errors { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
/// <summary>
/// Represents the payload for a template not found event.
/// </summary>
public class TemplateNotFoundPayload
public record TemplateNotFoundPayload
{
/// <summary>
/// Gets or sets the ID of the template.
/// </summary>
public required string TemplateId { get; set; }
public required string TemplateId { get; init; }

/// <summary>
/// Gets or sets the properties associated with the event.
/// </summary>
public Dictionary<string, string>? Properties { get; set; }
public Dictionary<string, string>? Properties { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Represents the payload for a user sign-in event.
/// </summary>
public class UserSignInPayload
public record UserSignInPayload
{
/// <summary>
/// Gets or sets the email of the user.
Expand Down

0 comments on commit 1dfe6c2

Please sign in to comment.