piwigodotnet/PiwigoDotnet/Piwigo.Client/SessionApi.cs

32 lines
861 B
C#

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()
{
return _context.LogoutAsync();
}
public Task LoginAsync()
{
return _context.LoginAsync();
}
public async Task<SessionStatus> GetStatusAsync()
{
var typedResponse = await _context.PostAsync<PiwigoResponse<SessionStatus>>(_logger, "pwg.session.getStatus");
return typedResponse.Result;
}
}