using System.Threading.Tasks;
using GB5Shared.DTO.Framework.Login;
using GoodBooks.PAY.PAYDAL.DTO.Webhook;
namespace GoodBooks.PAY.PAYDAL.CustomCode.Webhook
{
///
/// Data-access contract for TPAYWEBHOOKEVENT.
/// Insert is IDENTITY-based (returns new PK).
/// Updates are restricted to status columns only — this is a log table.
///
public interface IPayWebhookEventDAL
{
///
/// Persists an incoming raw webhook event immediately.
/// Returns the IDENTITY-generated PAYWEBHOOKEVENTID.
///
Task InsertWebhookEvent(PayWebhookEventDTO dto, LoginDTO login);
///
/// Updates the SIGNATUREVALID column for an existing event.
/// Returns rows affected (should be 1).
///
Task UpdateSignatureValid(int webhookEventId, byte signatureValid, LoginDTO login);
///
/// Marks the event as processed (or failed) and records the processing error if any.
/// Returns rows affected (should be 1).
///
Task UpdateProcessed(int webhookEventId, byte isProcessed, string? error, LoginDTO login);
///
/// Returns true if an event with the given idempotency key has already been
/// successfully processed (ISPROCESSED=1) for the specified gateway.
///
Task CheckIdempotency(string idempotencyKey, int payGatewayId, LoginDTO login);
///
/// Returns a paged JSON list of webhook events for admin review.
/// Supports optional filtering by ISPROCESSED and PAYGATEWAYID.
///
Task GetWebhookEventList(int pageOffset, int pageSize, LoginDTO login);
}
}