<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\Account\UpdateAgreementsRequest;
use App\Http\Requests\Account\WithdrawRequest;
use App\Services\AccountService;
use Illuminate\Http\JsonResponse;

class AccountController extends Controller
{
    public function __construct(
        private readonly AccountService $service
    ) {}

    /**
     * 회원 탈퇴 (SAM 완전 탈퇴)
     */
    public function withdraw(WithdrawRequest $request): JsonResponse
    {
        return ApiResponse::handle(
            fn () => $this->service->withdraw($request->validated()),
            __('message.account.withdrawn')
        );
    }

    /**
     * 사용 중지 (특정 테넌트에서만 탈퇴)
     */
    public function suspend(): JsonResponse
    {
        return ApiResponse::handle(
            fn () => $this->service->suspend(),
            __('message.account.suspended')
        );
    }

    /**
     * 약관 동의 정보 조회
     */
    public function getAgreements(): JsonResponse
    {
        return ApiResponse::handle(
            fn () => $this->service->getAgreements(),
            __('message.fetched')
        );
    }

    /**
     * 약관 동의 정보 수정
     */
    public function updateAgreements(UpdateAgreementsRequest $request): JsonResponse
    {
        return ApiResponse::handle(
            fn () => $this->service->updateAgreements($request->validated()),
            __('message.updated')
        );
    }
}
