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-10-09 12:23:31 +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();
|
|
|
|
}
|