<?php

declare(strict_types=1);

namespace App\Http\Resources\Api\V1;

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

class FtpUserResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'account_id' => $this->account_id,
            'user' => $this->user,
            'logical_name' => $this->logical_name,
            'dir' => $this->dir,
            'quota_size' => $this->quota_size,
            'quota_files' => $this->quota_files,
            'ip_access' => $this->ip_access,
            'is_main_account' => $this->is_main_account,
            'status' => $this->status?->value,
            'last_error' => $this->last_error,
            'last_provisioned_at' => $this->last_provisioned_at?->toIso8601String(),
            'created_at' => $this->created_at?->toIso8601String(),
            'links' => [
                'self' => route('api.v1.ftp-users.show', $this->id),
            ],
        ];
    }
}
