Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
MINDEE_V2_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
MINDEE_V2_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_WEBHOOK_ID }}
MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/_test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ env:
MINDEE_ACCOUNT_SE_TESTS: ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }}
MINDEE_ENDPOINT_SE_TESTS: ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
MINDEE_V2_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}

jobs:
test:
Expand All @@ -41,8 +40,8 @@ jobs:

- name: Tests V2 code samples
run: |
./tests/test_code_samples_v2.sh
./tests/test_v2_code_samples.sh

- name: Tests V1 code samples
run: |
./tests/test_code_samples_v1.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
./tests/test_v1_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
3 changes: 1 addition & 2 deletions src/Parsing/V2/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ public function __construct(array $serverResponse)
$this->filename = $serverResponse['filename'];
$this->resultUrl = $serverResponse['result_url'] ?? null;
$this->alias = $serverResponse['alias'];
$this->webhooks = [];
if (array_key_exists("webhooks", $serverResponse)) {
foreach ($serverResponse['webhooks'] as $webhook) {
$this->webhooks[] = new JobWebhook($webhook);
}
} else {
$this->webhooks = [];
}
}

Expand Down
12 changes: 2 additions & 10 deletions src/V2/ClientOptions/BaseParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,9 @@ public function asHash(): array
$outHash['alias'] = $this->alias;
}


if (isset($this->webhooksIds) && count($this->webhooksIds) > 0) {
if (PHP_VERSION_ID < 80200 && count($this->webhooksIds) > 1) {
// NOTE: see https://bugs.php.net/bug.php?id=51634
error_log("PHP version is too low to support webbook array destructuring.
\nOnly the first webhook ID will be sent to the server.");
$outHash['webhook_ids'] = $this->webhooksIds[0];
} else {
foreach ($this->webhooksIds as $webhookId) {
$outHash['webhook_ids[]'] = $webhookId;
}
}
$outHash['webhook_ids'] = implode(',', $this->webhooksIds);
}
return $outHash;
}
Expand Down
23 changes: 23 additions & 0 deletions tests/V2/ClientOptions/BaseParametersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace V2\ClientOptions;

use Mindee\V2\ClientOptions\BaseParameters;
use PHPUnit\Framework\TestCase;

class BaseParametersTest extends TestCase
{
public function testAsHashShouldSerializeMultipleWebhookIdsAsIndexedFields(): void
{
$params = new class ('model-id', null, ['first-id', 'second-id'], null) extends BaseParameters {
public static string $slug = 'test';
};

$hash = $params->asHash();

$this->assertArrayHasKey('model_id', $hash);
$this->assertArrayHasKey('webhook_ids', $hash);
$this->assertSame('model-id', $hash['model_id']);
$this->assertSame('first-id,second-id', $hash['webhook_ids']);
}
}
17 changes: 16 additions & 1 deletion tests/V2/ClientV2TestFunctional.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ public function testUrlInputSourceMustNotRaiseErrors(): void
$this->assertNotNull($result);
}

public function testDataSchemaMustSucceed(): void {
public function testDataSchemaMustSucceed(): void
{

$source = new PathInput(
TestingUtilities::getFileTypesDir() . '/pdf/blank_1.pdf'
Expand Down Expand Up @@ -214,4 +215,18 @@ public function testDataSchemaMustSucceed(): void {
$result->fields['test_replace']->value
);
}

public function testMultipleWebhooksMustSucceed(): void
{
$source = new PathInput(
TestingUtilities::getFileTypesDir() . '/pdf/blank_1.pdf'
);

$inferenceParams = new InferenceParameters($this->modelId, webhooksIds: [
getenv('MINDEE_V2_FAILURE_WEBHOOK_ID'),
getenv('MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID')]
);
$response = $this->mindeeClient->enqueue($source, $inferenceParams);
$this->assertEquals(2, count($response->job->webhooks));
}
}
2 changes: 2 additions & 0 deletions tests/V2/Parsing/JobResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function testShouldLoadWhenStatusIsProcessing(): void
$this->assertSame('Processing', $response->job->status);
$this->assertNull($response->job->completedAt);
$this->assertNull($response->job->error);
$this->assertIsArray($response->job->webhooks);
$this->assertCount(0, $response->job->webhooks);
}

/**
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions tests/test_code_samples_v2.sh → tests/test_v2_code_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ do

if echo "${f}" | grep -q "v2_classification"
then
sed -i "s/MY_MODEL_ID/${MINDEE_V2_CLASSIFICATION_MODEL_ID}/" $OUTPUT_FILE
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID}/" $OUTPUT_FILE
fi

if echo "${f}" | grep -q "v2_crop"
then
sed -i "s/MY_MODEL_ID/${MINDEE_V2_CROP_MODEL_ID}/" $OUTPUT_FILE
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CROP_MODEL_ID}/" $OUTPUT_FILE
fi

if echo "${f}" | grep -q "v2_extraction"
then
sed -i "s/MY_MODEL_ID/${MINDEE_V2_FINDOC_MODEL_ID}/" $OUTPUT_FILE
sed -i "s/MY_WEBHOOK_ID/${MINDEE_V2_FAILURE_WEBHOOK_ID}/" $OUTPUT_FILE
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID}/" $OUTPUT_FILE
sed -i "s/MY_WEBHOOK_ID/${MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID}/" $OUTPUT_FILE
fi

if echo "${f}" | grep -q "v2_ocr"
then
sed -i "s/MY_MODEL_ID/${MINDEE_V2_OCR_MODEL_ID}/" $OUTPUT_FILE
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_OCR_MODEL_ID}/" $OUTPUT_FILE
fi

if echo "${f}" | grep -q "v2_split"
then
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SPLIT_MODEL_ID}/" $OUTPUT_FILE
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID}/" $OUTPUT_FILE
fi

echo
Expand Down
Loading