From dd9be1a6af6b44b6911761eec0582cf17102dfeb Mon Sep 17 00:00:00 2001 From: Matthew Jorgensen Date: Fri, 4 Oct 2024 15:15:56 -0500 Subject: [PATCH 1/2] Target .NET 8 --- src/LinkAce.NET/LinkAce.NET.csproj | 2 +- src/TestApp/TestApp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LinkAce.NET/LinkAce.NET.csproj b/src/LinkAce.NET/LinkAce.NET.csproj index 48c25b5..a64470b 100644 --- a/src/LinkAce.NET/LinkAce.NET.csproj +++ b/src/LinkAce.NET/LinkAce.NET.csproj @@ -1,7 +1,7 @@ - net7.0;net8.0 + net8.0 enable enable 0.0.3 diff --git a/src/TestApp/TestApp.csproj b/src/TestApp/TestApp.csproj index 84b7392..2f5f7ed 100644 --- a/src/TestApp/TestApp.csproj +++ b/src/TestApp/TestApp.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable False From 4fb3b41f186d34bfcbfc107af4a4be7df665915b Mon Sep 17 00:00:00 2001 From: Matthew Jorgensen Date: Fri, 4 Oct 2024 15:17:08 -0500 Subject: [PATCH 2/2] Set serialization options --- src/LinkAce.NET/LinkAceClient.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/LinkAce.NET/LinkAceClient.cs b/src/LinkAce.NET/LinkAceClient.cs index fd466a7..956a534 100644 --- a/src/LinkAce.NET/LinkAceClient.cs +++ b/src/LinkAce.NET/LinkAceClient.cs @@ -17,6 +17,9 @@ public class LinkAceClient { private static string? _apiUrl; private static HttpClient _client; + private JsonSerializerOptions _serializationOptions = new(JsonSerializerDefaults.Web){ + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower + }; /// /// Initializes a new instance of the class with the specified URL and HTTP client. /// @@ -51,7 +54,7 @@ public LinkAceClient(string linkAceUrl, string apiToken, HttpClient? client = nu public async Task CreateLink(Link link) { var response = await _client.PostAsync($"{_apiUrl}/links", - new StringContent(JsonSerializer.Serialize(link), Encoding.UTF8, + new StringContent(JsonSerializer.Serialize(link, _serializationOptions), Encoding.UTF8, MediaTypeNames.Application.Json)); return response; } @@ -80,7 +83,7 @@ public LinkAceClient(string linkAceUrl, string apiToken, HttpClient? client = nu public async Task UpdateLinkById(int id, Link link) { var response = await _client.PatchAsync($"{_apiUrl}/links/{id}", - new StringContent(JsonSerializer.Serialize(link), Encoding.UTF8, + new StringContent(JsonSerializer.Serialize(link, _serializationOptions), Encoding.UTF8, MediaTypeNames.Application.Json)); return response; }