-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrecognize_api.py
More file actions
352 lines (296 loc) · 14.5 KB
/
recognize_api.py
File metadata and controls
352 lines (296 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# coding: utf-8
import re # noqa: F401
import warnings # noqa: F401
from aspose_barcode_cloud.api_client import ApiClient
class RecognizeApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/OpenAPITools/openapi-generator
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
# Authentication setting
self.auth_settings = ["JWT"]
def recognize(
self, barcode_type, file_url, recognition_mode=None, recognition_image_kind=None, async_req=False, **kwargs
):
"""Recognize barcode from file on server in the Internet using GET requests with parameter in query string. For recognizing files from your hard drive use `recognize-body` or `recognize-multipart` endpoints instead.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = RecognizeApi().recognize(barcode_type, file_url, async_req=True)
>>> result = thread.get()
:param DecodeBarcodeType barcode_type: Type of barcode to recognize # noqa: E501
:param str file_url: Url to barcode image # noqa: E501
:param RecognitionMode recognition_mode: Recognition mode # noqa: E501
:param RecognitionImageKind recognition_image_kind: Image kind for recognition # noqa: E501
:param async_req bool
:return: BarcodeResponseList
If the method is called asynchronously,
returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if async_req:
return self.recognize_with_http_info(
barcode_type,
file_url,
recognition_mode=recognition_mode,
recognition_image_kind=recognition_image_kind,
**kwargs
)
else:
(data) = self.recognize_with_http_info(
barcode_type,
file_url,
recognition_mode=recognition_mode,
recognition_image_kind=recognition_image_kind,
**kwargs
)
return data
def recognize_with_http_info(self, barcode_type, file_url, **kwargs):
"""Recognize barcode from file on server in the Internet using GET requests with parameter in query string. For recognizing files from your hard drive use `recognize-body` or `recognize-multipart` endpoints instead.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = RecognizeApi().recognize_with_http_info(barcode_type, file_url, async_req=True)
>>> result = thread.get()
:param DecodeBarcodeType barcode_type: Type of barcode to recognize # noqa: E501
:param str file_url: Url to barcode image # noqa: E501
:return: BarcodeResponseList
If the method is called asynchronously,
returns the request thread.
"""
all_params = {"barcode_type", "file_url", "recognition_mode", "recognition_image_kind"}
all_params.add("async_req")
all_params.add("_return_http_data_only")
all_params.add("_preload_content")
all_params.add("_request_timeout")
params = locals()
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method recognize" % key)
if val is None:
continue
params[key] = val
del params["kwargs"]
# verify the required parameter "barcode_type" is set
if "barcode_type" not in params or params["barcode_type"] is None:
raise ValueError("Missing the required parameter 'barcode_type' when calling 'recognize'")
# verify the required parameter "file_url" is set
if "file_url" not in params or params["file_url"] is None:
raise ValueError("Missing the required parameter 'file_url' when calling 'recognize'")
collection_formats = {}
path_params = {}
query_params = []
if "barcode_type" in params:
query_params.append(("barcodeType", params["barcode_type"]))
if "file_url" in params:
query_params.append(("fileUrl", params["file_url"]))
if "recognition_mode" in params:
query_params.append(("recognitionMode", params["recognition_mode"]))
if "recognition_image_kind" in params:
query_params.append(("recognitionImageKind", params["recognition_image_kind"]))
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header "Accept"
header_params["Accept"] = self.api_client.select_header_accept(["application/json", "application/xml"])
return self.api_client.call_api(
"/barcode/recognize",
"GET",
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type="BarcodeResponseList",
auth_settings=self.auth_settings,
async_req=params.get("async_req"),
_return_http_data_only=params.get("_return_http_data_only"),
_preload_content=params.get("_preload_content", True),
_request_timeout=params.get("_request_timeout"),
collection_formats=collection_formats,
)
def recognize_base64(self, recognize_base64_request, async_req=False, **kwargs):
"""Recognize barcode from file in request body using POST requests with parameters in body in json or xml format.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = RecognizeApi().recognize_base64(recognize_base64_request, async_req=True)
>>> result = thread.get()
:param RecognizeBase64Request recognize_base64_request: Barcode recognition request # noqa: E501
:param async_req bool
:return: BarcodeResponseList
If the method is called asynchronously,
returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if async_req:
return self.recognize_base64_with_http_info(recognize_base64_request, **kwargs)
else:
(data) = self.recognize_base64_with_http_info(recognize_base64_request, **kwargs)
return data
def recognize_base64_with_http_info(self, recognize_base64_request, **kwargs):
"""Recognize barcode from file in request body using POST requests with parameters in body in json or xml format.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = RecognizeApi().recognize_base64_with_http_info(recognize_base64_request, async_req=True)
>>> result = thread.get()
:param RecognizeBase64Request recognize_base64_request: Barcode recognition request # noqa: E501
:return: BarcodeResponseList
If the method is called asynchronously,
returns the request thread.
"""
all_params = {"recognize_base64_request"}
all_params.add("async_req")
all_params.add("_return_http_data_only")
all_params.add("_preload_content")
all_params.add("_request_timeout")
params = locals()
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method recognize_base64" % key)
if val is None:
continue
params[key] = val
del params["kwargs"]
# verify the required parameter "recognize_base64_request" is set
if "recognize_base64_request" not in params or params["recognize_base64_request"] is None:
raise ValueError(
"Missing the required parameter 'recognize_base64_request' when calling 'recognize_base64'"
)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if "recognize_base64_request" in params:
body_params = params["recognize_base64_request"]
# HTTP header "Accept"
header_params["Accept"] = self.api_client.select_header_accept(["application/json", "application/xml"])
# HTTP header "Content-Type"
header_params["Content-Type"] = self.api_client.select_header_content_type(
["application/json", "application/xml"]
)
return self.api_client.call_api(
"/barcode/recognize-body",
"POST",
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type="BarcodeResponseList",
auth_settings=self.auth_settings,
async_req=params.get("async_req"),
_return_http_data_only=params.get("_return_http_data_only"),
_preload_content=params.get("_preload_content", True),
_request_timeout=params.get("_request_timeout"),
collection_formats=collection_formats,
)
def recognize_multipart(
self, barcode_type, file, recognition_mode=None, recognition_image_kind=None, async_req=False, **kwargs
):
"""Recognize barcode from file in request body using POST requests with parameters in multipart form.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = RecognizeApi().recognize_multipart(barcode_type, file, async_req=True)
>>> result = thread.get()
:param DecodeBarcodeType barcode_type: # noqa: E501
:param bytearray file: Barcode image file # noqa: E501
:param RecognitionMode recognition_mode: # noqa: E501
:param RecognitionImageKind recognition_image_kind: # noqa: E501
:param async_req bool
:return: BarcodeResponseList
If the method is called asynchronously,
returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if async_req:
return self.recognize_multipart_with_http_info(
barcode_type,
file,
recognition_mode=recognition_mode,
recognition_image_kind=recognition_image_kind,
**kwargs
)
else:
(data) = self.recognize_multipart_with_http_info(
barcode_type,
file,
recognition_mode=recognition_mode,
recognition_image_kind=recognition_image_kind,
**kwargs
)
return data
def recognize_multipart_with_http_info(self, barcode_type, file, **kwargs):
"""Recognize barcode from file in request body using POST requests with parameters in multipart form.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = RecognizeApi().recognize_multipart_with_http_info(barcode_type, file, async_req=True)
>>> result = thread.get()
:param DecodeBarcodeType barcode_type: # noqa: E501
:param bytearray file: Barcode image file # noqa: E501
:return: BarcodeResponseList
If the method is called asynchronously,
returns the request thread.
"""
all_params = {"barcode_type", "file", "recognition_mode", "recognition_image_kind"}
all_params.add("async_req")
all_params.add("_return_http_data_only")
all_params.add("_preload_content")
all_params.add("_request_timeout")
params = locals()
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method recognize_multipart" % key)
if val is None:
continue
params[key] = val
del params["kwargs"]
# verify the required parameter "barcode_type" is set
if "barcode_type" not in params or params["barcode_type"] is None:
raise ValueError("Missing the required parameter 'barcode_type' when calling 'recognize_multipart'")
# verify the required parameter "file" is set
if "file" not in params or params["file"] is None:
raise ValueError("Missing the required parameter 'file' when calling 'recognize_multipart'")
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
if "barcode_type" in params:
form_params.append(("barcodeType", params["barcode_type"]))
if "file" in params:
local_var_files["file"] = params["file"]
if "recognition_mode" in params:
form_params.append(("recognitionMode", params["recognition_mode"]))
if "recognition_image_kind" in params:
form_params.append(("recognitionImageKind", params["recognition_image_kind"]))
body_params = None
# HTTP header "Accept"
header_params["Accept"] = self.api_client.select_header_accept(["application/json", "application/xml"])
# HTTP header "Content-Type"
header_params["Content-Type"] = self.api_client.select_header_content_type(["multipart/form-data"])
return self.api_client.call_api(
"/barcode/recognize-multipart",
"POST",
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type="BarcodeResponseList",
auth_settings=self.auth_settings,
async_req=params.get("async_req"),
_return_http_data_only=params.get("_return_http_data_only"),
_preload_content=params.get("_preload_content", True),
_request_timeout=params.get("_request_timeout"),
collection_formats=collection_formats,
)