22
33namespace Mindee \V2 ;
44
5+ use Mindee \ClientOptions \PollingOptions ;
56use Mindee \CustomSleepMixin ;
67use Mindee \Error \MindeeException ;
78use Mindee \Input \InputSource ;
89use Mindee \V2 \ClientOptions \BaseParameters ;
910use Mindee \V2 \HTTP \MindeeAPIV2 ;
1011use Mindee \V2 \Parsing \Inference \BaseResponse ;
11- use Mindee \V2 \Parsing \Inference \InferenceResponse ;
1212use Mindee \V2 \Parsing \JobResponse ;
13- use Mindee \V2 \Product \Extraction \Params \InferenceParameters ;
13+ use Mindee \V2 \Product \Extraction \Params \ExtractionParameters ;
1414
1515/**
1616 * Mindee Client V2.
@@ -37,15 +37,15 @@ public function __construct(?string $apiKey = null)
3737 /**
3838 * Send the document to an asynchronous endpoint and return its ID in the queue.
3939 *
40- * @param InputSource $inputSource File to parse.
41- * @param InferenceParameters $params Parameters relating to prediction options.
40+ * @param InputSource $inputSource File to parse.
41+ * @param ExtractionParameters $params Parameters relating to prediction options.
4242 * @return JobResponse A JobResponse containing the job (queue) corresponding to a document.
4343 * @throws MindeeException Throws if the input document is not provided.
4444 * @category Asynchronous
4545 */
4646 public function enqueueInference (
4747 InputSource $ inputSource ,
48- InferenceParameters $ params
48+ ExtractionParameters $ params
4949 ): JobResponse {
5050 return $ this ->enqueue ($ inputSource , $ params );
5151 }
@@ -65,17 +65,6 @@ public function enqueue(
6565 return $ this ->mindeeApi ->reqPostEnqueue ($ inputSource , $ params );
6666 }
6767
68- /**
69- * Retrieves an inference.
70- *
71- * @param string $inferenceId ID of the queue to poll.
72- * @return InferenceResponse An InferenceResponse containing a Job.
73- * @category Asynchronous
74- */
75- public function getInference (string $ inferenceId ): InferenceResponse
76- {
77- return $ this ->mindeeApi ->reqGetInference ($ inferenceId );
78- }
7968
8069 /**
8170 * @template T of BaseResponse
@@ -118,40 +107,28 @@ public function getJob(string $jobId): JobResponse
118107 return $ this ->mindeeApi ->reqGetJob ($ jobId );
119108 }
120109
121- /**
122- * Send a document to an endpoint and poll the server until the result is sent or
123- * until the maximum number of tries is reached.
124- *
125- * @param InputSource $inputDoc Input document to parse.
126- * @param InferenceParameters $params Parameters relating to prediction options.
127- * @return InferenceResponse A response containing parsing results.
128- * @throws MindeeException Throws if enqueueing fails, job fails, or times out.
129- */
130- public function enqueueAndGetInference (
131- InputSource $ inputDoc ,
132- InferenceParameters $ params
133- ): InferenceResponse {
134- return $ this ->enqueueAndGetResult (InferenceResponse::class, $ inputDoc , $ params );
135- }
136-
137110 /**
138111 * Send a document to an endpoint and poll the server until the result is sent or
139112 * until the maximum number of tries is reached.
140113 *
141114 * @template T of BaseResponse
142- * @param string $responseClass The response class to construct.
115+ * @param string $responseClass The response class to construct.
143116 * @phpstan-param class-string<T> $responseClass
144- * @param InputSource $inputDoc Input document to parse.
145- * @param BaseParameters $params Parameters relating to prediction options.
117+ * @param InputSource $inputDoc Input document to parse.
118+ * @param BaseParameters $params Parameters relating to prediction options.
119+ * @param PollingOptions|null $pollingOptions Options to apply to the polling.
146120 * @return BaseResponse A response containing parsing results.
147121 * @throws MindeeException Throws if enqueueing fails, job fails, or times out.
148122 */
149123 public function enqueueAndGetResult (
150124 string $ responseClass ,
151125 InputSource $ inputDoc ,
152- BaseParameters $ params
126+ BaseParameters $ params ,
127+ ?PollingOptions $ pollingOptions = null
153128 ): BaseResponse {
154- $ pollingOptions = $ params ->pollingOptions ;
129+ if (!$ pollingOptions ) {
130+ $ pollingOptions = new PollingOptions ();
131+ }
155132
156133 $ enqueueResponse = $ this ->enqueue ($ inputDoc , $ params );
157134
0 commit comments