From 2b3ebfe357a9854db0b7b02accab3dec835dbd34 Mon Sep 17 00:00:00 2001 From: Jepp9350 <2jepp9350@gmail.com> Date: Tue, 24 Jun 2025 10:40:52 +0200 Subject: [PATCH] Add `xlvask_parser_h_nger` to XLVask helpers imports for extended parsing functionalities --- .../limble/classes/limble_endpoints.php | 32 +++++++++---- .../limble/helpers/limble_object_helper.php | 8 ++++ .../helpers/limble_pagination_helper.php | 24 ++++++++++ .../limble/helpers/limble_task_comment.php | 42 +++++++++++++++++ .../helpers/limble_task_instruction.php | 47 +++++++++++++++++++ .../helpers/limble_tasks_pagination.php | 14 ++++++ .../helpers/limble_webhook_payload_task.php | 20 ++++---- .../limble/interfaces/limble_endpoints_i.php | 14 +++++- .../app/modules/limble/limble_helpers.php | 5 +- .../nginx/app/routes/moduleLimbleRoute.php | 13 ++--- 10 files changed, 190 insertions(+), 29 deletions(-) create mode 100644 services/nginx/app/modules/limble/helpers/limble_object_helper.php create mode 100644 services/nginx/app/modules/limble/helpers/limble_pagination_helper.php create mode 100644 services/nginx/app/modules/limble/helpers/limble_task_comment.php create mode 100644 services/nginx/app/modules/limble/helpers/limble_task_instruction.php create mode 100644 services/nginx/app/modules/limble/helpers/limble_tasks_pagination.php diff --git a/services/nginx/app/modules/limble/classes/limble_endpoints.php b/services/nginx/app/modules/limble/classes/limble_endpoints.php index 6db12c46..d8efbeaa 100644 --- a/services/nginx/app/modules/limble/classes/limble_endpoints.php +++ b/services/nginx/app/modules/limble/classes/limble_endpoints.php @@ -5,6 +5,7 @@ require_once WD . '/modules/limble/interfaces/limble_endpoints_i.php'; require_once WD . '/modules/limble/classes/limble_request.php'; use Exception; +use limble\helpers\limble_tasks_pagination; use limble_endpoints_i; abstract class limble_endpoints extends limble_request implements limble_endpoints_i @@ -14,14 +15,11 @@ abstract class limble_endpoints extends limble_request implements limble_endpoin * @inheritDoc * @throws Exception If the module is not enabled */ - public function listTasks(): array + public function listTasks(limble_tasks_pagination $pagination): array { $this->requireModuleEnabled(); $url = $this->config->api_url . '/tasks'; - $params = [ -// 'status' => 'open', -// 'limit' => 100, - ]; + $params = [...$pagination->getParams()]; return $this->sendRequest( $url, 'GET', @@ -51,6 +49,22 @@ abstract class limble_endpoints extends limble_request implements limble_endpoin ); } + /** + * @inheritDoc + * @throws Exception If the module is not enabled + */ + public function getTaskInstructions(int $taskId): array + { + $this->requireModuleEnabled(); + $url = $this->config->api_url . '/tasks/' . $taskId . '/instructions'; + return $this->sendRequest( + $url, + 'GET', + [], + [self::getAuthHeader(), 'Content-Type: application/json'] + ); + } + /** * @inheritDoc * @throws Exception If the module is not enabled @@ -59,12 +73,14 @@ abstract class limble_endpoints extends limble_request implements limble_endpoin { $this->requireModuleEnabled(); $url = $this->config->api_url . '/tasks'; + // Set the taskId as a pagination parameter + $pagination = new limble_tasks_pagination(); + $pagination->tasks = $taskId; + $pagination->limit = 1; // Limit to 1 task return $this->sendRequest( $url, 'GET', - [ - 'cursor' => $taskId, - ], + [...$pagination->getParams()], [self::getAuthHeader(), 'Content-Type: application/json'] ); } diff --git a/services/nginx/app/modules/limble/helpers/limble_object_helper.php b/services/nginx/app/modules/limble/helpers/limble_object_helper.php new file mode 100644 index 00000000..73563bdc --- /dev/null +++ b/services/nginx/app/modules/limble/helpers/limble_object_helper.php @@ -0,0 +1,8 @@ +slack->send_message('Initializing Limble Webhook Payload Task', 'Limble Webhook Task Initialization'); $this->taskID = (int)($payload['taskID'] ?? 0); $this->status = (string)($payload['status'] ?? ''); $this->category = (string)($payload['category'] ?? ''); $this->user = (string)($payload['user'] ?? ''); - $this->taskObject = new limble_task(((new limble())->getTask($payload['taskID'])) ?: []); - $this->slack->send_message('Task has been initialized with ID: ' . $this->taskID, 'Limble Webhook Task Initialized'); + $this->taskObject = new limble_task(((new limble())->getTask($payload['taskID']))[0] ?? []); $this->notifyWebhook(); } protected function notifyWebhook(): void { + // Generate the message to notify the webhook + $message = ""; + $message .= "Task ID: " . $this->taskID . "\n"; + $message .= "Name: " . $this->taskObject->name . "\n"; + $message .= "Description: " . $this->taskObject->description . "\n"; + $message .= "User: " . $this->user . "\n"; + $message .= "Status: " . $this->status . "\n"; + $message .= "Category: " . $this->category . "\n"; // Notify the webhook with the task object - $this->slack->send_message(' - Task ID: ' . $this->taskID . ' - Status: ' . $this->status . ' - Category: ' . $this->category . ' - User: ' . $this->user, - 'Limble Webhook Notification' - ); + $this->slack->send_message($message, 'Limble Webhook Task Notification'); } /** diff --git a/services/nginx/app/modules/limble/interfaces/limble_endpoints_i.php b/services/nginx/app/modules/limble/interfaces/limble_endpoints_i.php index 49cb8873..47676144 100644 --- a/services/nginx/app/modules/limble/interfaces/limble_endpoints_i.php +++ b/services/nginx/app/modules/limble/interfaces/limble_endpoints_i.php @@ -1,14 +1,18 @@ post('/modules/limble/webhook/task', function () { global $response; $slack = new slack(); - $slack->send_message('Limble Webhook Task Triggered', 'Limble Webhook'); //TODO: Add authentication of some sort here //self::requirePermission('modules_limble_webhooks_task'); // Check if the module is enabled @@ -32,14 +32,7 @@ class moduleLimbleRoute if (json_last_error() !== JSON_ERROR_NONE) { $response->error('Invalid JSON payload', 400); } - $slack->send_message('TaskId: ' . ($payload['taskID'] ?? 'Not provided'), 'Limble Webhook Task ID'); - $slack->send_message('Payload: ' . json_encode($payload), 'Limble Webhook Task Payload'); $task = new limble_webhook_payload_task($payload); - //$task = new $limble->helpers->limble_webhook_payload_task($payload); - $slack->send_message('Limble Webhook Task Received: ' . $task->taskID, 'Limble Webhook Task'); - $slack->send_message('Task Name: ' . $task->taskObject->name, 'Limble Webhook Task Name'); -// $slack->send_message('Task ID: ' . $payload['task_id'], 'Limble Webhook Task ID'); - // Response $response->success('Debug', 200); }, @@ -56,8 +49,10 @@ class moduleLimbleRoute // Check if the module is enabled $limble = new limble(); $limble->requireModuleEnabled(); + $pagination = new limble_tasks_pagination(); + //$pagination->tasks = 2; // Get the tasks - $tasks = $limble->getTasks()->formatTasks($limble->listTasks()); + $tasks = $limble->getTasks()->formatTasks($limble->listTasks($pagination)); // Response $response->success($tasks, 200); },