<?php

namespace Themes\kbgolf\pro\app\Http\Controllers\Auth;

use App\Services\CallApiService;

class MemberDeviceBlockController
{
    private $callApiService;
    public function __construct(CallApiService $callApiService)
    {
        $this->callApiService = $callApiService;
    }

    public function store()
    {
        $response =  $this->callApiService->callApi([
            'url' => 'member-device-block',
            'data' => [
                'ResetCode' => request('code'),
                'DeviceId' => (int)request('device_id'),
            ],
        ]);

        if (empty(request('code')) || $this->callApiService->verifyApiError($response)) {
            return redirect()->route('member-device-block-failed');
        }

        return redirect()->route('member-device-block-success');
    }
}
