<?php

namespace App\Http\Resources\Api\V1;

use App\Domain\Webhook\Models\WebhookEndpoint;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/** @mixin WebhookEndpoint */
class WebhookEndpointResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'url' => $this->url,
            'events' => $this->events,
            'headers' => $this->headers,
            'retry_config' => $this->retry_config,
            'is_active' => $this->is_active,
            'failure_count' => $this->failure_count,
            'last_triggered_at' => $this->last_triggered_at?->toISOString(),
            'created_at' => $this->created_at->toISOString(),
            'updated_at' => $this->updated_at->toISOString(),
        ];
    }
}
