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
$apiKey
public
string|null
$apiKey
API key.
$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
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
Return values
InferenceResponsereqGetJob()
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
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
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
Return values
T —A response containing parsing results.
reqPostEnqueue()
public
reqPostEnqueue(InputSource $inputDoc, BaseParameters $params) : JobResponse
Parameters
- $inputDoc : InputSource
-
Input document.
- $params : BaseParameters
-
Parameters for the inference.
Tags
Return values
JobResponse —Server response wrapped in a JobResponse object.
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
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
Return values
array<string|int, mixed>getUserAgent()
Get the User Agent to send for API calls.
private
getUserAgent() : string
Return values
stringinitChannel()
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
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
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