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
Return values
Endpointenqueue()
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
AsyncPredictResponseenqueueAndParse()
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
Return values
AsyncPredictResponseloadPrediction()
public
loadPrediction(string $predictionType, LocalResponse $localResponse) : AsyncPredictResponse|PredictResponse
Parameters
- $predictionType : string
-
Name of the product's class.
- $localResponse : LocalResponse
-
Local response to load.
Tags
Return values
AsyncPredictResponse|PredictResponse —A valid prediction response.
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
PredictResponseparseQueued()
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
AsyncPredictResponsesourceFromB64String()
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
Base64InputsourceFromBytes()
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
BytesInputsourceFromFile()
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
FileInputsourceFromPath()
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
PathInputsourceFromUrl()
Load a document from an URL.
public
sourceFromUrl(string $url) : URLInputSource
Parameters
- $url : string
-
File URL. Must start with "https://".
Return values
URLInputSourcecleanAccountName()
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
stringconstructEndpoint()
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
EndpointconstructOTSEndpoint()
Builds an off-the-shelf endpoint.
private
constructOTSEndpoint(string $product) : Endpoint
Parameters
- $product : string
-
Name of the product's class.
Tags
Return values
EndpointcutDocPages()
Cut the pages of a PDF following the detailed operations.
private
cutDocPages(LocalInputSource $inputDoc, PageOptions $pageOptions) : void
Parameters
- $inputDoc : LocalInputSource
-
Input PDF file.
- $pageOptions : PageOptions
-
Options to apply to the PDF file.
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
Return values
AsyncPredictResponsemakeParseQueuedRequest()
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
Return values
AsyncPredictResponsemakeParseRequest()
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.