2022-10-15 00:07:59 +02:00
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Piwigo.Client.Contract;
|
|
|
|
|
|
|
|
namespace Piwigo.Client;
|
|
|
|
|
2022-10-25 21:58:07 +02:00
|
|
|
public class SessionApi : ISessionApi
|
2022-10-15 00:07:59 +02:00
|
|
|
{
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2022-10-17 23:22:48 +02:00
|
|
|
public Task LogoutAsync(CancellationToken cancellationToken = default)
|
2022-10-15 00:07:59 +02:00
|
|
|
{
|
2022-10-17 23:22:48 +02:00
|
|
|
return _context.LogoutAsync(cancellationToken);
|
2022-10-15 00:07:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-17 23:22:48 +02:00
|
|
|
public Task LoginAsync(CancellationToken cancellationToken = default)
|
2022-10-15 00:07:59 +02:00
|
|
|
{
|
2022-10-17 23:22:48 +02:00
|
|
|
return _context.LoginAsync(cancellationToken);
|
2022-10-15 00:07:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-17 23:22:48 +02:00
|
|
|
public async Task<SessionStatus> GetStatusAsync(CancellationToken cancellationToken = default)
|
2022-10-15 00:07:59 +02:00
|
|
|
{
|
2022-10-17 23:22:48 +02:00
|
|
|
var typedResponse = await _context.PostAsync<PiwigoResponse<SessionStatus>>(_logger, "pwg.session.getStatus", cancellationToken);
|
2022-10-15 00:07:59 +02:00
|
|
|
return typedResponse.Result;
|
|
|
|
}
|
|
|
|
}
|