fix: remove unnecessary async methods, fix PluralkitApiService
This commit is contained in:
parent
086eb95452
commit
db01f879bd
10 changed files with 96 additions and 73 deletions
|
|
@ -3,6 +3,8 @@ using System.Text.Json;
|
|||
using System.Threading.RateLimiting;
|
||||
using Humanizer;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.SystemTextJson;
|
||||
using NodaTime.Text;
|
||||
using Polly;
|
||||
|
||||
namespace Catalogger.Backend.Services;
|
||||
|
|
@ -46,8 +48,14 @@ public class PluralkitApiService(ILogger logger)
|
|||
throw new CataloggerError("Non-200 status code from PluralKit API");
|
||||
}
|
||||
|
||||
return await resp.Content.ReadFromJsonAsync<T>(new JsonSerializerOptions
|
||||
{ PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower }, ct) ??
|
||||
var jsonOptions = new JsonSerializerOptions
|
||||
{ PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower }
|
||||
.ConfigureForNodaTime(new NodaJsonSettings
|
||||
{
|
||||
InstantConverter = new NodaPatternConverter<Instant>(InstantPattern.ExtendedIso)
|
||||
});
|
||||
|
||||
return await resp.Content.ReadFromJsonAsync<T>(jsonOptions, ct) ??
|
||||
throw new CataloggerError("JSON response from PluralKit API was null");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue