<?php

namespace App\Classes\Modules\Accounts\ControllersLogic;

use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounts\Processors\RefreshAuthenticationTokenProcessor;
use App\Models\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class RefreshAuthenticationTokenLogic extends AbstractControllerLogic
{

    protected function notification():array {
        return [
            'title' => 'Refresh Authentication',
            'message' => 'You have successfully your account authentication'
        ];
    }

    /** @var RefreshAuthenticationTokenProcessor */
    private $refreshAuthenticationTokenProcessor;

    /**
     * RefreshAuthenticationTokenLogic constructor.
     * @param RefreshAuthenticationTokenProcessor $refreshAuthenticationTokenProcessor
     */
    public function __construct(RefreshAuthenticationTokenProcessor $refreshAuthenticationTokenProcessor)
    {
        $this->refreshAuthenticationTokenProcessor = $refreshAuthenticationTokenProcessor;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\InternalServerErrorException
     */
    protected function logic(Request $request): JsonResponse {

        /** @var User $user */
        $user = Auth()->user();

        return $this->response($this->refreshAuthenticationTokenProcessor->execute($user));

    }

}