From 93487389c1eb9ebb93e022f7ba4e4d3c87a9ab14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 22 Oct 2026 11:21:42 +0200 Subject: [PATCH] :coffin: remove unused workflow methods --- docs/code_samples/workflow_execution.txt | 24 ------ src/V1/Client.php | 79 -------------------- tests/V1/Workflow/WorkflowTestFunctional.php | 20 ----- tests/resources | 2 +- 4 files changed, 1 insertion(+), 124 deletions(-) delete mode 100644 docs/code_samples/workflow_execution.txt diff --git a/docs/code_samples/workflow_execution.txt b/docs/code_samples/workflow_execution.txt deleted file mode 100644 index ab95020c..00000000 --- a/docs/code_samples/workflow_execution.txt +++ /dev/null @@ -1,24 +0,0 @@ -executeWorkflow($inputSource, $workflowId); - -// Alternatively, add an alias and priority to the document: -// $options = new WorkflowOptions('document-alias', "document-priority"); -// $workflowResponse = $mindeeClient->executeWorkflow($inputSource, $workflowId, $options); - - -echo $workflowResponse->execution; diff --git a/src/V1/Client.php b/src/V1/Client.php index 6043f552..c15116f7 100644 --- a/src/V1/Client.php +++ b/src/V1/Client.php @@ -227,56 +227,6 @@ private function makeEnqueueRequest( return new AsyncPredictResponse($predictionType, $response['data']); } - /** - * Makes the request to send a document to a workflow. - * - * @param string $predictionType Name of the product's class. - * @param InputSource $inputDoc Input file. - * @param string $workflowId ID of the workflow. - * @param PredictMethodOptions $options Prediction Options. - * @throws MindeeV1HttpException Throws if the API sent an error. - * @throws MindeeApiException Throws if the API sent an error, - * or if the prediction type isn't recognized or if a field can't be deserialized. - */ - private function makeWorkflowExecutionRequest( - string $predictionType, - InputSource $inputDoc, - string $workflowId, - PredictMethodOptions $options - ): WorkflowResponse { - $workflowRouterSettings = new MindeeWorkflowApi($this->apiKey, $workflowId); - $options->endpoint = new WorkflowEndpoint($workflowRouterSettings); - if (!$options->pageOptions->isEmpty()) { - if ($inputDoc instanceof LocalInputSource) { - $this->cutDocPages($inputDoc, $options->pageOptions); - } else { - throw new MindeeApiException( - "Cannot edit non-local input sources.", - ErrorCode::USER_OPERATION_ERROR - ); - } - } - $response = ResponseValidation::cleanRequestData($options->endpoint->executeWorkflowRequestPost( - $inputDoc, - $options->workflowOptions - )); - if (!ResponseValidation::isValidWorkflowResponse($response)) { - throw MindeeV1HttpException::handleError( - "workflows/$workflowId/executions", - $response - ); - } - try { - return new WorkflowResponse($predictionType, $response['data']); - } catch (Exception $e) { - throw new MindeeApiException( - "Unable to create workflow response for $predictionType", - ErrorCode::API_UNPROCESSABLE_ENTITY, - previous: $e - ); - } - } - /** * Makes the request to send a document to a synchronous endpoint. * @@ -462,33 +412,4 @@ public function loadPrediction( ); } } - - /** - * Sends a document to a workflow. - * - * @param InputSource $inputDoc Input File. - * @param string $workflowId ID of the workflow. - * @param WorkflowOptions|null $options Prediction Options. - * @param PageOptions|null $pageOptions Options to apply to the PDF file. - */ - public function executeWorkflow( - InputSource $inputDoc, - string $workflowId, - ?WorkflowOptions $options = null, - ?PageOptions $pageOptions = null - ): WorkflowResponse { - $options ??= new WorkflowOptions(); - if ($pageOptions !== null && $inputDoc instanceof LocalInputSource && $inputDoc->isPdf()) { - $this->cutDocPages($inputDoc, $pageOptions); - } - - $predictMethodOptions = new PredictMethodOptions(); - $predictMethodOptions->setWorkflowOptions($options); - return $this->makeWorkflowExecutionRequest( - GeneratedV1::class, - $inputDoc, - $workflowId, - $predictMethodOptions - ); - } } diff --git a/tests/V1/Workflow/WorkflowTestFunctional.php b/tests/V1/Workflow/WorkflowTestFunctional.php index 089b360f..1ab59dc6 100644 --- a/tests/V1/Workflow/WorkflowTestFunctional.php +++ b/tests/V1/Workflow/WorkflowTestFunctional.php @@ -31,26 +31,6 @@ protected function setUp(): void ); } - public function testWorkflow(): void - { - $currentDateTime = date('Y-m-d-H:i:s'); - $options = new WorkflowOptions( - "php-" . $currentDateTime, - "low", - false, - null, - true - ); - $response = $this->mindeeClient->executeWorkflow( - $this->inputSource, - $this->workflowId, - $options - ); - self::assertSame(202, $response->apiRequest->statusCode); - self::assertSame("php-$currentDateTime", $response->execution->file->alias); - self::assertSame("low", $response->execution->priority); - } - public function testWorkflowPollingWithRAG(): void { $options = new PredictMethodOptions(); diff --git a/tests/resources b/tests/resources index 5037ffc3..bf5893c5 160000 --- a/tests/resources +++ b/tests/resources @@ -1 +1 @@ -Subproject commit 5037ffc3c443ec0c93ed673acd22d6ae1c65771a +Subproject commit bf5893c5c631f37f01419b4a9c71c8a5ce036939