Skip to content

Commit

Permalink
fix(repo): ensure null values dont show in responses
Browse files Browse the repository at this point in the history
  • Loading branch information
AJCJ1 committed Dec 20, 2024
1 parent f821f66 commit 156c009
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
38 changes: 38 additions & 0 deletions UrlboxSDK/Metadata/Resource/UrlboxMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Text.Json.Serialization;

namespace UrlboxSDK.Metadata.Resource;

/// <summary>
Expand All @@ -8,23 +10,59 @@ public sealed class UrlboxMetadata
public string UrlRequested { get; }
public string UrlResolved { get; }
public string Url { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Author { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Date { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Description { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Image { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Logo { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Publisher { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Title { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? OgTitle { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public OgImage[]? OgImage { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? OgDescription { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? OgUrl { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? OgType { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? OgSiteName { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? OgLocale { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Charset { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TwitterCard { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TwitterSite { get; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TwitterCreator { get; }

public UrlboxMetadata(
Expand Down
5 changes: 4 additions & 1 deletion UrlboxSDK/Response/Resource/AsyncUrlboxResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ public sealed class AsyncUrlboxResponse : AbstractUrlboxResponse
{
public string Status { get; } // EG 'succeeded'
public string RenderId { get; } // A UUID for the request
public string StatusUrl { get; } // A url which you can poll to check the render's status
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? StatusUrl { get; } // A url which you can poll to check the render's status
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? RenderUrl { get; } // only on status succeeded
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Size { get; } // only on status succeeded

[JsonConstructor]
Expand Down
2 changes: 2 additions & 0 deletions UrlboxSDK/Webhook/Resource/UrlboxWebhookResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ public sealed class UrlboxWebhookResponse
{
public string Event { get; }
public string RenderId { get; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ErrorUrlboxResponse.UrlboxError? Error { get; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public SyncUrlboxResponse? Result { get; }
public Meta Meta { get; }

Expand Down

0 comments on commit 156c009

Please sign in to comment.