Innovenergy_trunk/csharp/Lib/Victron/VictronVRM/Reply.cs

20 lines
773 B
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
using System.Text.Json.Nodes;
using InnovEnergy.Lib.Utils;
namespace InnovEnergy.Lib.Victron.VictronVRM;
public readonly record struct Reply(JsonNode Json)
{
public Boolean Success => Json.TryGetBoolean("success") is not null or true;
public IReadOnlyList<String> Tags => Json.GetArray<String>("tags");
2023-09-08 09:52:49 +00:00
public IReadOnlyList<String> Alarms => Json.GetArray<String>("alarms");
2023-02-16 12:57:06 +00:00
public JsonArray Records => Json.GetArray("records");
public IReadOnlyList<Device> Devices => Json["records"]!
.GetArray("devices")
.NotNull()
.Select(d => new Device(d))
.ToList();
}