45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Telegram.Bot.SpaceApi.Backend;
|
|
|
|
public partial class SpaceApiResponse {
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
[JsonPropertyName("api")]
|
|
public string Api { get; set; }
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
[JsonPropertyName("space")]
|
|
public string Space { get; set; }
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
[JsonPropertyName("url")]
|
|
public Uri Url { get; set; }
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
[JsonPropertyName("state")]
|
|
public State State { get; set; }
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
[JsonPropertyName("open")]
|
|
public bool? Open { get; set; }
|
|
}
|
|
|
|
public class State {
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
[JsonPropertyName("open")]
|
|
public bool? Open { get; set; }
|
|
}
|
|
|
|
public partial class SpaceApiResponse {
|
|
public static SpaceApiResponse FromJson(string json) => JsonSerializer.Deserialize<SpaceApiResponse>(json, Converter.Settings);
|
|
}
|
|
|
|
public static class Serialize {
|
|
public static string ToJson(this SpaceApiResponse self) => JsonSerializer.Serialize(self, Converter.Settings);
|
|
}
|
|
|
|
internal static class Converter {
|
|
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General);
|
|
}
|