Skip to content

Commit 34424f2

Browse files
committed
♻️ remove useless class EnqueueAndParseMethodOptions
1 parent 7660a5e commit 34424f2

6 files changed

Lines changed: 22 additions & 30 deletions

File tree

src/Client.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
use Mindee\Http\WorkflowEndpoint;
2222
use Mindee\Input\Base64Input;
2323
use Mindee\Input\BytesInput;
24-
use Mindee\Input\EnqueueAndParseMethodOptions;
2524
use Mindee\Input\FileInput;
2625
use Mindee\Input\InputSource;
2726
use Mindee\Input\LocalInputSource;
2827
use Mindee\Input\LocalResponse;
2928
use Mindee\Input\PageOptions;
3029
use Mindee\Input\PathInput;
30+
use Mindee\Input\PollingOptions;
3131
use Mindee\Input\PredictMethodOptions;
3232
use Mindee\Input\URLInputSource;
3333
use Mindee\Input\WorkflowOptions;
@@ -429,26 +429,26 @@ public function parse(
429429
/**
430430
* Enqueues a document and automatically polls the response. Asynchronous calls only.
431431
*
432-
* @param string $predictionType Name of the product's class.
433-
* @param InputSource $inputDoc Input file.
434-
* @param PredictMethodOptions|null $options Prediction Options.
435-
* @param EnqueueAndParseMethodOptions|null $asyncOptions Async Options. Manages timers.
436-
* @param PageOptions|null $pageOptions Options to apply to the PDF file.
432+
* @param string $predictionType Name of the product's class.
433+
* @param InputSource $inputDoc Input file.
434+
* @param PredictMethodOptions|null $options Prediction Options.
435+
* @param PollingOptions|null $asyncOptions Async Options. Manages timers.
436+
* @param PageOptions|null $pageOptions Options to apply to the PDF file.
437437
* @return AsyncPredictResponse
438438
* @throws MindeeApiException Throws if the document couldn't be retrieved in time.
439439
*/
440440
public function enqueueAndParse(
441441
string $predictionType,
442442
InputSource $inputDoc,
443443
?PredictMethodOptions $options = null,
444-
?EnqueueAndParseMethodOptions $asyncOptions = null,
444+
?PollingOptions $asyncOptions = null,
445445
?PageOptions $pageOptions = null
446446
): AsyncPredictResponse {
447447
if ($options == null) {
448448
$options = new PredictMethodOptions();
449449
}
450450
if ($asyncOptions == null) {
451-
$asyncOptions = new EnqueueAndParseMethodOptions();
451+
$asyncOptions = new PollingOptions();
452452
}
453453

454454
$options->endpoint = $options->endpoint ?? $this->constructOTSEndpoint(

src/Http/MindeeApiV2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function __construct(?string $apiKey)
107107
*
108108
* @return void
109109
*/
110-
private function setFromEnv()
110+
private function setFromEnv(): void
111111
{
112112
$envVars = [
113113
API_V2_BASE_URL_ENV_NAME => [$this, 'setBaseUrl'],
@@ -129,7 +129,7 @@ private function setFromEnv()
129129
* @param string|null $apiKey Optional API key.
130130
* @return void
131131
*/
132-
protected function setApiKey(?string $apiKey = null)
132+
protected function setApiKey(?string $apiKey = null): void
133133
{
134134
$envVal = !getenv(API_V2_KEY_ENV_NAME) ? '' : getenv(API_V2_KEY_ENV_NAME);
135135
if (!$apiKey) {

src/Input/CommonOptions.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ abstract class CommonOptions
1313
*/
1414
public bool $fullText;
1515

16-
1716
/**
1817
* Prediction options.
1918
* @param boolean $fullText Whether to include the full OCR text response in compatible APIs.

src/Input/EnqueueAndParseMethodOptions.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Input/PollingOptions.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ public function __construct()
3636
$this->maxRetries = 80;
3737
}
3838

39-
4039
/**
4140
* @param integer $initialDelay Delay between polls.
4241
* @return $this
4342
* @throws MindeeApiException Throws if the initial parsing delay is less than 4 seconds.
4443
*/
45-
public function setInitialDelaySec(int $initialDelay): EnqueueAndParseMethodOptions
44+
public function setInitialDelaySec(int $initialDelay): PollingOptions
4645
{
4746
if ($initialDelay < MINIMUM_INITIAL_DELAY_SECONDS) {
4847
throw new MindeeApiException(
@@ -59,7 +58,7 @@ public function setInitialDelaySec(int $initialDelay): EnqueueAndParseMethodOpti
5958
* @return $this
6059
* @throws MindeeApiException Throws if the delay is too low.
6160
*/
62-
public function setDelaySec(int $delay): EnqueueAndParseMethodOptions
61+
public function setDelaySec(int $delay): PollingOptions
6362
{
6463
if ($delay < MINIMUM_DELAY_SECONDS) {
6564
throw new MindeeApiException(
@@ -75,7 +74,7 @@ public function setDelaySec(int $delay): EnqueueAndParseMethodOptions
7574
* @param integer $maxRetries Maximum allowed retries. Will default to 80 if an invalid number is provided.
7675
* @return $this
7776
*/
78-
public function setMaxRetries(int $maxRetries): EnqueueAndParseMethodOptions
77+
public function setMaxRetries(int $maxRetries): PollingOptions
7978
{
8079
if (!$maxRetries || $maxRetries < 0) {
8180
$this->maxRetries = 80;

tests/ClientTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
use Mindee\Error\MindeeApiException;
55
use Mindee\Error\MindeeHttpClientException;
66
use Mindee\Error\MindeeHttpException;
7-
use Mindee\Input\EnqueueAndParseMethodOptions;
87
use Mindee\Input\LocalResponse;
98
use Mindee\Input\PageOptions;
9+
use Mindee\Input\PollingOptions;
1010
use Mindee\Input\PredictMethodOptions;
11-
use Mindee\Product\Custom\CustomV1;
11+
use Mindee\Product\Generated\GeneratedV1;
1212
use Mindee\Product\Invoice\InvoiceV4;
1313
use Mindee\Product\InvoiceSplitter\InvoiceSplitterV1;
1414
use Mindee\Product\MultiReceiptsDetector\MultiReceiptsDetectorV1;
@@ -91,7 +91,11 @@ public function testInterfaceVersion()
9191
$this->assertEquals("1.1", $dummyEndpoint->settings->version);
9292

9393
$this->expectException(MindeeHTTPClientException::class);
94-
$this->dummyClient->parse(CustomV1::class, $inputDoc, $predictOptions->setEndpoint($dummyEndpoint));
94+
$this->dummyClient->parse(
95+
GeneratedV1::class,
96+
$inputDoc,
97+
$predictOptions->setEndpoint($dummyEndpoint),
98+
);
9599
}
96100

97101
public function testCutOptions()
@@ -106,14 +110,14 @@ public function testCutOptions()
106110
public function testAsyncWrongInitialDelay()
107111
{
108112
$this->expectException(MindeeApiException::class);
109-
$asyncParseOptions = new EnqueueAndParseMethodOptions();
113+
$asyncParseOptions = new PollingOptions();
110114
$asyncParseOptions->setInitialDelaySec(0);
111115
}
112116

113117
public function testAsyncWrongPollingDelay()
114118
{
115119
$this->expectException(MindeeApiException::class);
116-
$asyncParseOptions = new EnqueueAndParseMethodOptions();
120+
$asyncParseOptions = new PollingOptions();
117121
$asyncParseOptions->setDelaySec(0);
118122
}
119123

0 commit comments

Comments
 (0)