<?php

declare(strict_types=1);

namespace apexl\Io\modules\payment\Entity;

use apexl\entityCore\traits\HasCasts;
use apexl\Io\includes\Entity;

/**
 * PaymentWebhookLog — append-only record of every webhook the gateway sends.
 *
 * Used for:
 *   - idempotency (gateway_event_id unique index)
 *   - replay / forensic debugging
 *   - rebuilding state from raw payloads if needed
 *
 * @property int         $id
 * @property string      $gateway
 * @property string      $gateway_event_id   gateway's stable id (used as idempotency key)
 * @property string      $event_type         normalised + raw gateway type
 * @property string|null $gateway_event_type raw gateway type
 * @property int         $occurred_at
 * @property string      $status             received / verified / processed / failed
 * @property string|null $signature
 * @property string|null $failure_reason
 * @property string      $raw_payload        full JSON body as sent
 * @property int         $created
 */
class PaymentWebhookLog extends Entity
{
    use HasCasts;

    public final const string TABLE = 'payment_webhook_log';

    public function __construct()
    {
        parent::__construct(static::TABLE);
    }

    public function casts(): array
    {
        return [...parent::casts()];
    }
}
