<?php

namespace App\Http\Controllers\Api\Master;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Master\CustomerRequest;
use App\Services\Master\CustomerService;
use Illuminate\Http\JsonResponse;

class CustomerApiController extends Controller
{
    public function __construct(
        private readonly CustomerService $customerService,
    ) {}

    public function store(CustomerRequest $request): JsonResponse
    {
        $customer = $this->customerService->createAndReturn($request->validated());

        return response()->json([
            'id' => $customer->id,
            'name' => $customer->name,
        ]);
    }
}
