2022-10-15 00:07:59 +02:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2022-10-16 22:58:38 +02:00
|
|
|
public Task LogoutAsync()
|
2022-10-15 00:07:59 +02:00
|
|
|
{
|
2022-10-16 22:58:38 +02:00
|
|
|
return _context.LogoutAsync();
|
2022-10-15 00:07:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-16 22:58:38 +02:00
|
|
|
public Task LoginAsync()
|
2022-10-15 00:07:59 +02:00
|
|
|
{
|
2022-10-16 22:58:38 +02:00
|
|
|
return _context.LoginAsync();
|
2022-10-15 00:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<PiwigoStatus> GetStatusAsync()
|
|
|
|
{
|
|
|
|
_logger.LogInformation("Getting status");
|
2022-10-16 22:58:38 +02:00
|
|
|
var typedResponse = await _context.PostAsync<PiwigoResponse<PiwigoStatus>>(_logger, "pwg.session.getStatus");
|
2022-10-15 00:07:59 +02:00
|
|
|
return typedResponse.Result;
|
|
|
|
}
|
|
|
|
}
|