-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate_api.py
More file actions
533 lines (477 loc) · 22.2 KB
/
generate_api.py
File metadata and controls
533 lines (477 loc) · 22.2 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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# coding: utf-8
import re # noqa: F401
import warnings # noqa: F401
from aspose_barcode_cloud.api_client import ApiClient
class GenerateApi(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 generate(
self,
barcode_type,
data,
data_type=None,
image_format=None,
text_location=None,
foreground_color="Black",
background_color="White",
units=None,
resolution=None,
image_height=None,
image_width=None,
rotation_angle=None,
async_req=False,
**kwargs
):
"""Generate barcode using GET request with parameters in route and query string.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = GenerateApi().generate(barcode_type, data, async_req=True)
>>> result = thread.get()
:param EncodeBarcodeType barcode_type: Type of barcode to generate. # noqa: E501
:param str data: String represents data to encode # noqa: E501
:param EncodeDataType data_type: Type of data to encode. Default value: StringData. # noqa: E501
:param BarcodeImageFormat image_format: Barcode output image format. Default value: png # noqa: E501
:param CodeLocation text_location: Specify the displaying Text Location, set to CodeLocation.None to hide CodeText. Default value: Depends on BarcodeType. CodeLocation.Below for 1D Barcodes. CodeLocation.None for 2D Barcodes. # noqa: E501
:param str foreground_color: Specify the displaying bars and content Color. Value: Color name from https://reference.aspose.com/drawing/net/system.drawing/color/ or ARGB value started with #. For example: AliceBlue or #FF000000 Default value: Black. # noqa: E501
:param str background_color: Background color of the barcode image. Value: Color name from https://reference.aspose.com/drawing/net/system.drawing/color/ or ARGB value started with #. For example: AliceBlue or #FF000000 Default value: White. # noqa: E501
:param GraphicsUnit units: Common Units for all measuring in query. Default units: pixel. # noqa: E501
:param float resolution: Resolution of the BarCode image. One value for both dimensions. Default value: 96 dpi. Decimal separator is dot. # noqa: E501
:param float image_height: Height of the barcode image in given units. Default units: pixel. Decimal separator is dot. # noqa: E501
:param float image_width: Width of the barcode image in given units. Default units: pixel. Decimal separator is dot. # noqa: E501
:param int rotation_angle: BarCode image rotation angle, measured in degree, e.g. RotationAngle = 0 or RotationAngle = 360 means no rotation. If RotationAngle NOT equal to 90, 180, 270 or 0, it may increase the difficulty for the scanner to read the image. Default value: 0. # noqa: E501
:param async_req bool
:return: bytearray
If the method is called asynchronously,
returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if async_req:
return self.generate_with_http_info(
barcode_type,
data,
data_type=data_type,
image_format=image_format,
text_location=text_location,
foreground_color=foreground_color,
background_color=background_color,
units=units,
resolution=resolution,
image_height=image_height,
image_width=image_width,
rotation_angle=rotation_angle,
**kwargs
)
else:
data = self.generate_with_http_info(
barcode_type,
data,
data_type=data_type,
image_format=image_format,
text_location=text_location,
foreground_color=foreground_color,
background_color=background_color,
units=units,
resolution=resolution,
image_height=image_height,
image_width=image_width,
rotation_angle=rotation_angle,
**kwargs
)
return data
def generate_with_http_info(self, barcode_type, data, **kwargs):
"""Generate barcode using GET request with parameters in route and query string.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = GenerateApi().generate_with_http_info(barcode_type, data, async_req=True)
>>> result = thread.get()
:param EncodeBarcodeType barcode_type: Type of barcode to generate. # noqa: E501
:param str data: String represents data to encode # noqa: E501
:return: bytearray
If the method is called asynchronously,
returns the request thread.
"""
all_params = {
"barcode_type",
"data",
"data_type",
"image_format",
"text_location",
"foreground_color",
"background_color",
"units",
"resolution",
"image_height",
"image_width",
"rotation_angle",
}
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 generate" % 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 'generate'")
# verify the required parameter "data" is set
if "data" not in params or params["data"] is None:
raise ValueError("Missing the required parameter 'data' when calling 'generate'")
if "resolution" in params and params["resolution"] > 100000:
raise ValueError(
"Invalid value for parameter 'resolution' when calling 'generate', must be a value less than or equal to '100000'"
)
if "resolution" in params and params["resolution"] < 1:
raise ValueError(
"Invalid value for parameter 'resolution' when calling 'generate', must be a value greater than or equal to '1'"
)
collection_formats = {}
path_params = {}
if "barcode_type" in params:
path_params["barcodeType"] = params["barcode_type"]
query_params = []
if "data_type" in params:
query_params.append(("dataType", params["data_type"]))
if "data" in params:
query_params.append(("data", params["data"]))
if "image_format" in params:
query_params.append(("imageFormat", params["image_format"]))
if "text_location" in params:
query_params.append(("textLocation", params["text_location"]))
if "foreground_color" in params:
query_params.append(("foregroundColor", params["foreground_color"]))
if "background_color" in params:
query_params.append(("backgroundColor", params["background_color"]))
if "units" in params:
query_params.append(("units", params["units"]))
if "resolution" in params:
query_params.append(("resolution", params["resolution"]))
if "image_height" in params:
query_params.append(("imageHeight", params["image_height"]))
if "image_width" in params:
query_params.append(("imageWidth", params["image_width"]))
if "rotation_angle" in params:
query_params.append(("rotationAngle", params["rotation_angle"]))
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header "Accept"
header_params["Accept"] = self.api_client.select_header_accept(
[
"image/png",
"image/bmp",
"image/gif",
"image/jpeg",
"image/svg+xml",
"image/tiff",
"application/json",
"application/xml",
]
)
return self.api_client.call_api(
"/barcode/generate/{barcodeType}",
"GET",
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type="bytearray",
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", False),
_request_timeout=params.get("_request_timeout"),
collection_formats=collection_formats,
)
def generate_body(self, generate_params, async_req=False, **kwargs):
"""Generate barcode using POST request 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 = GenerateApi().generate_body(generate_params, async_req=True)
>>> result = thread.get()
:param GenerateParams generate_params: Parameters of generation # noqa: E501
:param async_req bool
:return: bytearray
If the method is called asynchronously,
returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if async_req:
return self.generate_body_with_http_info(generate_params, **kwargs)
else:
data = self.generate_body_with_http_info(generate_params, **kwargs)
return data
def generate_body_with_http_info(self, generate_params, **kwargs):
"""Generate barcode using POST request 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 = GenerateApi().generate_body_with_http_info(generate_params, async_req=True)
>>> result = thread.get()
:param GenerateParams generate_params: Parameters of generation # noqa: E501
:return: bytearray
If the method is called asynchronously,
returns the request thread.
"""
all_params = {"generate_params"}
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 generate_body" % key)
if val is None:
continue
params[key] = val
del params["kwargs"]
# verify the required parameter "generate_params" is set
if "generate_params" not in params or params["generate_params"] is None:
raise ValueError("Missing the required parameter 'generate_params' when calling 'generate_body'")
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if "generate_params" in params:
body_params = params["generate_params"]
# HTTP header "Accept"
header_params["Accept"] = self.api_client.select_header_accept(
[
"image/png",
"image/bmp",
"image/gif",
"image/jpeg",
"image/svg+xml",
"image/tiff",
"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/generate-body",
"POST",
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type="bytearray",
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", False),
_request_timeout=params.get("_request_timeout"),
collection_formats=collection_formats,
)
def generate_multipart(
self,
barcode_type,
data,
data_type=None,
image_format=None,
text_location=None,
foreground_color="Black",
background_color="White",
units=None,
resolution=None,
image_height=None,
image_width=None,
rotation_angle=None,
async_req=False,
**kwargs
):
"""Generate barcode using POST request 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 = GenerateApi().generate_multipart(barcode_type, data, async_req=True)
>>> result = thread.get()
:param EncodeBarcodeType barcode_type: # noqa: E501
:param str data: String represents data to encode # noqa: E501
:param EncodeDataType data_type: # noqa: E501
:param BarcodeImageFormat image_format: # noqa: E501
:param CodeLocation text_location: # noqa: E501
:param str foreground_color: Specify the displaying bars and content Color. Value: Color name from https://reference.aspose.com/drawing/net/system.drawing/color/ or ARGB value started with #. For example: AliceBlue or #FF000000 Default value: Black. # noqa: E501
:param str background_color: Background color of the barcode image. Value: Color name from https://reference.aspose.com/drawing/net/system.drawing/color/ or ARGB value started with #. For example: AliceBlue or #FF000000 Default value: White. # noqa: E501
:param GraphicsUnit units: # noqa: E501
:param float resolution: Resolution of the BarCode image. One value for both dimensions. Default value: 96 dpi. Decimal separator is dot. # noqa: E501
:param float image_height: Height of the barcode image in given units. Default units: pixel. Decimal separator is dot. # noqa: E501
:param float image_width: Width of the barcode image in given units. Default units: pixel. Decimal separator is dot. # noqa: E501
:param int rotation_angle: BarCode image rotation angle, measured in degree, e.g. RotationAngle = 0 or RotationAngle = 360 means no rotation. If RotationAngle NOT equal to 90, 180, 270 or 0, it may increase the difficulty for the scanner to read the image. Default value: 0. # noqa: E501
:param async_req bool
:return: bytearray
If the method is called asynchronously,
returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if async_req:
return self.generate_multipart_with_http_info(
barcode_type,
data,
data_type=data_type,
image_format=image_format,
text_location=text_location,
foreground_color=foreground_color,
background_color=background_color,
units=units,
resolution=resolution,
image_height=image_height,
image_width=image_width,
rotation_angle=rotation_angle,
**kwargs
)
else:
data = self.generate_multipart_with_http_info(
barcode_type,
data,
data_type=data_type,
image_format=image_format,
text_location=text_location,
foreground_color=foreground_color,
background_color=background_color,
units=units,
resolution=resolution,
image_height=image_height,
image_width=image_width,
rotation_angle=rotation_angle,
**kwargs
)
return data
def generate_multipart_with_http_info(self, barcode_type, data, **kwargs):
"""Generate barcode using POST request 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 = GenerateApi().generate_multipart_with_http_info(barcode_type, data, async_req=True)
>>> result = thread.get()
:param EncodeBarcodeType barcode_type: # noqa: E501
:param str data: String represents data to encode # noqa: E501
:return: bytearray
If the method is called asynchronously,
returns the request thread.
"""
all_params = {
"barcode_type",
"data",
"data_type",
"image_format",
"text_location",
"foreground_color",
"background_color",
"units",
"resolution",
"image_height",
"image_width",
"rotation_angle",
}
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 generate_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 'generate_multipart'")
# verify the required parameter "data" is set
if "data" not in params or params["data"] is None:
raise ValueError("Missing the required parameter 'data' when calling 'generate_multipart'")
if "resolution" in params and params["resolution"] > 100000:
raise ValueError(
"Invalid value for parameter 'resolution' when calling 'generate_multipart', must be a value less than or equal to '100000'"
)
if "resolution" in params and params["resolution"] < 1:
raise ValueError(
"Invalid value for parameter 'resolution' when calling 'generate_multipart', must be a value greater than or equal to '1'"
)
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 "data_type" in params:
form_params.append(("dataType", params["data_type"]))
if "data" in params:
form_params.append(("data", params["data"]))
if "image_format" in params:
form_params.append(("imageFormat", params["image_format"]))
if "text_location" in params:
form_params.append(("textLocation", params["text_location"]))
if "foreground_color" in params:
form_params.append(("foregroundColor", params["foreground_color"]))
if "background_color" in params:
form_params.append(("backgroundColor", params["background_color"]))
if "units" in params:
form_params.append(("units", params["units"]))
if "resolution" in params:
form_params.append(("resolution", params["resolution"]))
if "image_height" in params:
form_params.append(("imageHeight", params["image_height"]))
if "image_width" in params:
form_params.append(("imageWidth", params["image_width"]))
if "rotation_angle" in params:
form_params.append(("rotationAngle", params["rotation_angle"]))
body_params = None
# HTTP header "Accept"
header_params["Accept"] = self.api_client.select_header_accept(
[
"image/png",
"image/bmp",
"image/gif",
"image/jpeg",
"image/svg+xml",
"image/tiff",
"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/generate-multipart",
"POST",
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type="bytearray",
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", False),
_request_timeout=params.get("_request_timeout"),
collection_formats=collection_formats,
)