<?php

namespace App\Http\Controllers\Api\Support;

use App\Http\Controllers\Api\Core\BaseApiController;
use App\Http\Requests\Support\ContactSendRequest;
use App\Http\Resources\Support\ContactMessageResource;
use App\Services\Support\ContactMessageService;
use Illuminate\Http\JsonResponse;
use Symfony\Component\HttpFoundation\Response;

class ContactController extends BaseApiController
{
    public function __construct(private ContactMessageService $messageService)
    {
        parent::__construct();
    }

    public function send(ContactSendRequest $request): JsonResponse
    {
        $result = $this->messageService->send($request->validated());

        return $this->success([
            'contact' => new ContactMessageResource($result),
        ], 'Message sent.', Response::HTTP_CREATED);
    }
}
