<?php

namespace App\Mail\Admin;

use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;

class WebhookFailedAdmin extends BaseAdminNotification
{
    public function __construct(
        public string $providerKey,
        public ?string $eventId,
        public ?string $eventType,
        public string $errorMessage,
        public ?string $errorClass = null,
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(subject: $this->adminSubject("Webhook dispatch failed ({$this->providerKey})"));
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'mail.admin.webhook-failed',
            with: array_merge($this->commonData(), [
                'providerKey' => $this->providerKey,
                'eventId' => $this->eventId,
                'eventType' => $this->eventType,
                'errorMessage' => $this->errorMessage,
                'errorClass' => $this->errorClass,
            ]),
        );
    }
}
