Documentation

Client
in package

Main entrypoint for Mindee operations.

Table of Contents

Constants

DEFAULT_OWNER  = 'mindee'
Default owner for API products.

Properties

$apiKey  : string

Methods

__construct()  : mixed
Mindee Client.
createEndpoint()  : Endpoint
Adds a custom endpoint, created using the Mindee API Builder.
enqueue()  : AsyncPredictResponse
Enqueue a document to an asynchronous endpoint.
enqueueAndParse()  : AsyncPredictResponse
Enqueues a document and automatically polls the response. Asynchronous calls only.
loadPrediction()  : AsyncPredictResponse|PredictResponse
parse()  : PredictResponse
Call prediction API on the document and parse the results.
parseQueued()  : AsyncPredictResponse
Parses a queued document.
sourceFromB64String()  : Base64Input
Load a document from a base64 encoded string.
sourceFromBytes()  : BytesInput
Load a document from raw bytes.
sourceFromFile()  : FileInput
Load a document from a normal PHP file object.
sourceFromPath()  : PathInput
Load a document from an absolute path, as a string.
sourceFromUrl()  : URLInputSource
Load a document from an URL.
cleanAccountName()  : string
Cleans the account name.
constructEndpoint()  : Endpoint
Builds a custom endpoint.
constructOTSEndpoint()  : Endpoint
Builds an off-the-shelf endpoint.
cutDocPages()  : void
Cut the pages of a PDF following the detailed operations.
makeEnqueueRequest()  : AsyncPredictResponse
Makes the request to send a document to an asynchronous endpoint.
makeParseQueuedRequest()  : AsyncPredictResponse
Makes the request to retrieve an async document.
makeParseRequest()  : PredictResponse
Makes the request to send a document to a synchronous endpoint.

Constants

DEFAULT_OWNER

Default owner for API products.

public mixed DEFAULT_OWNER = 'mindee'

Do not change unless you know what you are doing.

Properties

$apiKey

private string $apiKey

API key for a given client.

Methods

__construct()

Mindee Client.

public __construct([string|null $apiKey = null ]) : mixed
Parameters
$apiKey : string|null = null

Optional API key. Will fall back to environment variable if not provided.

createEndpoint()

Adds a custom endpoint, created using the Mindee API Builder.

public createEndpoint(string $endpointName, string $accountName[, string|null $version = null ]) : Endpoint
Parameters
$endpointName : string

URL of the endpoint.

$accountName : string

Name of the endpoint's owner.

$version : string|null = null

Version of the endpoint.

Tags
throws
MindeeClientException

Throws if a custom endpoint name isn't provided.

Return values
Endpoint

enqueue()

Enqueue a document to an asynchronous endpoint.

public enqueue(string $predictionType, InputSource $inputDoc[, PredictMethodOptions|null $options = null ][, PageOptions|null $pageOptions = null ]) : AsyncPredictResponse
Parameters
$predictionType : string

Name of the product's class.

$inputDoc : InputSource

Input File.

$options : PredictMethodOptions|null = null

Prediction Options.

$pageOptions : PageOptions|null = null

Options to apply to the PDF file.

Return values
AsyncPredictResponse

enqueueAndParse()

Enqueues a document and automatically polls the response. Asynchronous calls only.

public enqueueAndParse(string $predictionType, InputSource $inputDoc[, PredictMethodOptions|null $options = null ][, EnqueueAndParseMethodOptions|null $asyncOptions = null ][, PageOptions|null $pageOptions = null ]) : AsyncPredictResponse
Parameters
$predictionType : string

Name of the product's class.

$inputDoc : InputSource

Input file.

$options : PredictMethodOptions|null = null

Prediction Options.

$asyncOptions : EnqueueAndParseMethodOptions|null = null

Async Options. Manages timers.

$pageOptions : PageOptions|null = null

Options to apply to the PDF file.

Tags
throws
MindeeApiException

Throws if the document couldn't be retrieved in time.

Return values
AsyncPredictResponse

parse()

Call prediction API on the document and parse the results.

public parse(string $predictionType, InputSource $inputDoc[, PredictMethodOptions|null $options = null ][, PageOptions|null $pageOptions = null ]) : PredictResponse
Parameters
$predictionType : string

Name of the product's class.

$inputDoc : InputSource

Input file.

$options : PredictMethodOptions|null = null

Prediction options.

