mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
70 lines
2.4 KiB
PHP
70 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\KeyValuePairs\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
|
use App\Classes\Modules\KeyValuePairs\DataTransferObjects\UpdateClaudePromptDTO;
|
|
use App\Classes\Modules\KeyValuePairs\Standards\Rules\CanUpdateClaudePrompt;
|
|
use App\Classes\Modules\Accounts\Services\FetchesKeyValuePair;
|
|
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
|
use App\Http\Resources\ClaudePromptResource;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
class UpdateClaudePromptKVPLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Update Claude Prompt',
|
|
'message' => 'You have successfully updated the Claude prompt'
|
|
];
|
|
}
|
|
|
|
/** @var CanUpdateClaudePrompt */
|
|
private $canUpdateClaudePrompt;
|
|
|
|
/** @var UpdatesKeyValuePair */
|
|
private $updatesKeyValuePair;
|
|
|
|
/** @var FetchesKeyValuePair */
|
|
private $fetchesKeyValuePair;
|
|
|
|
/**
|
|
* UpdateClaudePromptKVPLogic constructor.
|
|
* @param CanUpdateClaudePrompt $canUpdateClaudePrompt
|
|
* @param UpdatesKeyValuePair $updatesKeyValuePair
|
|
* @param FetchesKeyValuePair $fetchesKeyValuePair
|
|
*/
|
|
public function __construct(CanUpdateClaudePrompt $canUpdateClaudePrompt, UpdatesKeyValuePair $updatesKeyValuePair, FetchesKeyValuePair $fetchesKeyValuePair)
|
|
{
|
|
$this->canUpdateClaudePrompt = $canUpdateClaudePrompt;
|
|
$this->updatesKeyValuePair = $updatesKeyValuePair;
|
|
$this->fetchesKeyValuePair = $fetchesKeyValuePair;
|
|
}
|
|
|
|
/**
|
|
* @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
|
|
{
|
|
$dto = new UpdateClaudePromptDTO($request->all());
|
|
$this->canUpdateClaudePrompt->passes($dto);
|
|
|
|
$kvp = $this->fetchesKeyValuePair->execute(['id' => $dto->getId()]);
|
|
$keyValuePairObject = new KeyValuePairObject($kvp->key, $dto->getPrompt());
|
|
$this->updatesKeyValuePair->execute($kvp, $keyValuePairObject);
|
|
|
|
return $this->resourceResponse(new ClaudePromptResource($kvp));
|
|
}
|
|
}
|