piwigodotnet/PiwigoDotnet/Piwigo.Client/SessionApi.cs

32 lines
1.0 KiB
C#
Raw Normal View History

using Microsoft.Extensions.Logging;
using Piwigo.Client.Contract;
namespace Piwigo.Client;
internal class SessionApi : ISessionApi
{
private readonly IPiwigoContext _context;
private readonly ILogger<SessionApi> _logger;
public SessionApi(IPiwigoContext context, ILogger<SessionApi> logger)
{
_context = context ?? throw new ArgumentNullException(nameof(context));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public Task LogoutAsync(CancellationToken cancellationToken = default)
{
return _context.LogoutAsync(cancellationToken);
}
public Task LoginAsync(CancellationToken cancellationToken = default)
{
return _context.LoginAsync(cancellationToken);
}
public async Task<SessionStatus> GetStatusAsync(CancellationToken cancellationToken = default)
{
var typedResponse = await _context.PostAsync<PiwigoResponse<SessionStatus>>(_logger, "pwg.session.getStatus", cancellationToken);
return typedResponse.Result;
}
}