$pageOptions : PageOptions|null = null

Options to apply to the PDF file.

Return values
PredictResponse

parseQueued()

Parses a queued document.

public parseQueued(string $predictionType, string $queueId[, Endpoint|null $endpoint = null ]) : AsyncPredictResponse
Parameters
$predictionType : string

Name of the product's class.

$queueId : string

ID of the queue.

$endpoint : Endpoint|null = null

Endpoint to poll.

Return values
AsyncPredictResponse

sourceFromB64String()

Load a document from a base64 encoded string.

public sourceFromB64String(string $fileB64, string $fileName[, bool $fixPDF = false ]) : Base64Input
Parameters
$fileB64 : string

File object in Base64.

$fileName : string

File name, mandatory.

$fixPDF : bool = false

Whether the PDF should be fixed or not.

Return values
Base64Input

sourceFromBytes()

Load a document from raw bytes.

public sourceFromBytes(string $fileBytes, string $fileName[, bool $fixPDF = false ]) : BytesInput
Parameters
$fileBytes : string

File object in raw bytes.

$fileName : string

File name, mandatory.

$fixPDF : bool = false

Whether the PDF should be fixed or not.

Return values
BytesInput

sourceFromFile()

Load a document from a normal PHP file object.

public sourceFromFile(mixed $file[, bool $fixPDF = false ]) : FileInput
Parameters
$file : mixed

File object as created from the file() function.

$fixPDF : bool = false

Whether the PDF should be fixed or not.

Return values
FileInput

sourceFromPath()

Load a document from an absolute path, as a string.

public sourceFromPath(string $filePath[, bool $fixPDF = false ]) : PathInput
Parameters
$filePath : string

Path of the file.

$fixPDF : bool = false

Whether the PDF should be fixed or not.

Return values
PathInput

sourceFromUrl()

Load a document from an URL.

public sourceFromUrl(string $url) : URLInputSource
Parameters
$url : string

File URL. Must start with "https://".

Return values
URLInputSource

cleanAccountName()

Cleans the account name.

private cleanAccountName(string $accountName) : string
Parameters
$accountName : string

Name of the endpoint's owner. Replaced by self::DEFAULT_OWNER if absent.

Return values
string

constructEndpoint()

Builds a custom endpoint.

private constructEndpoint(string $endpointName, string $endpointOwner, string $endpointVersion) : Endpoint
Parameters
$endpointName : string

URL of the endpoint.

$endpointOwner : string

Name of the endpoint's owner.

$endpointVersion : string

Version of the endpoint.

Return values
Endpoint

constructOTSEndpoint()

Builds an off-the-shelf endpoint.

private constructOTSEndpoint(string $product) : Endpoint
Parameters
$product : string

Name of the product's class.

Tags
throws
MindeeApiException

Throws if the product isn't recognized.

Return values
Endpoint

makeEnqueueRequest()

Makes the request to send a document to an asynchronous endpoint.

private makeEnqueueRequest(string $predictionType, InputSource $inputDoc, PredictMethodOptions $options) : AsyncPredictResponse
Parameters
$predictionType : string

Name of the product's class.

$inputDoc : InputSource

Input file.

$options : PredictMethodOptions

Prediction Options.

Tags
throws
MindeeHttpException

Throws if the API sent an error.

throws
MindeeApiException

Throws if one attempts to edit remote resources.

Return values
AsyncPredictResponse

makeParseQueuedRequest()

Makes the request to retrieve an async document.

private makeParseQueuedRequest(string $predictionType, string $queueId, Endpoint $endpoint) : AsyncPredictResponse
Parameters
$predictionType : string

Name of the product's class.

$queueId : string

ID of the queue.

$endpoint : Endpoint

Endpoint to poll.

Tags
throws
MindeeHttpException

Throws if the API sent an error.

Return values
AsyncPredictResponse

makeParseRequest()

Makes the request to send a document to a synchronous endpoint.

private makeParseRequest(string $predictionType, InputSource $inputDoc, PredictMethodOptions $options) : PredictResponse
Parameters
$predictionType : string

Name of the product's class.

$inputDoc : InputSource

Input file.

$options : PredictMethodOptions

Prediction Options.

Tags
throws
MindeeHttpException

Throws if the API sent an error.

throws
MindeeApiException

Throws if one attempts to edit remote resources.

Return values
PredictResponse

        
On this page

Search results