Skip to content

Commit 5912af6

Browse files
🐛 fix curl lib not registering webhooks correctly
1 parent 9b5b056 commit 5912af6

5 files changed

Lines changed: 45 additions & 12 deletions

File tree

.github/workflows/_test-integrations.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ env:
1313
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
1414
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
1515
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
16-
MINDEE_V2_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
16+
MINDEE_V2_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_WEBHOOK_ID }}
17+
MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
1718
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
1819
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
1920
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}

src/V2/ClientOptions/BaseParameters.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,9 @@ public function asHash(): array
6363
$outHash['alias'] = $this->alias;
6464
}
6565

66+
6667
if (isset($this->webhooksIds) && count($this->webhooksIds) > 0) {
67-
if (PHP_VERSION_ID < 80200 && count($this->webhooksIds) > 1) {
68-
// NOTE: see https://bugs.php.net/bug.php?id=51634
69-
error_log("PHP version is too low to support webbook array destructuring.
70-
\nOnly the first webhook ID will be sent to the server.");
71-
$outHash['webhook_ids'] = $this->webhooksIds[0];
72-
} else {
73-
foreach ($this->webhooksIds as $webhookId) {
74-
$outHash['webhook_ids[]'] = $webhookId;
75-
}
76-
}
68+
$outHash['webhook_ids'] = implode(',', $this->webhooksIds);
7769
}
7870
return $outHash;
7971
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace V2\ClientOptions;
4+
5+
use Mindee\V2\ClientOptions\BaseParameters;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class BaseParametersTest extends TestCase
9+
{
10+
public function testAsHashShouldSerializeMultipleWebhookIdsAsIndexedFields(): void
11+
{
12+
$params = new class ('model-id', null, ['first-id', 'second-id'], null) extends BaseParameters {
13+
public static string $slug = 'test';
14+
};
15+
16+
$hash = $params->asHash();
17+
18+
$this->assertArrayHasKey('model_id', $hash);
19+
$this->assertArrayHasKey('webhook_ids', $hash);
20+
$this->assertSame('model-id', $hash['model_id']);
21+
$this->assertSame('first-id,second-id', $hash['webhook_ids']);
22+
}
23+
}

tests/V2/ClientV2TestFunctional.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ public function testUrlInputSourceMustNotRaiseErrors(): void
177177
$this->assertNotNull($result);
178178
}
179179

180-
public function testDataSchemaMustSucceed(): void {
180+
public function testDataSchemaMustSucceed(): void
181+
{
181182

182183
$source = new PathInput(
183184
TestingUtilities::getFileTypesDir() . '/pdf/blank_1.pdf'
@@ -214,4 +215,18 @@ public function testDataSchemaMustSucceed(): void {
214215
$result->fields['test_replace']->value
215216
);
216217
}
218+
219+
public function testMultipleWebhooksMustSucceed(): void
220+
{
221+
$source = new PathInput(
222+
TestingUtilities::getFileTypesDir() . '/pdf/blank_1.pdf'
223+
);
224+
225+
$inferenceParams = new InferenceParameters($this->modelId, webhooksIds: [
226+
getenv('MINDEE_V2_FAILURE_WEBHOOK_ID'),
227+
getenv('MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID')]
228+
);
229+
$response = $this->mindeeClient->enqueue($source, $inferenceParams);
230+
$this->assertEquals(2, count($response->job->webhooks));
231+
}
217232
}

tests/V2/Parsing/JobResponseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function testShouldLoadWhenStatusIsProcessing(): void
3939
$this->assertSame('Processing', $response->job->status);
4040
$this->assertNull($response->job->completedAt);
4141
$this->assertNull($response->job->error);
42+
$this->assertIsArray($response->job->webhooks);
43+
$this->assertCount(0, $response->job->webhooks);
4244
}
4345

4446
/**

0 commit comments

Comments
 (0)