Documentation

MindeeApiV2
in package

Data class containing settings for endpoints.

Table of Contents

Properties

$apiKey  : string|null
$baseUrl  : string
$requestTimeout  : int

Methods

__construct()  : void
reqGetJob()  : JobResponse
Requests the job of a queued document from the API.
reqGetResult()  : T
reqGetResultFromUrl()  : T
reqPostEnqueue()  : JobResponse
searchModels()  : SearchResponse
Retrieves a list of models based on criteria.
setAPIKey()  : void
Sets the API key.
setBaseUrl()  : void
Sets the base url.
checkValidResponse()  : void
documentEnqueuePost()  : array<string, int|float|string|bool|null|array<string|int, mixed>>
Starts a CURL session using POST.
getUserAgent()  : string
Get the User Agent to send for API calls.
initChannel()  : bool|CurlHandle
Init a CURL channel with common params.
processJobResponse()  : JobResponse
Process the HTTP response and return the appropriate response object.
processResponse()  : T
Process the HTTP response and return the appropriate response object.
reqGetSearchModels()  : array<string, int|float|string|bool|null|array<string|int, mixed>>
sendGetRequest()  : array<string, int|float|string|bool|null|array<string|int, mixed>>
Makes a GET call to retrieve a job.
setFromEnv()  : void
Sets values from environment, if needed.

Properties

$baseUrl

public string $baseUrl

Base for the root url. Used for testing purposes.

$requestTimeout

public int $requestTimeout

Timeout for the request, in ms.

Methods

__construct()

public __construct(string|null $apiKey) : void
Parameters
$apiKey : string|null

API key.

Tags
throws
MindeeException

Throws if the API key specified is invalid.

reqGetJob()

Requests the job of a queued document from the API.

public reqGetJob(string $jobId) : JobResponse

Throws an error if the server's response contains one.

Parameters
$jobId : string

ID of the inference.

Tags
throws
MindeeException

Throws if the server's response contains an error.

MindeeException

Throws if the inference ID is not provided.

Return values
JobResponse

Server response wrapped in a JobResponse object.

reqGetResult()

public reqGetResult(string $responseClass, string $resultId) : T
Parameters
$responseClass : string

The response class to construct.

$resultId : string

URL of the result.

Tags
template
phpstan-param

class-string<T> $responseClass

throws
MindeeException

Throws if the server's response contains an error.

MindeeApiException

Throws if the response class is not valid.

Return values
T

A response containing parsing results.

reqGetResultFromUrl()

public reqGetResultFromUrl(string $responseClass, string $resultUrl) : T
Parameters
$responseClass : string

The response class to construct.

$resultUrl : string

URL of the result.

Tags
template
phpstan-param

class-string<T> $responseClass

throws
MindeeException

Throws if the server's response contains an error.

Return values
T

A response containing parsing results.

searchModels()

Retrieves a list of models based on criteria.

public searchModels([string|null $modelName = null ][, string|null $modelType = null ]) : SearchResponse
Parameters
$modelName : string|null = null

Optional model name to filter by.

$modelType : string|null = null

Optional model type to filter by.

Return values
SearchResponse

The list of models matching the criteria.

setAPIKey()

Sets the API key.

protected setAPIKey([string|null $apiKey = null ]) : void
Parameters
$apiKey : string|null = null

Optional API key.

setBaseUrl()

Sets the base url.

protected setBaseUrl(string $value) : void
Parameters
$value : string

Value for the base Url.

checkValidResponse()

private checkValidResponse(array<string, int|float|string|bool|null|array<string|int, mixed>> $result) : void
Parameters
$result : array<string, int|float|string|bool|null|array<string|int, mixed>>

Raw HTTP response array with 'data' and 'code' keys.

Tags
throws
MindeeV2HttpException

Throws if the HTTP status indicates an error.

MindeeV2HttpUnknownException

Throws if the server sends an unexpected reply.

documentEnqueuePost()

Starts a CURL session using POST.

private documentEnqueuePost(InputSource $inputSource, BaseParameters $params) : array<string, int|float|string|bool|null|array<string|int, mixed>>
Parameters
$inputSource : InputSource

File to upload.

$params : BaseParameters

Parameters.

Tags
throws
MindeeException

Throws if the cURL operation doesn't go succeed.

Return values
array<string, int|float|string|bool|null|array<string|int, mixed>>

Server response.

getUserAgent()

Get the User Agent to send for API calls.

private getUserAgent() : string
Return values
string

initChannel()

Init a CURL channel with common params.

private initChannel() : bool|CurlHandle
Return values
bool|CurlHandle

Returns a valid CURL channel.

processJobResponse()

Process the HTTP response and return the appropriate response object.

private processJobResponse(array<string, int|float|string|bool|null|array<string|int, mixed>> $result) : JobResponse
Parameters
$result : array<string, int|float|string|bool|null|array<string|int, mixed>>

Raw HTTP response array with 'data' and 'code' keys.

Tags
throws
MindeeException

Throws if HTTP status indicates an error or deserialization fails.

MindeeApiException

Throws if the response type is not recognized.

Return values
JobResponse

The processed response object.

processResponse()

Process the HTTP response and return the appropriate response object.

private processResponse(string $responseClass, array<string, int|float|string|bool|null|array<string|int, mixed>> $result) : T
Parameters
$responseClass : string

The response class to construct.

$result : array<string, int|float|string|bool|null|array<string|int, mixed>>

Raw HTTP response array with 'data' and 'code' keys.

Tags
template
phpstan-param

class-string<T> $responseClass

throws
MindeeException

Throws if HTTP status indicates an error or deserialization fails.

Return values
T

A response containing parsing results.

reqGetSearchModels()

private reqGetSearchModels([string|null $modelName = null ][, string|null $modelType = null ]) : array<string, int|float|string|bool|null|array<string|int, mixed>>
Parameters
$modelName : string|null = null
$modelType : string|null = null
Return values
array<string, int|float|string|bool|null|array<string|int, mixed>>

Server response.

sendGetRequest()

Makes a GET call to retrieve a job.

private sendGetRequest(string $url) : array<string, int|float|string|bool|null|array<string|int, mixed>>
Parameters
$url : string

URL of the job.

Return values
array<string, int|float|string|bool|null|array<string|int, mixed>>

Server response.

setFromEnv()

Sets values from environment, if needed.

private setFromEnv() : void
On this page

Search results