Files
mapo-iob-libs/EgwProxy.Shelly/Clients/Shelly1PmClient.cs
T
2025-08-07 08:35:34 +02:00

32 lines
1.3 KiB
C#

using EgwProxy.Shelly.DTO;
using EgwProxy.Shelly.Options;
using Flurl;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace EgwProxy.Shelly.Clients
{
public class Shelly1PmClient : ShellyClientBase, IShelly1Pm
{
public Shelly1PmClient(HttpClient httpClient, ShellyOptions shellyOptions) : base(httpClient, shellyOptions)
{
}
public async Task<ShellyResult<Shelly1PmStatusDto>> GetStatus(CancellationToken cancellationToken, TimeSpan? timeout = null)
{
var endpoint = ServerUri.AppendPathSegment("Shelly.GetStatus");
var requestMessage = new HttpRequestMessage(HttpMethod.Get, endpoint);
return await ExecuteRequestAsync<Shelly1PmStatusDto>(requestMessage, cancellationToken, timeout);
}
public async Task<ShellyResult<DTO.Shelly1PM.SwitchDto>> GetSwitchStatus(CancellationToken cancellationToken, int id, TimeSpan? timeout = null)
{
var endpoint = ServerUri.AppendPathSegment("Switch.GetStatus").AppendQueryParam("id",id);
var requestMessage = new HttpRequestMessage(HttpMethod.Get, endpoint);
return await ExecuteRequestAsync<DTO.Shelly1PM.SwitchDto>(requestMessage, cancellationToken, timeout);
}
}
}