Documentation

MindeeApiV2
in package

Data class containing settings for endpoints.

Table of Contents

Properties

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

Methods

__construct()  : void
reqGetInference()  : InferenceResponse
Requests the job of a queued document from the API.
reqGetJob()  : JobResponse
Requests the job of a queued document from the API.
reqGetResult()  : T
reqGetResultFromUrl()  : T
reqPostEnqueue()  : JobResponse
setApiKey()  : void
Sets the API key.
setBaseUrl()  : void
Sets the base url.
checkValidResponse()  : void
documentEnqueuePost()  : array<string|int, mixed>
Starts a CURL session using POST.
getUserAgent()  : string
Get the User Agent to send for API calls.
initChannel()  : false|resource
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.
sendGetRequest()  : 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.

reqGetInference()

Requests the job of a queued document from the API.

public reqGetInference(string $inferenceId) : InferenceResponse

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

Parameters
$inferenceId : string

ID of the inference.

Tags
throws
MindeeException

Throws if the server's response contains an error.

throws
MindeeException

Throws if the inference ID is not provided.

Return values
InferenceResponse

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.

throws
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.

throws
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.

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, mixed> $result) : void
Parameters
$result : array<string|int, mixed>

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

Tags
throws
MindeeV2HttpException

Throws if the HTTP status indicates an error.

throws
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, mixed>
Parameters
$inputSource : InputSource

File to upload.

$params : BaseParameters

Inference parameters.

Tags
throws
MindeeException

Throws if the cURL operation doesn't go succeed.

Return values
array<string|int, mixed>

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() : false|resource
Return values
false|resource

Returns a valid CURL channel.

processJobResponse()

Process the HTTP response and return the appropriate response object.

private processJobResponse(array<string|int, mixed> $result) : JobResponse
Parameters
$result : 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.

throws
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, mixed> $result) : T
Parameters
$responseClass : string

The response class to construct.

$result : 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.

sendGetRequest()

Makes a GET call to retrieve a job.

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

URL of the job.

Return values
array<string|int, mixed>

Server response.

setFromEnv()

Sets values from environment, if needed.

private setFromEnv() : void

        
On this page

Search results