1 /*
2 * Copyright 2009-2017 Alibaba Cloud All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <alibabacloud/ocr/OcrClient.h>
18 #include <alibabacloud/core/SimpleCredentialsProvider.h>
19
20 using namespace AlibabaCloud;
21 using namespace AlibabaCloud::Location;
22 using namespace AlibabaCloud::Ocr;
23 using namespace AlibabaCloud::Ocr::Model;
24
25 namespace
26 {
27 const std::string SERVICE_NAME = "ocr";
28 }
29
OcrClient(const Credentials & credentials,const ClientConfiguration & configuration)30 OcrClient::OcrClient(const Credentials &credentials, const ClientConfiguration &configuration) :
31 RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
32 {
33 auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
34 endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "ocr");
35 }
36
OcrClient(const std::shared_ptr<CredentialsProvider> & credentialsProvider,const ClientConfiguration & configuration)37 OcrClient::OcrClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
38 RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
39 {
40 auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
41 endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "ocr");
42 }
43
OcrClient(const std::string & accessKeyId,const std::string & accessKeySecret,const ClientConfiguration & configuration)44 OcrClient::OcrClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
45 RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
46 {
47 auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
48 endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "ocr");
49 }
50
~OcrClient()51 OcrClient::~OcrClient()
52 {}
53
detectCardScreenshot(const DetectCardScreenshotRequest & request) const54 OcrClient::DetectCardScreenshotOutcome OcrClient::detectCardScreenshot(const DetectCardScreenshotRequest &request) const
55 {
56 auto endpointOutcome = endpointProvider_->getEndpoint();
57 if (!endpointOutcome.isSuccess())
58 return DetectCardScreenshotOutcome(endpointOutcome.error());
59
60 auto outcome = makeRequest(endpointOutcome.result(), request);
61
62 if (outcome.isSuccess())
63 return DetectCardScreenshotOutcome(DetectCardScreenshotResult(outcome.result()));
64 else
65 return DetectCardScreenshotOutcome(outcome.error());
66 }
67
detectCardScreenshotAsync(const DetectCardScreenshotRequest & request,const DetectCardScreenshotAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const68 void OcrClient::detectCardScreenshotAsync(const DetectCardScreenshotRequest& request, const DetectCardScreenshotAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
69 {
70 auto fn = [this, request, handler, context]()
71 {
72 handler(this, request, detectCardScreenshot(request), context);
73 };
74
75 asyncExecute(new Runnable(fn));
76 }
77
detectCardScreenshotCallable(const DetectCardScreenshotRequest & request) const78 OcrClient::DetectCardScreenshotOutcomeCallable OcrClient::detectCardScreenshotCallable(const DetectCardScreenshotRequest &request) const
79 {
80 auto task = std::make_shared<std::packaged_task<DetectCardScreenshotOutcome()>>(
81 [this, request]()
82 {
83 return this->detectCardScreenshot(request);
84 });
85
86 asyncExecute(new Runnable([task]() { (*task)(); }));
87 return task->get_future();
88 }
89
getAsyncJobResult(const GetAsyncJobResultRequest & request) const90 OcrClient::GetAsyncJobResultOutcome OcrClient::getAsyncJobResult(const GetAsyncJobResultRequest &request) const
91 {
92 auto endpointOutcome = endpointProvider_->getEndpoint();
93 if (!endpointOutcome.isSuccess())
94 return GetAsyncJobResultOutcome(endpointOutcome.error());
95
96 auto outcome = makeRequest(endpointOutcome.result(), request);
97
98 if (outcome.isSuccess())
99 return GetAsyncJobResultOutcome(GetAsyncJobResultResult(outcome.result()));
100 else
101 return GetAsyncJobResultOutcome(outcome.error());
102 }
103
getAsyncJobResultAsync(const GetAsyncJobResultRequest & request,const GetAsyncJobResultAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const104 void OcrClient::getAsyncJobResultAsync(const GetAsyncJobResultRequest& request, const GetAsyncJobResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
105 {
106 auto fn = [this, request, handler, context]()
107 {
108 handler(this, request, getAsyncJobResult(request), context);
109 };
110
111 asyncExecute(new Runnable(fn));
112 }
113
getAsyncJobResultCallable(const GetAsyncJobResultRequest & request) const114 OcrClient::GetAsyncJobResultOutcomeCallable OcrClient::getAsyncJobResultCallable(const GetAsyncJobResultRequest &request) const
115 {
116 auto task = std::make_shared<std::packaged_task<GetAsyncJobResultOutcome()>>(
117 [this, request]()
118 {
119 return this->getAsyncJobResult(request);
120 });
121
122 asyncExecute(new Runnable([task]() { (*task)(); }));
123 return task->get_future();
124 }
125
recognizeAccountPage(const RecognizeAccountPageRequest & request) const126 OcrClient::RecognizeAccountPageOutcome OcrClient::recognizeAccountPage(const RecognizeAccountPageRequest &request) const
127 {
128 auto endpointOutcome = endpointProvider_->getEndpoint();
129 if (!endpointOutcome.isSuccess())
130 return RecognizeAccountPageOutcome(endpointOutcome.error());
131
132 auto outcome = makeRequest(endpointOutcome.result(), request);
133
134 if (outcome.isSuccess())
135 return RecognizeAccountPageOutcome(RecognizeAccountPageResult(outcome.result()));
136 else
137 return RecognizeAccountPageOutcome(outcome.error());
138 }
139
recognizeAccountPageAsync(const RecognizeAccountPageRequest & request,const RecognizeAccountPageAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const140 void OcrClient::recognizeAccountPageAsync(const RecognizeAccountPageRequest& request, const RecognizeAccountPageAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
141 {
142 auto fn = [this, request, handler, context]()
143 {
144 handler(this, request, recognizeAccountPage(request), context);
145 };
146
147 asyncExecute(new Runnable(fn));
148 }
149
recognizeAccountPageCallable(const RecognizeAccountPageRequest & request) const150 OcrClient::RecognizeAccountPageOutcomeCallable OcrClient::recognizeAccountPageCallable(const RecognizeAccountPageRequest &request) const
151 {
152 auto task = std::make_shared<std::packaged_task<RecognizeAccountPageOutcome()>>(
153 [this, request]()
154 {
155 return this->recognizeAccountPage(request);
156 });
157
158 asyncExecute(new Runnable([task]() { (*task)(); }));
159 return task->get_future();
160 }
161
recognizeBankCard(const RecognizeBankCardRequest & request) const162 OcrClient::RecognizeBankCardOutcome OcrClient::recognizeBankCard(const RecognizeBankCardRequest &request) const
163 {
164 auto endpointOutcome = endpointProvider_->getEndpoint();
165 if (!endpointOutcome.isSuccess())
166 return RecognizeBankCardOutcome(endpointOutcome.error());
167
168 auto outcome = makeRequest(endpointOutcome.result(), request);
169
170 if (outcome.isSuccess())
171 return RecognizeBankCardOutcome(RecognizeBankCardResult(outcome.result()));
172 else
173 return RecognizeBankCardOutcome(outcome.error());
174 }
175
recognizeBankCardAsync(const RecognizeBankCardRequest & request,const RecognizeBankCardAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const176 void OcrClient::recognizeBankCardAsync(const RecognizeBankCardRequest& request, const RecognizeBankCardAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
177 {
178 auto fn = [this, request, handler, context]()
179 {
180 handler(this, request, recognizeBankCard(request), context);
181 };
182
183 asyncExecute(new Runnable(fn));
184 }
185
recognizeBankCardCallable(const RecognizeBankCardRequest & request) const186 OcrClient::RecognizeBankCardOutcomeCallable OcrClient::recognizeBankCardCallable(const RecognizeBankCardRequest &request) const
187 {
188 auto task = std::make_shared<std::packaged_task<RecognizeBankCardOutcome()>>(
189 [this, request]()
190 {
191 return this->recognizeBankCard(request);
192 });
193
194 asyncExecute(new Runnable([task]() { (*task)(); }));
195 return task->get_future();
196 }
197
recognizeBusinessCard(const RecognizeBusinessCardRequest & request) const198 OcrClient::RecognizeBusinessCardOutcome OcrClient::recognizeBusinessCard(const RecognizeBusinessCardRequest &request) const
199 {
200 auto endpointOutcome = endpointProvider_->getEndpoint();
201 if (!endpointOutcome.isSuccess())
202 return RecognizeBusinessCardOutcome(endpointOutcome.error());
203
204 auto outcome = makeRequest(endpointOutcome.result(), request);
205
206 if (outcome.isSuccess())
207 return RecognizeBusinessCardOutcome(RecognizeBusinessCardResult(outcome.result()));
208 else
209 return RecognizeBusinessCardOutcome(outcome.error());
210 }
211
recognizeBusinessCardAsync(const RecognizeBusinessCardRequest & request,const RecognizeBusinessCardAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const212 void OcrClient::recognizeBusinessCardAsync(const RecognizeBusinessCardRequest& request, const RecognizeBusinessCardAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
213 {
214 auto fn = [this, request, handler, context]()
215 {
216 handler(this, request, recognizeBusinessCard(request), context);
217 };
218
219 asyncExecute(new Runnable(fn));
220 }
221
recognizeBusinessCardCallable(const RecognizeBusinessCardRequest & request) const222 OcrClient::RecognizeBusinessCardOutcomeCallable OcrClient::recognizeBusinessCardCallable(const RecognizeBusinessCardRequest &request) const
223 {
224 auto task = std::make_shared<std::packaged_task<RecognizeBusinessCardOutcome()>>(
225 [this, request]()
226 {
227 return this->recognizeBusinessCard(request);
228 });
229
230 asyncExecute(new Runnable([task]() { (*task)(); }));
231 return task->get_future();
232 }
233
recognizeBusinessLicense(const RecognizeBusinessLicenseRequest & request) const234 OcrClient::RecognizeBusinessLicenseOutcome OcrClient::recognizeBusinessLicense(const RecognizeBusinessLicenseRequest &request) const
235 {
236 auto endpointOutcome = endpointProvider_->getEndpoint();
237 if (!endpointOutcome.isSuccess())
238 return RecognizeBusinessLicenseOutcome(endpointOutcome.error());
239
240 auto outcome = makeRequest(endpointOutcome.result(), request);
241
242 if (outcome.isSuccess())
243 return RecognizeBusinessLicenseOutcome(RecognizeBusinessLicenseResult(outcome.result()));
244 else
245 return RecognizeBusinessLicenseOutcome(outcome.error());
246 }
247
recognizeBusinessLicenseAsync(const RecognizeBusinessLicenseRequest & request,const RecognizeBusinessLicenseAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const248 void OcrClient::recognizeBusinessLicenseAsync(const RecognizeBusinessLicenseRequest& request, const RecognizeBusinessLicenseAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
249 {
250 auto fn = [this, request, handler, context]()
251 {
252 handler(this, request, recognizeBusinessLicense(request), context);
253 };
254
255 asyncExecute(new Runnable(fn));
256 }
257
recognizeBusinessLicenseCallable(const RecognizeBusinessLicenseRequest & request) const258 OcrClient::RecognizeBusinessLicenseOutcomeCallable OcrClient::recognizeBusinessLicenseCallable(const RecognizeBusinessLicenseRequest &request) const
259 {
260 auto task = std::make_shared<std::packaged_task<RecognizeBusinessLicenseOutcome()>>(
261 [this, request]()
262 {
263 return this->recognizeBusinessLicense(request);
264 });
265
266 asyncExecute(new Runnable([task]() { (*task)(); }));
267 return task->get_future();
268 }
269
recognizeCharacter(const RecognizeCharacterRequest & request) const270 OcrClient::RecognizeCharacterOutcome OcrClient::recognizeCharacter(const RecognizeCharacterRequest &request) const
271 {
272 auto endpointOutcome = endpointProvider_->getEndpoint();
273 if (!endpointOutcome.isSuccess())
274 return RecognizeCharacterOutcome(endpointOutcome.error());
275
276 auto outcome = makeRequest(endpointOutcome.result(), request);
277
278 if (outcome.isSuccess())
279 return RecognizeCharacterOutcome(RecognizeCharacterResult(outcome.result()));
280 else
281 return RecognizeCharacterOutcome(outcome.error());
282 }
283
recognizeCharacterAsync(const RecognizeCharacterRequest & request,const RecognizeCharacterAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const284 void OcrClient::recognizeCharacterAsync(const RecognizeCharacterRequest& request, const RecognizeCharacterAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
285 {
286 auto fn = [this, request, handler, context]()
287 {
288 handler(this, request, recognizeCharacter(request), context);
289 };
290
291 asyncExecute(new Runnable(fn));
292 }
293
recognizeCharacterCallable(const RecognizeCharacterRequest & request) const294 OcrClient::RecognizeCharacterOutcomeCallable OcrClient::recognizeCharacterCallable(const RecognizeCharacterRequest &request) const
295 {
296 auto task = std::make_shared<std::packaged_task<RecognizeCharacterOutcome()>>(
297 [this, request]()
298 {
299 return this->recognizeCharacter(request);
300 });
301
302 asyncExecute(new Runnable([task]() { (*task)(); }));
303 return task->get_future();
304 }
305
recognizeChinapassport(const RecognizeChinapassportRequest & request) const306 OcrClient::RecognizeChinapassportOutcome OcrClient::recognizeChinapassport(const RecognizeChinapassportRequest &request) const
307 {
308 auto endpointOutcome = endpointProvider_->getEndpoint();
309 if (!endpointOutcome.isSuccess())
310 return RecognizeChinapassportOutcome(endpointOutcome.error());
311
312 auto outcome = makeRequest(endpointOutcome.result(), request);
313
314 if (outcome.isSuccess())
315 return RecognizeChinapassportOutcome(RecognizeChinapassportResult(outcome.result()));
316 else
317 return RecognizeChinapassportOutcome(outcome.error());
318 }
319
recognizeChinapassportAsync(const RecognizeChinapassportRequest & request,const RecognizeChinapassportAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const320 void OcrClient::recognizeChinapassportAsync(const RecognizeChinapassportRequest& request, const RecognizeChinapassportAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
321 {
322 auto fn = [this, request, handler, context]()
323 {
324 handler(this, request, recognizeChinapassport(request), context);
325 };
326
327 asyncExecute(new Runnable(fn));
328 }
329
recognizeChinapassportCallable(const RecognizeChinapassportRequest & request) const330 OcrClient::RecognizeChinapassportOutcomeCallable OcrClient::recognizeChinapassportCallable(const RecognizeChinapassportRequest &request) const
331 {
332 auto task = std::make_shared<std::packaged_task<RecognizeChinapassportOutcome()>>(
333 [this, request]()
334 {
335 return this->recognizeChinapassport(request);
336 });
337
338 asyncExecute(new Runnable([task]() { (*task)(); }));
339 return task->get_future();
340 }
341
recognizeDriverLicense(const RecognizeDriverLicenseRequest & request) const342 OcrClient::RecognizeDriverLicenseOutcome OcrClient::recognizeDriverLicense(const RecognizeDriverLicenseRequest &request) const
343 {
344 auto endpointOutcome = endpointProvider_->getEndpoint();
345 if (!endpointOutcome.isSuccess())
346 return RecognizeDriverLicenseOutcome(endpointOutcome.error());
347
348 auto outcome = makeRequest(endpointOutcome.result(), request);
349
350 if (outcome.isSuccess())
351 return RecognizeDriverLicenseOutcome(RecognizeDriverLicenseResult(outcome.result()));
352 else
353 return RecognizeDriverLicenseOutcome(outcome.error());
354 }
355
recognizeDriverLicenseAsync(const RecognizeDriverLicenseRequest & request,const RecognizeDriverLicenseAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const356 void OcrClient::recognizeDriverLicenseAsync(const RecognizeDriverLicenseRequest& request, const RecognizeDriverLicenseAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
357 {
358 auto fn = [this, request, handler, context]()
359 {
360 handler(this, request, recognizeDriverLicense(request), context);
361 };
362
363 asyncExecute(new Runnable(fn));
364 }
365
recognizeDriverLicenseCallable(const RecognizeDriverLicenseRequest & request) const366 OcrClient::RecognizeDriverLicenseOutcomeCallable OcrClient::recognizeDriverLicenseCallable(const RecognizeDriverLicenseRequest &request) const
367 {
368 auto task = std::make_shared<std::packaged_task<RecognizeDriverLicenseOutcome()>>(
369 [this, request]()
370 {
371 return this->recognizeDriverLicense(request);
372 });
373
374 asyncExecute(new Runnable([task]() { (*task)(); }));
375 return task->get_future();
376 }
377
recognizeDrivingLicense(const RecognizeDrivingLicenseRequest & request) const378 OcrClient::RecognizeDrivingLicenseOutcome OcrClient::recognizeDrivingLicense(const RecognizeDrivingLicenseRequest &request) const
379 {
380 auto endpointOutcome = endpointProvider_->getEndpoint();
381 if (!endpointOutcome.isSuccess())
382 return RecognizeDrivingLicenseOutcome(endpointOutcome.error());
383
384 auto outcome = makeRequest(endpointOutcome.result(), request);
385
386 if (outcome.isSuccess())
387 return RecognizeDrivingLicenseOutcome(RecognizeDrivingLicenseResult(outcome.result()));
388 else
389 return RecognizeDrivingLicenseOutcome(outcome.error());
390 }
391
recognizeDrivingLicenseAsync(const RecognizeDrivingLicenseRequest & request,const RecognizeDrivingLicenseAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const392 void OcrClient::recognizeDrivingLicenseAsync(const RecognizeDrivingLicenseRequest& request, const RecognizeDrivingLicenseAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
393 {
394 auto fn = [this, request, handler, context]()
395 {
396 handler(this, request, recognizeDrivingLicense(request), context);
397 };
398
399 asyncExecute(new Runnable(fn));
400 }
401
recognizeDrivingLicenseCallable(const RecognizeDrivingLicenseRequest & request) const402 OcrClient::RecognizeDrivingLicenseOutcomeCallable OcrClient::recognizeDrivingLicenseCallable(const RecognizeDrivingLicenseRequest &request) const
403 {
404 auto task = std::make_shared<std::packaged_task<RecognizeDrivingLicenseOutcome()>>(
405 [this, request]()
406 {
407 return this->recognizeDrivingLicense(request);
408 });
409
410 asyncExecute(new Runnable([task]() { (*task)(); }));
411 return task->get_future();
412 }
413
recognizeIdentityCard(const RecognizeIdentityCardRequest & request) const414 OcrClient::RecognizeIdentityCardOutcome OcrClient::recognizeIdentityCard(const RecognizeIdentityCardRequest &request) const
415 {
416 auto endpointOutcome = endpointProvider_->getEndpoint();
417 if (!endpointOutcome.isSuccess())
418 return RecognizeIdentityCardOutcome(endpointOutcome.error());
419
420 auto outcome = makeRequest(endpointOutcome.result(), request);
421
422 if (outcome.isSuccess())
423 return RecognizeIdentityCardOutcome(RecognizeIdentityCardResult(outcome.result()));
424 else
425 return RecognizeIdentityCardOutcome(outcome.error());
426 }
427
recognizeIdentityCardAsync(const RecognizeIdentityCardRequest & request,const RecognizeIdentityCardAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const428 void OcrClient::recognizeIdentityCardAsync(const RecognizeIdentityCardRequest& request, const RecognizeIdentityCardAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
429 {
430 auto fn = [this, request, handler, context]()
431 {
432 handler(this, request, recognizeIdentityCard(request), context);
433 };
434
435 asyncExecute(new Runnable(fn));
436 }
437
recognizeIdentityCardCallable(const RecognizeIdentityCardRequest & request) const438 OcrClient::RecognizeIdentityCardOutcomeCallable OcrClient::recognizeIdentityCardCallable(const RecognizeIdentityCardRequest &request) const
439 {
440 auto task = std::make_shared<std::packaged_task<RecognizeIdentityCardOutcome()>>(
441 [this, request]()
442 {
443 return this->recognizeIdentityCard(request);
444 });
445
446 asyncExecute(new Runnable([task]() { (*task)(); }));
447 return task->get_future();
448 }
449
recognizeLicensePlate(const RecognizeLicensePlateRequest & request) const450 OcrClient::RecognizeLicensePlateOutcome OcrClient::recognizeLicensePlate(const RecognizeLicensePlateRequest &request) const
451 {
452 auto endpointOutcome = endpointProvider_->getEndpoint();
453 if (!endpointOutcome.isSuccess())
454 return RecognizeLicensePlateOutcome(endpointOutcome.error());
455
456 auto outcome = makeRequest(endpointOutcome.result(), request);
457
458 if (outcome.isSuccess())
459 return RecognizeLicensePlateOutcome(RecognizeLicensePlateResult(outcome.result()));
460 else
461 return RecognizeLicensePlateOutcome(outcome.error());
462 }
463
recognizeLicensePlateAsync(const RecognizeLicensePlateRequest & request,const RecognizeLicensePlateAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const464 void OcrClient::recognizeLicensePlateAsync(const RecognizeLicensePlateRequest& request, const RecognizeLicensePlateAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
465 {
466 auto fn = [this, request, handler, context]()
467 {
468 handler(this, request, recognizeLicensePlate(request), context);
469 };
470
471 asyncExecute(new Runnable(fn));
472 }
473
recognizeLicensePlateCallable(const RecognizeLicensePlateRequest & request) const474 OcrClient::RecognizeLicensePlateOutcomeCallable OcrClient::recognizeLicensePlateCallable(const RecognizeLicensePlateRequest &request) const
475 {
476 auto task = std::make_shared<std::packaged_task<RecognizeLicensePlateOutcome()>>(
477 [this, request]()
478 {
479 return this->recognizeLicensePlate(request);
480 });
481
482 asyncExecute(new Runnable([task]() { (*task)(); }));
483 return task->get_future();
484 }
485
recognizePassportMRZ(const RecognizePassportMRZRequest & request) const486 OcrClient::RecognizePassportMRZOutcome OcrClient::recognizePassportMRZ(const RecognizePassportMRZRequest &request) const
487 {
488 auto endpointOutcome = endpointProvider_->getEndpoint();
489 if (!endpointOutcome.isSuccess())
490 return RecognizePassportMRZOutcome(endpointOutcome.error());
491
492 auto outcome = makeRequest(endpointOutcome.result(), request);
493
494 if (outcome.isSuccess())
495 return RecognizePassportMRZOutcome(RecognizePassportMRZResult(outcome.result()));
496 else
497 return RecognizePassportMRZOutcome(outcome.error());
498 }
499
recognizePassportMRZAsync(const RecognizePassportMRZRequest & request,const RecognizePassportMRZAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const500 void OcrClient::recognizePassportMRZAsync(const RecognizePassportMRZRequest& request, const RecognizePassportMRZAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
501 {
502 auto fn = [this, request, handler, context]()
503 {
504 handler(this, request, recognizePassportMRZ(request), context);
505 };
506
507 asyncExecute(new Runnable(fn));
508 }
509
recognizePassportMRZCallable(const RecognizePassportMRZRequest & request) const510 OcrClient::RecognizePassportMRZOutcomeCallable OcrClient::recognizePassportMRZCallable(const RecognizePassportMRZRequest &request) const
511 {
512 auto task = std::make_shared<std::packaged_task<RecognizePassportMRZOutcome()>>(
513 [this, request]()
514 {
515 return this->recognizePassportMRZ(request);
516 });
517
518 asyncExecute(new Runnable([task]() { (*task)(); }));
519 return task->get_future();
520 }
521
recognizePoiName(const RecognizePoiNameRequest & request) const522 OcrClient::RecognizePoiNameOutcome OcrClient::recognizePoiName(const RecognizePoiNameRequest &request) const
523 {
524 auto endpointOutcome = endpointProvider_->getEndpoint();
525 if (!endpointOutcome.isSuccess())
526 return RecognizePoiNameOutcome(endpointOutcome.error());
527
528 auto outcome = makeRequest(endpointOutcome.result(), request);
529
530 if (outcome.isSuccess())
531 return RecognizePoiNameOutcome(RecognizePoiNameResult(outcome.result()));
532 else
533 return RecognizePoiNameOutcome(outcome.error());
534 }
535
recognizePoiNameAsync(const RecognizePoiNameRequest & request,const RecognizePoiNameAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const536 void OcrClient::recognizePoiNameAsync(const RecognizePoiNameRequest& request, const RecognizePoiNameAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
537 {
538 auto fn = [this, request, handler, context]()
539 {
540 handler(this, request, recognizePoiName(request), context);
541 };
542
543 asyncExecute(new Runnable(fn));
544 }
545
recognizePoiNameCallable(const RecognizePoiNameRequest & request) const546 OcrClient::RecognizePoiNameOutcomeCallable OcrClient::recognizePoiNameCallable(const RecognizePoiNameRequest &request) const
547 {
548 auto task = std::make_shared<std::packaged_task<RecognizePoiNameOutcome()>>(
549 [this, request]()
550 {
551 return this->recognizePoiName(request);
552 });
553
554 asyncExecute(new Runnable([task]() { (*task)(); }));
555 return task->get_future();
556 }
557
recognizeQrCode(const RecognizeQrCodeRequest & request) const558 OcrClient::RecognizeQrCodeOutcome OcrClient::recognizeQrCode(const RecognizeQrCodeRequest &request) const
559 {
560 auto endpointOutcome = endpointProvider_->getEndpoint();
561 if (!endpointOutcome.isSuccess())
562 return RecognizeQrCodeOutcome(endpointOutcome.error());
563
564 auto outcome = makeRequest(endpointOutcome.result(), request);
565
566 if (outcome.isSuccess())
567 return RecognizeQrCodeOutcome(RecognizeQrCodeResult(outcome.result()));
568 else
569 return RecognizeQrCodeOutcome(outcome.error());
570 }
571
recognizeQrCodeAsync(const RecognizeQrCodeRequest & request,const RecognizeQrCodeAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const572 void OcrClient::recognizeQrCodeAsync(const RecognizeQrCodeRequest& request, const RecognizeQrCodeAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
573 {
574 auto fn = [this, request, handler, context]()
575 {
576 handler(this, request, recognizeQrCode(request), context);
577 };
578
579 asyncExecute(new Runnable(fn));
580 }
581
recognizeQrCodeCallable(const RecognizeQrCodeRequest & request) const582 OcrClient::RecognizeQrCodeOutcomeCallable OcrClient::recognizeQrCodeCallable(const RecognizeQrCodeRequest &request) const
583 {
584 auto task = std::make_shared<std::packaged_task<RecognizeQrCodeOutcome()>>(
585 [this, request]()
586 {
587 return this->recognizeQrCode(request);
588 });
589
590 asyncExecute(new Runnable([task]() { (*task)(); }));
591 return task->get_future();
592 }
593
recognizeStamp(const RecognizeStampRequest & request) const594 OcrClient::RecognizeStampOutcome OcrClient::recognizeStamp(const RecognizeStampRequest &request) const
595 {
596 auto endpointOutcome = endpointProvider_->getEndpoint();
597 if (!endpointOutcome.isSuccess())
598 return RecognizeStampOutcome(endpointOutcome.error());
599
600 auto outcome = makeRequest(endpointOutcome.result(), request);
601
602 if (outcome.isSuccess())
603 return RecognizeStampOutcome(RecognizeStampResult(outcome.result()));
604 else
605 return RecognizeStampOutcome(outcome.error());
606 }
607
recognizeStampAsync(const RecognizeStampRequest & request,const RecognizeStampAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const608 void OcrClient::recognizeStampAsync(const RecognizeStampRequest& request, const RecognizeStampAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
609 {
610 auto fn = [this, request, handler, context]()
611 {
612 handler(this, request, recognizeStamp(request), context);
613 };
614
615 asyncExecute(new Runnable(fn));
616 }
617
recognizeStampCallable(const RecognizeStampRequest & request) const618 OcrClient::RecognizeStampOutcomeCallable OcrClient::recognizeStampCallable(const RecognizeStampRequest &request) const
619 {
620 auto task = std::make_shared<std::packaged_task<RecognizeStampOutcome()>>(
621 [this, request]()
622 {
623 return this->recognizeStamp(request);
624 });
625
626 asyncExecute(new Runnable([task]() { (*task)(); }));
627 return task->get_future();
628 }
629
recognizeTable(const RecognizeTableRequest & request) const630 OcrClient::RecognizeTableOutcome OcrClient::recognizeTable(const RecognizeTableRequest &request) const
631 {
632 auto endpointOutcome = endpointProvider_->getEndpoint();
633 if (!endpointOutcome.isSuccess())
634 return RecognizeTableOutcome(endpointOutcome.error());
635
636 auto outcome = makeRequest(endpointOutcome.result(), request);
637
638 if (outcome.isSuccess())
639 return RecognizeTableOutcome(RecognizeTableResult(outcome.result()));
640 else
641 return RecognizeTableOutcome(outcome.error());
642 }
643
recognizeTableAsync(const RecognizeTableRequest & request,const RecognizeTableAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const644 void OcrClient::recognizeTableAsync(const RecognizeTableRequest& request, const RecognizeTableAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
645 {
646 auto fn = [this, request, handler, context]()
647 {
648 handler(this, request, recognizeTable(request), context);
649 };
650
651 asyncExecute(new Runnable(fn));
652 }
653
recognizeTableCallable(const RecognizeTableRequest & request) const654 OcrClient::RecognizeTableOutcomeCallable OcrClient::recognizeTableCallable(const RecognizeTableRequest &request) const
655 {
656 auto task = std::make_shared<std::packaged_task<RecognizeTableOutcome()>>(
657 [this, request]()
658 {
659 return this->recognizeTable(request);
660 });
661
662 asyncExecute(new Runnable([task]() { (*task)(); }));
663 return task->get_future();
664 }
665
recognizeTakeoutOrder(const RecognizeTakeoutOrderRequest & request) const666 OcrClient::RecognizeTakeoutOrderOutcome OcrClient::recognizeTakeoutOrder(const RecognizeTakeoutOrderRequest &request) const
667 {
668 auto endpointOutcome = endpointProvider_->getEndpoint();
669 if (!endpointOutcome.isSuccess())
670 return RecognizeTakeoutOrderOutcome(endpointOutcome.error());
671
672 auto outcome = makeRequest(endpointOutcome.result(), request);
673
674 if (outcome.isSuccess())
675 return RecognizeTakeoutOrderOutcome(RecognizeTakeoutOrderResult(outcome.result()));
676 else
677 return RecognizeTakeoutOrderOutcome(outcome.error());
678 }
679
recognizeTakeoutOrderAsync(const RecognizeTakeoutOrderRequest & request,const RecognizeTakeoutOrderAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const680 void OcrClient::recognizeTakeoutOrderAsync(const RecognizeTakeoutOrderRequest& request, const RecognizeTakeoutOrderAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
681 {
682 auto fn = [this, request, handler, context]()
683 {
684 handler(this, request, recognizeTakeoutOrder(request), context);
685 };
686
687 asyncExecute(new Runnable(fn));
688 }
689
recognizeTakeoutOrderCallable(const RecognizeTakeoutOrderRequest & request) const690 OcrClient::RecognizeTakeoutOrderOutcomeCallable OcrClient::recognizeTakeoutOrderCallable(const RecognizeTakeoutOrderRequest &request) const
691 {
692 auto task = std::make_shared<std::packaged_task<RecognizeTakeoutOrderOutcome()>>(
693 [this, request]()
694 {
695 return this->recognizeTakeoutOrder(request);
696 });
697
698 asyncExecute(new Runnable([task]() { (*task)(); }));
699 return task->get_future();
700 }
701
recognizeTaxiInvoice(const RecognizeTaxiInvoiceRequest & request) const702 OcrClient::RecognizeTaxiInvoiceOutcome OcrClient::recognizeTaxiInvoice(const RecognizeTaxiInvoiceRequest &request) const
703 {
704 auto endpointOutcome = endpointProvider_->getEndpoint();
705 if (!endpointOutcome.isSuccess())
706 return RecognizeTaxiInvoiceOutcome(endpointOutcome.error());
707
708 auto outcome = makeRequest(endpointOutcome.result(), request);
709
710 if (outcome.isSuccess())
711 return RecognizeTaxiInvoiceOutcome(RecognizeTaxiInvoiceResult(outcome.result()));
712 else
713 return RecognizeTaxiInvoiceOutcome(outcome.error());
714 }
715
recognizeTaxiInvoiceAsync(const RecognizeTaxiInvoiceRequest & request,const RecognizeTaxiInvoiceAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const716 void OcrClient::recognizeTaxiInvoiceAsync(const RecognizeTaxiInvoiceRequest& request, const RecognizeTaxiInvoiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
717 {
718 auto fn = [this, request, handler, context]()
719 {
720 handler(this, request, recognizeTaxiInvoice(request), context);
721 };
722
723 asyncExecute(new Runnable(fn));
724 }
725
recognizeTaxiInvoiceCallable(const RecognizeTaxiInvoiceRequest & request) const726 OcrClient::RecognizeTaxiInvoiceOutcomeCallable OcrClient::recognizeTaxiInvoiceCallable(const RecognizeTaxiInvoiceRequest &request) const
727 {
728 auto task = std::make_shared<std::packaged_task<RecognizeTaxiInvoiceOutcome()>>(
729 [this, request]()
730 {
731 return this->recognizeTaxiInvoice(request);
732 });
733
734 asyncExecute(new Runnable([task]() { (*task)(); }));
735 return task->get_future();
736 }
737
recognizeTrainTicket(const RecognizeTrainTicketRequest & request) const738 OcrClient::RecognizeTrainTicketOutcome OcrClient::recognizeTrainTicket(const RecognizeTrainTicketRequest &request) const
739 {
740 auto endpointOutcome = endpointProvider_->getEndpoint();
741 if (!endpointOutcome.isSuccess())
742 return RecognizeTrainTicketOutcome(endpointOutcome.error());
743
744 auto outcome = makeRequest(endpointOutcome.result(), request);
745
746 if (outcome.isSuccess())
747 return RecognizeTrainTicketOutcome(RecognizeTrainTicketResult(outcome.result()));
748 else
749 return RecognizeTrainTicketOutcome(outcome.error());
750 }
751
recognizeTrainTicketAsync(const RecognizeTrainTicketRequest & request,const RecognizeTrainTicketAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const752 void OcrClient::recognizeTrainTicketAsync(const RecognizeTrainTicketRequest& request, const RecognizeTrainTicketAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
753 {
754 auto fn = [this, request, handler, context]()
755 {
756 handler(this, request, recognizeTrainTicket(request), context);
757 };
758
759 asyncExecute(new Runnable(fn));
760 }
761
recognizeTrainTicketCallable(const RecognizeTrainTicketRequest & request) const762 OcrClient::RecognizeTrainTicketOutcomeCallable OcrClient::recognizeTrainTicketCallable(const RecognizeTrainTicketRequest &request) const
763 {
764 auto task = std::make_shared<std::packaged_task<RecognizeTrainTicketOutcome()>>(
765 [this, request]()
766 {
767 return this->recognizeTrainTicket(request);
768 });
769
770 asyncExecute(new Runnable([task]() { (*task)(); }));
771 return task->get_future();
772 }
773
recognizeVATInvoice(const RecognizeVATInvoiceRequest & request) const774 OcrClient::RecognizeVATInvoiceOutcome OcrClient::recognizeVATInvoice(const RecognizeVATInvoiceRequest &request) const
775 {
776 auto endpointOutcome = endpointProvider_->getEndpoint();
777 if (!endpointOutcome.isSuccess())
778 return RecognizeVATInvoiceOutcome(endpointOutcome.error());
779
780 auto outcome = makeRequest(endpointOutcome.result(), request);
781
782 if (outcome.isSuccess())
783 return RecognizeVATInvoiceOutcome(RecognizeVATInvoiceResult(outcome.result()));
784 else
785 return RecognizeVATInvoiceOutcome(outcome.error());
786 }
787
recognizeVATInvoiceAsync(const RecognizeVATInvoiceRequest & request,const RecognizeVATInvoiceAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const788 void OcrClient::recognizeVATInvoiceAsync(const RecognizeVATInvoiceRequest& request, const RecognizeVATInvoiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
789 {
790 auto fn = [this, request, handler, context]()
791 {
792 handler(this, request, recognizeVATInvoice(request), context);
793 };
794
795 asyncExecute(new Runnable(fn));
796 }
797
recognizeVATInvoiceCallable(const RecognizeVATInvoiceRequest & request) const798 OcrClient::RecognizeVATInvoiceOutcomeCallable OcrClient::recognizeVATInvoiceCallable(const RecognizeVATInvoiceRequest &request) const
799 {
800 auto task = std::make_shared<std::packaged_task<RecognizeVATInvoiceOutcome()>>(
801 [this, request]()
802 {
803 return this->recognizeVATInvoice(request);
804 });
805
806 asyncExecute(new Runnable([task]() { (*task)(); }));
807 return task->get_future();
808 }
809
recognizeVINCode(const RecognizeVINCodeRequest & request) const810 OcrClient::RecognizeVINCodeOutcome OcrClient::recognizeVINCode(const RecognizeVINCodeRequest &request) const
811 {
812 auto endpointOutcome = endpointProvider_->getEndpoint();
813 if (!endpointOutcome.isSuccess())
814 return RecognizeVINCodeOutcome(endpointOutcome.error());
815
816 auto outcome = makeRequest(endpointOutcome.result(), request);
817
818 if (outcome.isSuccess())
819 return RecognizeVINCodeOutcome(RecognizeVINCodeResult(outcome.result()));
820 else
821 return RecognizeVINCodeOutcome(outcome.error());
822 }
823
recognizeVINCodeAsync(const RecognizeVINCodeRequest & request,const RecognizeVINCodeAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const824 void OcrClient::recognizeVINCodeAsync(const RecognizeVINCodeRequest& request, const RecognizeVINCodeAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
825 {
826 auto fn = [this, request, handler, context]()
827 {
828 handler(this, request, recognizeVINCode(request), context);
829 };
830
831 asyncExecute(new Runnable(fn));
832 }
833
recognizeVINCodeCallable(const RecognizeVINCodeRequest & request) const834 OcrClient::RecognizeVINCodeOutcomeCallable OcrClient::recognizeVINCodeCallable(const RecognizeVINCodeRequest &request) const
835 {
836 auto task = std::make_shared<std::packaged_task<RecognizeVINCodeOutcome()>>(
837 [this, request]()
838 {
839 return this->recognizeVINCode(request);
840 });
841
842 asyncExecute(new Runnable([task]() { (*task)(); }));
843 return task->get_future();
844 }
845
recognizeVerificationcode(const RecognizeVerificationcodeRequest & request) const846 OcrClient::RecognizeVerificationcodeOutcome OcrClient::recognizeVerificationcode(const RecognizeVerificationcodeRequest &request) const
847 {
848 auto endpointOutcome = endpointProvider_->getEndpoint();
849 if (!endpointOutcome.isSuccess())
850 return RecognizeVerificationcodeOutcome(endpointOutcome.error());
851
852 auto outcome = makeRequest(endpointOutcome.result(), request);
853
854 if (outcome.isSuccess())
855 return RecognizeVerificationcodeOutcome(RecognizeVerificationcodeResult(outcome.result()));
856 else
857 return RecognizeVerificationcodeOutcome(outcome.error());
858 }
859
recognizeVerificationcodeAsync(const RecognizeVerificationcodeRequest & request,const RecognizeVerificationcodeAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const860 void OcrClient::recognizeVerificationcodeAsync(const RecognizeVerificationcodeRequest& request, const RecognizeVerificationcodeAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
861 {
862 auto fn = [this, request, handler, context]()
863 {
864 handler(this, request, recognizeVerificationcode(request), context);
865 };
866
867 asyncExecute(new Runnable(fn));
868 }
869
recognizeVerificationcodeCallable(const RecognizeVerificationcodeRequest & request) const870 OcrClient::RecognizeVerificationcodeOutcomeCallable OcrClient::recognizeVerificationcodeCallable(const RecognizeVerificationcodeRequest &request) const
871 {
872 auto task = std::make_shared<std::packaged_task<RecognizeVerificationcodeOutcome()>>(
873 [this, request]()
874 {
875 return this->recognizeVerificationcode(request);
876 });
877
878 asyncExecute(new Runnable([task]() { (*task)(); }));
879 return task->get_future();
880 }
881
trimDocument(const TrimDocumentRequest & request) const882 OcrClient::TrimDocumentOutcome OcrClient::trimDocument(const TrimDocumentRequest &request) const
883 {
884 auto endpointOutcome = endpointProvider_->getEndpoint();
885 if (!endpointOutcome.isSuccess())
886 return TrimDocumentOutcome(endpointOutcome.error());
887
888 auto outcome = makeRequest(endpointOutcome.result(), request);
889
890 if (outcome.isSuccess())
891 return TrimDocumentOutcome(TrimDocumentResult(outcome.result()));
892 else
893 return TrimDocumentOutcome(outcome.error());
894 }
895
trimDocumentAsync(const TrimDocumentRequest & request,const TrimDocumentAsyncHandler & handler,const std::shared_ptr<const AsyncCallerContext> & context) const896 void OcrClient::trimDocumentAsync(const TrimDocumentRequest& request, const TrimDocumentAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
897 {
898 auto fn = [this, request, handler, context]()
899 {
900 handler(this, request, trimDocument(request), context);
901 };
902
903 asyncExecute(new Runnable(fn));
904 }
905
trimDocumentCallable(const TrimDocumentRequest & request) const906 OcrClient::TrimDocumentOutcomeCallable OcrClient::trimDocumentCallable(const TrimDocumentRequest &request) const
907 {
908 auto task = std::make_shared<std::packaged_task<TrimDocumentOutcome()>>(
909 [this, request]()
910 {
911 return this->trimDocument(request);
912 });
913
914 asyncExecute(new Runnable([task]() { (*task)(); }));
915 return task->get_future();
916 }
917
918