<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class IntegrationWebhookEvent extends Model
{
    /** @use HasFactory<\Database\Factories\IntegrationWebhookEventFactory> */
    use HasFactory;

    public const STATUS_RECEIVED = 'received';

    public const STATUS_PROCESSED = 'processed';

    public const STATUS_FAILED = 'failed';

    public const STATUS_IGNORED = 'ignored';

    protected $fillable = [
        'provider',
        'event_id',
        'event_type',
        'status',
        'received_at',
        'processed_at',
        'failed_at',
        'error_message',
        'context',
    ];

    protected function casts(): array
    {
        return [
            'received_at' => 'datetime',
            'processed_at' => 'datetime',
            'failed_at' => 'datetime',
            'context' => 'array',
        ];
    }
}
