2023-02-16 12:57:06 +00:00
|
|
|
using Flurl;
|
|
|
|
using Flurl.Http;
|
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Victron.VictronVRM;
|
|
|
|
|
|
|
|
public static class Requests
|
|
|
|
{
|
|
|
|
private const String ApiRoot = "https://vrmapi.victronenergy.com/v2/";
|
|
|
|
|
|
|
|
public static FlurlRequest LoginRequest { get; } = new FlurlRequest(ApiRoot.AppendPathSegments("auth", "login"));
|
|
|
|
|
|
|
|
public static IFlurlRequest LogoutRequest(this VrmAccount account)
|
|
|
|
{
|
|
|
|
return ApiRoot
|
|
|
|
.AppendPathSegments("auth", "logout")
|
|
|
|
.WithHeader("X-Authorization", account.Auth);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IFlurlRequest DetailsRequest(this VrmAccount account, UInt64 installationId, Int32 nDetails = 1000)
|
|
|
|
{
|
|
|
|
return InstallationRequest(account, installationId)
|
|
|
|
.AppendPathSegment("diagnostics")
|
|
|
|
.SetQueryParams(new { count = nDetails });
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IFlurlRequest InstallationRequest(this VrmAccount account, UInt64 installationId)
|
|
|
|
{
|
|
|
|
return ApiRoot
|
|
|
|
.AppendPathSegment("installations")
|
|
|
|
.AppendPathSegment(installationId)
|
|
|
|
.WithHeader("X-Authorization", account.Auth);
|
|
|
|
}
|
|
|
|
|
2023-06-01 13:29:39 +00:00
|
|
|
public static IFlurlRequest SpecificInstallationRequest(this VrmAccount account, UInt64 installationId)
|
|
|
|
{
|
|
|
|
return ApiRoot
|
|
|
|
.AppendPathSegment("users")
|
|
|
|
.AppendPathSegment(account.UserId)
|
|
|
|
.AppendPathSegment("installations")
|
|
|
|
.AppendPathSegment(installationId)
|
|
|
|
.WithHeader("X-Authorization", account.Auth);
|
|
|
|
}
|
|
|
|
|
2023-02-16 12:57:06 +00:00
|
|
|
public static IFlurlRequest AllInstallationsRequest(this VrmAccount account)
|
|
|
|
{
|
|
|
|
return ApiRoot
|
|
|
|
.AppendPathSegment("users")
|
|
|
|
.AppendPathSegment(account.UserId)
|
|
|
|
.AppendPathSegment("installations")
|
2023-04-27 14:59:45 +00:00
|
|
|
.WithHeader("x-authorization", account.Auth);
|
2023-02-16 12:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IFlurlRequest TagsRequest(this VrmAccount account, UInt64 installationId)
|
|
|
|
{
|
|
|
|
return InstallationRequest(account, installationId)
|
|
|
|
.AppendPathSegment("tags");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IFlurlRequest SettingsRequest(this VrmAccount account, UInt64 installationId)
|
|
|
|
{
|
|
|
|
return InstallationRequest(account, installationId)
|
|
|
|
.AppendPathSegment("settings");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IFlurlRequest DevicesRequest(this VrmAccount account, UInt64 installationId)
|
|
|
|
{
|
|
|
|
return InstallationRequest(account, installationId)
|
|
|
|
.AppendPathSegment("system-overview");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|