mirror of
https://github.com/bitwarden/server.git
synced 2025-04-12 00:28:11 -05:00

* Remove gRPC and convert PricingClient to HttpClient wrapper * Add PlanType.GetProductTier extension Many instances of StaticStore use are just to get the ProductTierType of a PlanType, but this can be derived from the PlanType itself without having to fetch the entire plan. * Remove invocations of the StaticStore in non-Test code * Deprecate StaticStore entry points * Run dotnet format * Matt's feedback * Run dotnet format * Rui's feedback * Run dotnet format * Replacements since approval * Run dotnet format
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System.Text.Json;
|
|
using Bit.Core.Billing.Pricing.Models;
|
|
|
|
namespace Bit.Core.Billing.Pricing.JSON;
|
|
|
|
#nullable enable
|
|
|
|
public class FreeOrScalableDTOJsonConverter : TypeReadingJsonConverter<FreeOrScalableDTO>
|
|
{
|
|
public override FreeOrScalableDTO? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
var type = ReadType(reader);
|
|
|
|
return type switch
|
|
{
|
|
"free" => JsonSerializer.Deserialize<FreeDTO>(ref reader, options) switch
|
|
{
|
|
null => null,
|
|
var free => new FreeOrScalableDTO(free)
|
|
},
|
|
"scalable" => JsonSerializer.Deserialize<ScalableDTO>(ref reader, options) switch
|
|
{
|
|
null => null,
|
|
var scalable => new FreeOrScalableDTO(scalable)
|
|
},
|
|
_ => null
|
|
};
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, FreeOrScalableDTO value, JsonSerializerOptions options)
|
|
=> value.Switch(
|
|
free => JsonSerializer.Serialize(writer, free, options),
|
|
scalable => JsonSerializer.Serialize(writer, scalable, options)
|
|
);
|
|
}
|