<?php

namespace App\Http\Resources\Api\V1;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class UploadSessionResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->uuid,
            'filename' => $this->original_name,
            'total_size' => $this->total_size,
            'chunk_size' => $this->chunk_size,
            'total_chunks' => $this->total_chunks,
            'uploaded_chunks' => count($this->uploaded_chunks ?? []),
            'progress_percentage' => $this->getProgressPercentage(),
            'status' => $this->status,
            'mime_type' => $this->mime_type,
            'expires_at' => $this->expires_at->toIso8601String(),
            'created_at' => $this->created_at->toIso8601String(),
        ];
    }
}
