32 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|