Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ protected HttpRequestMessage BuildRequest<T>(HttpMethod method, Uri requestUri,
{
var request = new HttpRequestMessage(method, requestUri);

string json = JsonSerializer.Serialize(body, this.SerializerOptions);

string json = JsonSerializer.Serialize(body, body.GetType(), this.SerializerOptions);
request.Content = new StringContent(json, Encoding.UTF8, "application/json");

return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Marain.UserNotifications.Client.Management.Resources.CommunicationTemp
using Menes.Hal;

/// <summary>
/// The web push template resource structure.
/// The email template resource structure.
/// </summary>
[JsonConverter(typeof(EmailTemplateResourceConverter))]
public class EmailTemplateResource : IHalDocumentResource
Expand Down Expand Up @@ -41,50 +41,50 @@ public EmailTemplateResource(in HalDocumentResource source)
public WebLink SelfLink => this.HalDocument.SelfLink;

/// <summary>
/// Gets the body of a WebPush notification.
/// Gets the notification type of an email notification.
/// </summary>
public string Body
public string NotificationType
{
get
{
if (this.HalDocument.TryGetProperty("body", out JsonElement body) &&
body.ValueKind == JsonValueKind.String)
if (this.HalDocument.TryGetProperty("notificationType", out JsonElement notificationType) &&
notificationType.ValueKind == JsonValueKind.String)
{
return body.GetString();
return notificationType.GetString();
}

throw new Exception("Schema violation - this value is required.");
}
}

/// <summary>
/// Gets the title of the WebPush notification.
/// Gets the body of a Email notification.
/// </summary>
public string Title
public string Body
{
get
{
if (this.HalDocument.TryGetProperty("title", out JsonElement title) &&
title.ValueKind == JsonValueKind.String)
if (this.HalDocument.TryGetProperty("body", out JsonElement body) &&
body.ValueKind == JsonValueKind.String)
{
return title.GetString();
return body.GetString();
}

throw new Exception("Schema violation - this value is required.");
}
}

/// <summary>
/// Gets the Base64 image of a WebPush notification.
/// Gets the title of the email notification.
/// </summary>
public string Image
public string Subject
{
get
{
if (this.HalDocument.TryGetProperty("image", out JsonElement image) &&
image.ValueKind == JsonValueKind.String)
if (this.HalDocument.TryGetProperty("subject", out JsonElement subject) &&
subject.ValueKind == JsonValueKind.String)
{
return image.GetString();
return subject.GetString();
}

throw new Exception("Schema violation - this value is required.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ public SmsTemplateResource(in HalDocumentResource source)
/// <inheritdoc/>
public WebLink SelfLink => this.HalDocument.SelfLink;

/// <summary>
/// Gets the notification type of an SMS notification.
/// </summary>
public string NotificationType
{
get
{
if (this.HalDocument.TryGetProperty("notificationType", out JsonElement notificationType) &&
notificationType.ValueKind == JsonValueKind.String)
{
return notificationType.GetString();
}

throw new Exception("Schema violation - this value is required.");
}
}

/// <summary>
/// Gets the body of a WebPush notification.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ public WebPushTemplateResource(in HalDocumentResource source)
/// <inheritdoc/>
public WebLink SelfLink => this.HalDocument.SelfLink;

/// <summary>
/// Gets the notification type of a WebPush notification.
/// </summary>
public string NotificationType
{
get
{
if (this.HalDocument.TryGetProperty("notificationType", out JsonElement notificationType) &&
notificationType.ValueKind == JsonValueKind.String)
{
return notificationType.GetString();
}

throw new Exception("Schema violation - this value is required.");
}
}

/// <summary>
/// Gets the body of a WebPush notification.
/// </summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading