Innovenergy_trunk/csharp/Lib/Victron/VictronVRM/Installation.Settings.cs

22 lines
891 B
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
using System.Text.Json.Nodes;
namespace InnovEnergy.Lib.Victron.VictronVRM;
/// Settings are *read* as part of the json (Installation class) returned by GetInstallation*
/// Settings are *written* using a special request VrmAccount.SettingsRequest
public readonly partial record struct Installation
{
public Task<Boolean> SetNotes (String notes) => SetSettings(new JsonObject { ["notes"] = notes });
public Task<Boolean> SetName (String name) => SetSettings(new JsonObject { ["description"] = name });
public Task<Boolean> SetPhoneNumber(String phoneNb) => SetSettings(new JsonObject { ["phonenumber"] = phoneNb });
private async Task<Boolean> SetSettings(JsonObject settings)
{
var reply = await VrmAccount.SettingsRequest(IdSite).TryPostJson(settings);
var vrmReply = new Reply(reply);
return vrmReply.Success;
}
}