<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\Offers\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Maestro\Core\Modules\Offers\Models\OfferServiceCatalogItem;

/** @property OfferServiceCatalogItem $resource */
final class OfferCatalogItemResource extends JsonResource
{
    /**
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'default_description' => $this->default_description,
            'default_pricing_type' => (string) $this->default_pricing_type,
            'default_custom_unit_label' => $this->default_custom_unit_label,
            'default_unit_price' => (float) $this->default_unit_price,
            'default_quantity' => (float) $this->default_quantity,
            'default_vat_rate' => (float) $this->default_vat_rate,
            'is_active' => (bool) $this->is_active,
            'created_at' => optional($this->created_at)?->toIso8601String(),
            'updated_at' => optional($this->updated_at)?->toIso8601String(),
        ];
    }
}
