Skip to content
Merged
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
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
# Mindee PHP API Library Changelog

## v2.0.0 - 2025-09-11
### Changes
* :sparkles: add support for V2 Mindee API
* :sparkles: add support for PHP 8.4
* :sparkles: add more functions to Polygon class
* :recycle: prohibit nulls in some functions
### ¡Breaking Changes!
* :coffin: **remove support for PHP 7.4 and 8.0**
* :recycle: remove useless class `EnqueueAndParseMethodOptions`, replace with `PollingOptions`
* :coffin: remove some static methods from the `PolygonUtils` class, use directly from `Polygon` class instead
* :recycle: remove `processPDF()` in favor of `applyPageOptions()`
### Fixes
* :bug: fix for polygon points not correctly initialized


## v1.23.0-rc3 - 2025-09-09
### Changes
* :sparkles: allow inference options to be set
* :sparkles: allow v2 inference options to be set
* :sparkles: add more functions to Polygon class
* :recycle: remove unused DynamicField & put location data into BaseField
### ¡Breaking Changes!
* :recycle: :boom: update options and raw text to new format
* :recycle: :boom: update v2 options and raw text to the new format
### Fixes
* :bug: fix for polygon points not being init correctly
* :bug: fix for polygon points not correctly initialized


## v1.23.0-rc2 - 2025-08-01
Expand Down
16 changes: 8 additions & 8 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
use Mindee\Http\WorkflowEndpoint;
use Mindee\Input\Base64Input;
use Mindee\Input\BytesInput;
use Mindee\Input\EnqueueAndParseMethodOptions;
use Mindee\Input\FileInput;
use Mindee\Input\InputSource;
use Mindee\Input\LocalInputSource;
use Mindee\Input\LocalResponse;
use Mindee\Input\PageOptions;
use Mindee\Input\PathInput;
use Mindee\Input\PollingOptions;
use Mindee\Input\PredictMethodOptions;
use Mindee\Input\URLInputSource;
use Mindee\Input\WorkflowOptions;
Expand Down Expand Up @@ -429,26 +429,26 @@ public function parse(
/**
* Enqueues a document and automatically polls the response. Asynchronous calls only.
*
* @param string $predictionType Name of the product's class.
* @param InputSource $inputDoc Input file.
* @param PredictMethodOptions|null $options Prediction Options.
* @param EnqueueAndParseMethodOptions|null $asyncOptions Async Options. Manages timers.
* @param PageOptions|null $pageOptions Options to apply to the PDF file.
* @param string $predictionType Name of the product's class.
* @param InputSource $inputDoc Input file.
* @param PredictMethodOptions|null $options Prediction Options.
* @param PollingOptions|null $asyncOptions Async Options. Manages timers.
* @param PageOptions|null $pageOptions Options to apply to the PDF file.
* @return AsyncPredictResponse
* @throws MindeeApiException Throws if the document couldn't be retrieved in time.
*/
public function enqueueAndParse(
string $predictionType,
InputSource $inputDoc,
?PredictMethodOptions $options = null,
?EnqueueAndParseMethodOptions $asyncOptions = null,
?PollingOptions $asyncOptions = null,
?PageOptions $pageOptions = null
): AsyncPredictResponse {
if ($options == null) {
$options = new PredictMethodOptions();
}
if ($asyncOptions == null) {
$asyncOptions = new EnqueueAndParseMethodOptions();
$asyncOptions = new PollingOptions();
}

$options->endpoint = $options->endpoint ?? $this->constructOTSEndpoint(
Expand Down
12 changes: 6 additions & 6 deletions src/Geometry/BBoxUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ abstract class BBoxUtils
/**
* Generates a BBox from a polygon. Returns null if no polygon is provided.
*
* @param \Mindee\Geometry\Polygon|null $polygon Polygon to get the BBox of.
* @return \Mindee\Geometry\BBox|null
* @param Polygon $polygon Polygon to get the BBox of.
* @return BBox|null
*/
public static function generateBBoxFromPolygon(?Polygon $polygon): ?BBox
public static function generateBBoxFromPolygon(Polygon $polygon): ?BBox
{
if (!$polygon || !$polygon->getCoordinates()) {
if (!$polygon->getCoordinates()) {
return null;
}
return new BBox(
Expand All @@ -30,7 +30,7 @@ public static function generateBBoxFromPolygon(?Polygon $polygon): ?BBox
* Generates a BBox from an array of polygons. Returns null if no polygons are provided.
*
* @param array $polygons Series of polygons to get the BBox of.
* @return \Mindee\Geometry\BBox|null
* @return BBox|null
*/
public static function generateBBoxFromPolygons(array $polygons): ?BBox
{
Expand All @@ -55,7 +55,7 @@ public static function generateBBoxFromPolygons(array $polygons): ?BBox
* Merges an array of bboxes.
*
* @param array $bboxes BBoxes to merge.
* @return \Mindee\Geometry\BBox|null
* @return BBox|null
*/
public static function mergeBBoxes(array $bboxes): ?BBox
{
Expand Down
2 changes: 0 additions & 2 deletions src/Geometry/Polygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Mindee\Geometry;

use Mindee\Error\MindeeGeometryException;

/**
* Polygon represented as a set of coordinates (vertices/points).
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Http/MindeeApiV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function __construct(?string $apiKey)
*
* @return void
*/
private function setFromEnv()
private function setFromEnv(): void
{
$envVars = [
API_V2_BASE_URL_ENV_NAME => [$this, 'setBaseUrl'],
Expand All @@ -129,7 +129,7 @@ private function setFromEnv()
* @param string|null $apiKey Optional API key.
* @return void
*/
protected function setApiKey(?string $apiKey = null)
protected function setApiKey(?string $apiKey = null): void
{
$envVal = !getenv(API_V2_KEY_ENV_NAME) ? '' : getenv(API_V2_KEY_ENV_NAME);
if (!$apiKey) {
Expand Down
1 change: 0 additions & 1 deletion src/Input/CommonOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ abstract class CommonOptions
*/
public bool $fullText;


/**
* Prediction options.
* @param boolean $fullText Whether to include the full OCR text response in compatible APIs.
Expand Down
10 changes: 0 additions & 10 deletions src/Input/EnqueueAndParseMethodOptions.php

This file was deleted.

7 changes: 3 additions & 4 deletions src/Input/PollingOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ public function __construct()
$this->maxRetries = 80;
}


/**
* @param integer $initialDelay Delay between polls.
* @return $this
* @throws MindeeApiException Throws if the initial parsing delay is less than 4 seconds.
*/
public function setInitialDelaySec(int $initialDelay): EnqueueAndParseMethodOptions
public function setInitialDelaySec(int $initialDelay): PollingOptions
{
if ($initialDelay < MINIMUM_INITIAL_DELAY_SECONDS) {
throw new MindeeApiException(
Expand All @@ -59,7 +58,7 @@ public function setInitialDelaySec(int $initialDelay): EnqueueAndParseMethodOpti
* @return $this
* @throws MindeeApiException Throws if the delay is too low.
*/
public function setDelaySec(int $delay): EnqueueAndParseMethodOptions
public function setDelaySec(int $delay): PollingOptions
{
if ($delay < MINIMUM_DELAY_SECONDS) {
throw new MindeeApiException(
Expand All @@ -75,7 +74,7 @@ public function setDelaySec(int $delay): EnqueueAndParseMethodOptions
* @param integer $maxRetries Maximum allowed retries. Will default to 80 if an invalid number is provided.
* @return $this
*/
public function setMaxRetries(int $maxRetries): EnqueueAndParseMethodOptions
public function setMaxRetries(int $maxRetries): PollingOptions
{
if (!$maxRetries || $maxRetries < 0) {
$this->maxRetries = 80;
Expand Down
2 changes: 1 addition & 1 deletion src/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace Mindee;

const VERSION = '1.23.0-rc3';
const VERSION = '2.0.0';
14 changes: 9 additions & 5 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use Mindee\Error\MindeeApiException;
use Mindee\Error\MindeeHttpClientException;
use Mindee\Error\MindeeHttpException;
use Mindee\Input\EnqueueAndParseMethodOptions;
use Mindee\Input\LocalResponse;
use Mindee\Input\PageOptions;
use Mindee\Input\PollingOptions;
use Mindee\Input\PredictMethodOptions;
use Mindee\Product\Custom\CustomV1;
use Mindee\Product\Generated\GeneratedV1;
use Mindee\Product\Invoice\InvoiceV4;
use Mindee\Product\InvoiceSplitter\InvoiceSplitterV1;
use Mindee\Product\MultiReceiptsDetector\MultiReceiptsDetectorV1;
Expand Down Expand Up @@ -91,7 +91,11 @@ public function testInterfaceVersion()
$this->assertEquals("1.1", $dummyEndpoint->settings->version);

$this->expectException(MindeeHTTPClientException::class);
$this->dummyClient->parse(CustomV1::class, $inputDoc, $predictOptions->setEndpoint($dummyEndpoint));
$this->dummyClient->parse(
GeneratedV1::class,
$inputDoc,
$predictOptions->setEndpoint($dummyEndpoint),
);
}

public function testCutOptions()
Expand All @@ -106,14 +110,14 @@ public function testCutOptions()
public function testAsyncWrongInitialDelay()
{
$this->expectException(MindeeApiException::class);
$asyncParseOptions = new EnqueueAndParseMethodOptions();
$asyncParseOptions = new PollingOptions();
$asyncParseOptions->setInitialDelaySec(0);
}

public function testAsyncWrongPollingDelay()
{
$this->expectException(MindeeApiException::class);
$asyncParseOptions = new EnqueueAndParseMethodOptions();
$asyncParseOptions = new PollingOptions();
$asyncParseOptions->setDelaySec(0);
}

Expand Down
Loading