piwigodotnet/PiwigoDotnet/Piwigo.Client/SessionApi.cs

33 lines
909 B
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()
{
return _context.LogoutAsync();
}
public Task LoginAsync()
{
return _context.LoginAsync();
}
public async Task<PiwigoStatus> GetStatusAsync()
{
_logger.LogInformation("Getting status");
var typedResponse = await _context.PostAsync<PiwigoResponse<PiwigoStatus>>(_logger, "pwg.session.getStatus");
return typedResponse.Result;
}
}