<?php

namespace App\Classes\Modules\KeyValuePairs\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\KeyValuePairs\Services\DeletesKeyValuePair;
use App\Classes\Modules\KeyValuePairs\Services\FetchesKeyValuePair;
use App\Classes\Modules\KeyValuePairs\Standards\Rules\CanDeleteClaudePrompt;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class DeleteClaudePromptKVPLogic extends AbstractControllerLogic
{

    /**
     * @return array
     */
    protected function notification(): array
    {
        return [
            'title' => 'Delete Claude Prompt',
            'message' => 'You have successfully deleted the Claude Prompt'
        ];
    }

    /** @var CanDeleteClaudePrompt */
    private $canDeleteClaudePrompt;

    /** @var FetchesKeyValuePair */
    private $fetchesKeyValuePair;

    /** @var DeletesKeyValuePair */
    private $deletesKeyValuePair;

    /**
     * DeleteClaudePromptKVPLogic constructor.
     * @param CanDeleteClaudePrompt $canDeleteClaudePrompt
     * @param FetchesKeyValuePair $fetchesKeyValuePair
     * @param DeletesKeyValuePair $deletesKeyValuePair
     */
    public function __construct(
        CanDeleteClaudePrompt $canDeleteClaudePrompt,
        FetchesKeyValuePair $fetchesKeyValuePair,
        DeletesKeyValuePair $deletesKeyValuePair
    ) {
        $this->canDeleteClaudePrompt = $canDeleteClaudePrompt;
        $this->fetchesKeyValuePair = $fetchesKeyValuePair;
        $this->deletesKeyValuePair = $deletesKeyValuePair;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\AccessForbiddenException
     * @throws \App\Classes\Exceptions\MalformedRequestException
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    public function logic(Request $request): JsonResponse
    {
        $this->canDeleteClaudePrompt->passes();

        $kvp = $this->fetchesKeyValuePair->execute(['id' => $request->route('id')]);

        $this->deletesKeyValuePair->execute($kvp);

        return $this->response([]);
    }
}
