aspose-barcode-cloud-node 25.1.0 → 25.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1646 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var http = require('http');
6
- var https = require('https');
7
- var crypto = require('crypto');
8
-
9
- class HttpClient {
10
- requestAsync(options) {
11
- const url = options.qs ? new URL(`?${new URLSearchParams(options.qs).toString()}`, options.uri) : new URL(options.uri);
12
- const requestBody = this.buildRequestBody(options);
13
- const requestOptions = {
14
- method: options.method,
15
- headers: options.headers
16
- };
17
- const responseEncoding = options.encoding === null ? null : options.encoding || 'utf-8';
18
- return this.doHttpRequest(url, requestBody, requestOptions, responseEncoding);
19
- }
20
- buildRequestBody(options) {
21
- let requestBody = options.body;
22
- if (options.form) {
23
- // Override requestBody for form with form content
24
- requestBody = new URLSearchParams(options.form).toString();
25
- options.headers = Object.assign({
26
- 'Content-Type': 'application/x-www-form-urlencoded'
27
- }, options.headers);
28
- }
29
- if (options.json) {
30
- // Override requestBody with JSON value
31
- requestBody = JSON.stringify(options.body);
32
- options.headers = Object.assign({
33
- 'Content-Type': 'application/json'
34
- }, options.headers);
35
- }
36
- return requestBody;
37
- }
38
- doHttpRequest(url, requestBody, requestOptions, responseEncoding) {
39
- return new Promise((resolve, reject) => {
40
- function requestCallback(res) {
41
- if (responseEncoding) {
42
- // encoding = null for binary responses
43
- res.setEncoding(responseEncoding);
44
- }
45
- const chunks = [];
46
- res.on('data', chunk => {
47
- chunks.push(chunk);
48
- });
49
- res.on('end', () => {
50
- const respBody = responseEncoding ? chunks.join('') : Buffer.concat(chunks);
51
- const response = {
52
- statusCode: res.statusCode,
53
- statusMessage: res.statusMessage,
54
- headers: res.headers,
55
- body: respBody
56
- };
57
- if (response.statusCode >= 200 && response.statusCode <= 299) {
58
- resolve({
59
- response: response,
60
- body: respBody
61
- });
62
- } else {
63
- var rejectObject = {
64
- response: response,
65
- error: new Error(`Error on '${url}': ${res.statusCode} ${res.statusMessage}`),
66
- errorResponse: null
67
- };
68
- var errorResponse = null;
69
- try {
70
- errorResponse = JSON.parse(respBody.toString());
71
- } catch (parseError) {}
72
- if (errorResponse) {
73
- rejectObject.errorResponse = errorResponse;
74
- } else {
75
- rejectObject.error.message += `. ${respBody}`;
76
- }
77
- reject(rejectObject);
78
- }
79
- });
80
- }
81
- const req = url.protocol === 'http:' ? http.request(url, requestOptions, requestCallback) : https.request(url, requestOptions, requestCallback);
82
- req.on('error', error => {
83
- reject({
84
- response: null,
85
- error: error,
86
- errorResponse: null
87
- });
88
- });
89
- if (requestBody) {
90
- req.write(requestBody);
91
- }
92
- req.end();
93
- });
94
- }
95
- }
96
-
97
- class RequestFile {
98
- constructor(name, filename, data, contentType) {
99
- this.name = void 0;
100
- this.filename = void 0;
101
- this.data = void 0;
102
- this.contentType = void 0;
103
- this.name = name;
104
- this.filename = filename;
105
- this.data = data;
106
- this.contentType = contentType;
107
- }
108
- }
109
- class Multipart {
110
- constructor(textFields, files) {
111
- this.boundary = void 0;
112
- this.body = void 0;
113
- this.headers = void 0;
114
- const random = crypto.randomUUID();
115
- this.boundary = '------------------------' + random.replace(/-/g, '');
116
- const bodyLines = [];
117
- for (const tuple of textFields) {
118
- bodyLines.push(`--${this.boundary}`);
119
- bodyLines.push(`Content-Disposition: form-data; name="${tuple[0]}"`);
120
- bodyLines.push('');
121
- bodyLines.push(tuple[1]);
122
- }
123
- for (const file of files || []) {
124
- bodyLines.push(`--${this.boundary}`);
125
- bodyLines.push(`Content-Disposition: form-data; name="${file.name}"; filename="${file.filename || 'filename'}"`);
126
- bodyLines.push(`Content-Type: ${file.contentType || 'application/octet-stream'}`);
127
- bodyLines.push('');
128
- bodyLines.push(file.data.toString('binary'));
129
- }
130
- bodyLines.push(`--${this.boundary}--`);
131
- this.body = Buffer.from(bodyLines.join('\r\n'), 'binary');
132
- this.headers = {
133
- 'Content-Type': `multipart/form-data; boundary=${this.boundary}`,
134
- 'Content-Length': this.body.length.toString()
135
- };
136
- }
137
- }
138
-
139
- /**
140
- * Api Error.
141
- */
142
- class ApiError {
143
- constructor() {
144
- /**
145
- * Gets or sets api error code.
146
- */
147
- this['code'] = void 0;
148
- /**
149
- * Gets or sets error message.
150
- */
151
- this['message'] = void 0;
152
- /**
153
- * Gets or sets error description.
154
- */
155
- this['description'] = void 0;
156
- /**
157
- * Gets or sets server datetime.
158
- */
159
- this['dateTime'] = void 0;
160
- this['innerError'] = void 0;
161
- }
162
- static getAttributeTypeMap() {
163
- return ApiError.attributeTypeMap;
164
- }
165
- }
166
- /**
167
- * ApiError Response
168
- */
169
- ApiError.attributeTypeMap = [{
170
- name: 'code',
171
- baseName: 'code',
172
- type: 'string'
173
- }, {
174
- name: 'message',
175
- baseName: 'message',
176
- type: 'string'
177
- }, {
178
- name: 'description',
179
- baseName: 'description',
180
- type: 'string'
181
- }, {
182
- name: 'dateTime',
183
- baseName: 'dateTime',
184
- type: 'Date'
185
- }, {
186
- name: 'innerError',
187
- baseName: 'innerError',
188
- type: 'ApiError'
189
- }];
190
- class ApiErrorResponse {
191
- constructor() {
192
- /**
193
- * Gets or sets request Id.
194
- */
195
- this['requestId'] = void 0;
196
- this['error'] = void 0;
197
- }
198
- static getAttributeTypeMap() {
199
- return ApiErrorResponse.attributeTypeMap;
200
- }
201
- }
202
- /**
203
- * Specifies the file format of the image.
204
- */
205
- ApiErrorResponse.attributeTypeMap = [{
206
- name: 'requestId',
207
- baseName: 'requestId',
208
- type: 'string'
209
- }, {
210
- name: 'error',
211
- baseName: 'error',
212
- type: 'ApiError'
213
- }];
214
- exports.BarcodeImageFormat = void 0;
215
- (function (BarcodeImageFormat) {
216
- BarcodeImageFormat["Png"] = "Png";
217
- BarcodeImageFormat["Jpeg"] = "Jpeg";
218
- BarcodeImageFormat["Svg"] = "Svg";
219
- BarcodeImageFormat["Tiff"] = "Tiff";
220
- BarcodeImageFormat["Gif"] = "Gif";
221
- })(exports.BarcodeImageFormat || (exports.BarcodeImageFormat = {}));
222
- /**
223
- * Barcode image optional parameters
224
- */
225
- class BarcodeImageParams {
226
- constructor() {
227
- this['imageFormat'] = void 0;
228
- this['textLocation'] = void 0;
229
- /**
230
- * 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.
231
- */
232
- this['foregroundColor'] = void 0;
233
- /**
234
- * 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.
235
- */
236
- this['backgroundColor'] = void 0;
237
- this['units'] = void 0;
238
- /**
239
- * Resolution of the BarCode image. One value for both dimensions. Default value: 96 dpi. Decimal separator is dot.
240
- */
241
- this['resolution'] = void 0;
242
- /**
243
- * Height of the barcode image in given units. Default units: pixel. Decimal separator is dot.
244
- */
245
- this['imageHeight'] = void 0;
246
- /**
247
- * Width of the barcode image in given units. Default units: pixel. Decimal separator is dot.
248
- */
249
- this['imageWidth'] = void 0;
250
- /**
251
- * 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.
252
- */
253
- this['rotationAngle'] = void 0;
254
- }
255
- static getAttributeTypeMap() {
256
- return BarcodeImageParams.attributeTypeMap;
257
- }
258
- }
259
- /**
260
- * Represents information about barcode.
261
- */
262
- BarcodeImageParams.attributeTypeMap = [{
263
- name: 'imageFormat',
264
- baseName: 'imageFormat',
265
- type: 'BarcodeImageFormat'
266
- }, {
267
- name: 'textLocation',
268
- baseName: 'textLocation',
269
- type: 'CodeLocation'
270
- }, {
271
- name: 'foregroundColor',
272
- baseName: 'foregroundColor',
273
- type: 'string'
274
- }, {
275
- name: 'backgroundColor',
276
- baseName: 'backgroundColor',
277
- type: 'string'
278
- }, {
279
- name: 'units',
280
- baseName: 'units',
281
- type: 'GraphicsUnit'
282
- }, {
283
- name: 'resolution',
284
- baseName: 'resolution',
285
- type: 'number'
286
- }, {
287
- name: 'imageHeight',
288
- baseName: 'imageHeight',
289
- type: 'number'
290
- }, {
291
- name: 'imageWidth',
292
- baseName: 'imageWidth',
293
- type: 'number'
294
- }, {
295
- name: 'rotationAngle',
296
- baseName: 'rotationAngle',
297
- type: 'number'
298
- }];
299
- class BarcodeResponse {
300
- constructor() {
301
- /**
302
- * Barcode data.
303
- */
304
- this['barcodeValue'] = void 0;
305
- /**
306
- * Type of the barcode.
307
- */
308
- this['type'] = void 0;
309
- /**
310
- * Region with barcode.
311
- */
312
- this['region'] = void 0;
313
- /**
314
- * Checksum of barcode.
315
- */
316
- this['checksum'] = void 0;
317
- }
318
- static getAttributeTypeMap() {
319
- return BarcodeResponse.attributeTypeMap;
320
- }
321
- }
322
- /**
323
- * Represents information about barcode list.
324
- */
325
- BarcodeResponse.attributeTypeMap = [{
326
- name: 'barcodeValue',
327
- baseName: 'barcodeValue',
328
- type: 'string'
329
- }, {
330
- name: 'type',
331
- baseName: 'type',
332
- type: 'string'
333
- }, {
334
- name: 'region',
335
- baseName: 'region',
336
- type: 'Array<RegionPoint>'
337
- }, {
338
- name: 'checksum',
339
- baseName: 'checksum',
340
- type: 'string'
341
- }];
342
- class BarcodeResponseList {
343
- constructor() {
344
- /**
345
- * List of barcodes which are present in image.
346
- */
347
- this['barcodes'] = void 0;
348
- }
349
- static getAttributeTypeMap() {
350
- return BarcodeResponseList.attributeTypeMap;
351
- }
352
- }
353
- BarcodeResponseList.attributeTypeMap = [{
354
- name: 'barcodes',
355
- baseName: 'barcodes',
356
- type: 'Array<BarcodeResponse>'
357
- }];
358
- exports.CodeLocation = void 0;
359
- (function (CodeLocation) {
360
- CodeLocation["Below"] = "Below";
361
- CodeLocation["Above"] = "Above";
362
- CodeLocation["None"] = "None";
363
- })(exports.CodeLocation || (exports.CodeLocation = {}));
364
- /**
365
- * See Aspose.BarCode.Aspose.BarCode.BarCodeRecognition.DecodeType
366
- */
367
- exports.DecodeBarcodeType = void 0;
368
- (function (DecodeBarcodeType) {
369
- DecodeBarcodeType["MostCommonlyUsed"] = "MostCommonlyUsed";
370
- DecodeBarcodeType["Qr"] = "QR";
371
- DecodeBarcodeType["AustraliaPost"] = "AustraliaPost";
372
- DecodeBarcodeType["AustralianPosteParcel"] = "AustralianPosteParcel";
373
- DecodeBarcodeType["Aztec"] = "Aztec";
374
- DecodeBarcodeType["Codabar"] = "Codabar";
375
- DecodeBarcodeType["CodablockF"] = "CodablockF";
376
- DecodeBarcodeType["Code11"] = "Code11";
377
- DecodeBarcodeType["Code128"] = "Code128";
378
- DecodeBarcodeType["Code16K"] = "Code16K";
379
- DecodeBarcodeType["Code32"] = "Code32";
380
- DecodeBarcodeType["Code39"] = "Code39";
381
- DecodeBarcodeType["Code39FullAscii"] = "Code39FullASCII";
382
- DecodeBarcodeType["Code93"] = "Code93";
383
- DecodeBarcodeType["CompactPdf417"] = "CompactPdf417";
384
- DecodeBarcodeType["DataLogic2of5"] = "DataLogic2of5";
385
- DecodeBarcodeType["DataMatrix"] = "DataMatrix";
386
- DecodeBarcodeType["DatabarExpanded"] = "DatabarExpanded";
387
- DecodeBarcodeType["DatabarExpandedStacked"] = "DatabarExpandedStacked";
388
- DecodeBarcodeType["DatabarLimited"] = "DatabarLimited";
389
- DecodeBarcodeType["DatabarOmniDirectional"] = "DatabarOmniDirectional";
390
- DecodeBarcodeType["DatabarStacked"] = "DatabarStacked";
391
- DecodeBarcodeType["DatabarStackedOmniDirectional"] = "DatabarStackedOmniDirectional";
392
- DecodeBarcodeType["DatabarTruncated"] = "DatabarTruncated";
393
- DecodeBarcodeType["DeutschePostIdentcode"] = "DeutschePostIdentcode";
394
- DecodeBarcodeType["DeutschePostLeitcode"] = "DeutschePostLeitcode";
395
- DecodeBarcodeType["DotCode"] = "DotCode";
396
- DecodeBarcodeType["DutchKix"] = "DutchKIX";
397
- DecodeBarcodeType["Ean13"] = "EAN13";
398
- DecodeBarcodeType["Ean14"] = "EAN14";
399
- DecodeBarcodeType["Ean8"] = "EAN8";
400
- DecodeBarcodeType["Gs1Aztec"] = "GS1Aztec";
401
- DecodeBarcodeType["Gs1Code128"] = "GS1Code128";
402
- DecodeBarcodeType["Gs1CompositeBar"] = "GS1CompositeBar";
403
- DecodeBarcodeType["Gs1DataMatrix"] = "GS1DataMatrix";
404
- DecodeBarcodeType["Gs1DotCode"] = "GS1DotCode";
405
- DecodeBarcodeType["Gs1HanXin"] = "GS1HanXin";
406
- DecodeBarcodeType["Gs1MicroPdf417"] = "GS1MicroPdf417";
407
- DecodeBarcodeType["Gs1Qr"] = "GS1QR";
408
- DecodeBarcodeType["HanXin"] = "HanXin";
409
- DecodeBarcodeType["HibcAztecLic"] = "HIBCAztecLIC";
410
- DecodeBarcodeType["HibcAztecPas"] = "HIBCAztecPAS";
411
- DecodeBarcodeType["HibcCode128Lic"] = "HIBCCode128LIC";
412
- DecodeBarcodeType["HibcCode128Pas"] = "HIBCCode128PAS";
413
- DecodeBarcodeType["HibcCode39Lic"] = "HIBCCode39LIC";
414
- DecodeBarcodeType["HibcCode39Pas"] = "HIBCCode39PAS";
415
- DecodeBarcodeType["HibcDataMatrixLic"] = "HIBCDataMatrixLIC";
416
- DecodeBarcodeType["HibcDataMatrixPas"] = "HIBCDataMatrixPAS";
417
- DecodeBarcodeType["Hibcqrlic"] = "HIBCQRLIC";
418
- DecodeBarcodeType["Hibcqrpas"] = "HIBCQRPAS";
419
- DecodeBarcodeType["Iata2of5"] = "IATA2of5";
420
- DecodeBarcodeType["Isbn"] = "ISBN";
421
- DecodeBarcodeType["Ismn"] = "ISMN";
422
- DecodeBarcodeType["Issn"] = "ISSN";
423
- DecodeBarcodeType["Itf14"] = "ITF14";
424
- DecodeBarcodeType["Itf6"] = "ITF6";
425
- DecodeBarcodeType["Interleaved2of5"] = "Interleaved2of5";
426
- DecodeBarcodeType["ItalianPost25"] = "ItalianPost25";
427
- DecodeBarcodeType["MacroPdf417"] = "MacroPdf417";
428
- DecodeBarcodeType["Mailmark"] = "Mailmark";
429
- DecodeBarcodeType["Matrix2of5"] = "Matrix2of5";
430
- DecodeBarcodeType["MaxiCode"] = "MaxiCode";
431
- DecodeBarcodeType["MicrE13B"] = "MicrE13B";
432
- DecodeBarcodeType["MicroPdf417"] = "MicroPdf417";
433
- DecodeBarcodeType["MicroQr"] = "MicroQR";
434
- DecodeBarcodeType["Msi"] = "MSI";
435
- DecodeBarcodeType["OneCode"] = "OneCode";
436
- DecodeBarcodeType["Opc"] = "OPC";
437
- DecodeBarcodeType["PatchCode"] = "PatchCode";
438
- DecodeBarcodeType["Pdf417"] = "Pdf417";
439
- DecodeBarcodeType["Pharmacode"] = "Pharmacode";
440
- DecodeBarcodeType["Planet"] = "Planet";
441
- DecodeBarcodeType["Postnet"] = "Postnet";
442
- DecodeBarcodeType["Pzn"] = "PZN";
443
- DecodeBarcodeType["RectMicroQr"] = "RectMicroQR";
444
- DecodeBarcodeType["Rm4Scc"] = "RM4SCC";
445
- DecodeBarcodeType["Scc14"] = "SCC14";
446
- DecodeBarcodeType["Sscc18"] = "SSCC18";
447
- DecodeBarcodeType["Standard2of5"] = "Standard2of5";
448
- DecodeBarcodeType["Supplement"] = "Supplement";
449
- DecodeBarcodeType["SwissPostParcel"] = "SwissPostParcel";
450
- DecodeBarcodeType["Upca"] = "UPCA";
451
- DecodeBarcodeType["Upce"] = "UPCE";
452
- DecodeBarcodeType["Vin"] = "VIN";
453
- })(exports.DecodeBarcodeType || (exports.DecodeBarcodeType = {}));
454
- /**
455
- * See Aspose.BarCode.Generation.EncodeTypes
456
- */
457
- exports.EncodeBarcodeType = void 0;
458
- (function (EncodeBarcodeType) {
459
- EncodeBarcodeType["Qr"] = "QR";
460
- EncodeBarcodeType["AustraliaPost"] = "AustraliaPost";
461
- EncodeBarcodeType["AustralianPosteParcel"] = "AustralianPosteParcel";
462
- EncodeBarcodeType["Aztec"] = "Aztec";
463
- EncodeBarcodeType["Codabar"] = "Codabar";
464
- EncodeBarcodeType["CodablockF"] = "CodablockF";
465
- EncodeBarcodeType["Code11"] = "Code11";
466
- EncodeBarcodeType["Code128"] = "Code128";
467
- EncodeBarcodeType["Code16K"] = "Code16K";
468
- EncodeBarcodeType["Code32"] = "Code32";
469
- EncodeBarcodeType["Code39"] = "Code39";
470
- EncodeBarcodeType["Code39FullAscii"] = "Code39FullASCII";
471
- EncodeBarcodeType["Code93"] = "Code93";
472
- EncodeBarcodeType["DataLogic2of5"] = "DataLogic2of5";
473
- EncodeBarcodeType["DataMatrix"] = "DataMatrix";
474
- EncodeBarcodeType["DatabarExpanded"] = "DatabarExpanded";
475
- EncodeBarcodeType["DatabarExpandedStacked"] = "DatabarExpandedStacked";
476
- EncodeBarcodeType["DatabarLimited"] = "DatabarLimited";
477
- EncodeBarcodeType["DatabarOmniDirectional"] = "DatabarOmniDirectional";
478
- EncodeBarcodeType["DatabarStacked"] = "DatabarStacked";
479
- EncodeBarcodeType["DatabarStackedOmniDirectional"] = "DatabarStackedOmniDirectional";
480
- EncodeBarcodeType["DatabarTruncated"] = "DatabarTruncated";
481
- EncodeBarcodeType["DeutschePostIdentcode"] = "DeutschePostIdentcode";
482
- EncodeBarcodeType["DeutschePostLeitcode"] = "DeutschePostLeitcode";
483
- EncodeBarcodeType["DotCode"] = "DotCode";
484
- EncodeBarcodeType["DutchKix"] = "DutchKIX";
485
- EncodeBarcodeType["Ean13"] = "EAN13";
486
- EncodeBarcodeType["Ean14"] = "EAN14";
487
- EncodeBarcodeType["Ean8"] = "EAN8";
488
- EncodeBarcodeType["Gs1Aztec"] = "GS1Aztec";
489
- EncodeBarcodeType["Gs1CodablockF"] = "GS1CodablockF";
490
- EncodeBarcodeType["Gs1Code128"] = "GS1Code128";
491
- EncodeBarcodeType["Gs1DataMatrix"] = "GS1DataMatrix";
492
- EncodeBarcodeType["Gs1DotCode"] = "GS1DotCode";
493
- EncodeBarcodeType["Gs1HanXin"] = "GS1HanXin";
494
- EncodeBarcodeType["Gs1MicroPdf417"] = "GS1MicroPdf417";
495
- EncodeBarcodeType["Gs1Qr"] = "GS1QR";
496
- EncodeBarcodeType["HanXin"] = "HanXin";
497
- EncodeBarcodeType["Iata2of5"] = "IATA2of5";
498
- EncodeBarcodeType["Isbn"] = "ISBN";
499
- EncodeBarcodeType["Ismn"] = "ISMN";
500
- EncodeBarcodeType["Issn"] = "ISSN";
501
- EncodeBarcodeType["Itf14"] = "ITF14";
502
- EncodeBarcodeType["Itf6"] = "ITF6";
503
- EncodeBarcodeType["Interleaved2of5"] = "Interleaved2of5";
504
- EncodeBarcodeType["ItalianPost25"] = "ItalianPost25";
505
- EncodeBarcodeType["Msi"] = "MSI";
506
- EncodeBarcodeType["MacroPdf417"] = "MacroPdf417";
507
- EncodeBarcodeType["Mailmark"] = "Mailmark";
508
- EncodeBarcodeType["Matrix2of5"] = "Matrix2of5";
509
- EncodeBarcodeType["MaxiCode"] = "MaxiCode";
510
- EncodeBarcodeType["MicroPdf417"] = "MicroPdf417";
511
- EncodeBarcodeType["MicroQr"] = "MicroQR";
512
- EncodeBarcodeType["Opc"] = "OPC";
513
- EncodeBarcodeType["OneCode"] = "OneCode";
514
- EncodeBarcodeType["Pzn"] = "PZN";
515
- EncodeBarcodeType["PatchCode"] = "PatchCode";
516
- EncodeBarcodeType["Pdf417"] = "Pdf417";
517
- EncodeBarcodeType["Pharmacode"] = "Pharmacode";
518
- EncodeBarcodeType["Planet"] = "Planet";
519
- EncodeBarcodeType["Postnet"] = "Postnet";
520
- EncodeBarcodeType["Rm4Scc"] = "RM4SCC";
521
- EncodeBarcodeType["RectMicroQr"] = "RectMicroQR";
522
- EncodeBarcodeType["Scc14"] = "SCC14";
523
- EncodeBarcodeType["Sscc18"] = "SSCC18";
524
- EncodeBarcodeType["SingaporePost"] = "SingaporePost";
525
- EncodeBarcodeType["Standard2of5"] = "Standard2of5";
526
- EncodeBarcodeType["SwissPostParcel"] = "SwissPostParcel";
527
- EncodeBarcodeType["Upca"] = "UPCA";
528
- EncodeBarcodeType["Upce"] = "UPCE";
529
- EncodeBarcodeType["UpcaGs1Code128Coupon"] = "UpcaGs1Code128Coupon";
530
- EncodeBarcodeType["UpcaGs1DatabarCoupon"] = "UpcaGs1DatabarCoupon";
531
- EncodeBarcodeType["Vin"] = "VIN";
532
- })(exports.EncodeBarcodeType || (exports.EncodeBarcodeType = {}));
533
- /**
534
- * Data to encode in barcode
535
- */
536
- class EncodeData {
537
- constructor() {
538
- this['dataType'] = void 0;
539
- /**
540
- * String represents data to encode
541
- */
542
- this['data'] = void 0;
543
- }
544
- static getAttributeTypeMap() {
545
- return EncodeData.attributeTypeMap;
546
- }
547
- }
548
- /**
549
- * Types of data can be encoded to barcode
550
- */
551
- EncodeData.attributeTypeMap = [{
552
- name: 'dataType',
553
- baseName: 'dataType',
554
- type: 'EncodeDataType'
555
- }, {
556
- name: 'data',
557
- baseName: 'data',
558
- type: 'string'
559
- }];
560
- exports.EncodeDataType = void 0;
561
- (function (EncodeDataType) {
562
- EncodeDataType["StringData"] = "StringData";
563
- EncodeDataType["Base64Bytes"] = "Base64Bytes";
564
- EncodeDataType["HexBytes"] = "HexBytes";
565
- })(exports.EncodeDataType || (exports.EncodeDataType = {}));
566
- /**
567
- * Barcode generation parameters
568
- */
569
- class GenerateParams {
570
- constructor() {
571
- this['barcodeType'] = void 0;
572
- this['encodeData'] = void 0;
573
- this['barcodeImageParams'] = void 0;
574
- }
575
- static getAttributeTypeMap() {
576
- return GenerateParams.attributeTypeMap;
577
- }
578
- }
579
- /**
580
- * Subset of Aspose.Drawing.GraphicsUnit.
581
- */
582
- GenerateParams.attributeTypeMap = [{
583
- name: 'barcodeType',
584
- baseName: 'barcodeType',
585
- type: 'EncodeBarcodeType'
586
- }, {
587
- name: 'encodeData',
588
- baseName: 'encodeData',
589
- type: 'EncodeData'
590
- }, {
591
- name: 'barcodeImageParams',
592
- baseName: 'barcodeImageParams',
593
- type: 'BarcodeImageParams'
594
- }];
595
- exports.GraphicsUnit = void 0;
596
- (function (GraphicsUnit) {
597
- GraphicsUnit["Pixel"] = "Pixel";
598
- GraphicsUnit["Point"] = "Point";
599
- GraphicsUnit["Inch"] = "Inch";
600
- GraphicsUnit["Millimeter"] = "Millimeter";
601
- })(exports.GraphicsUnit || (exports.GraphicsUnit = {}));
602
- /**
603
- * Kind of image to recognize
604
- */
605
- exports.RecognitionImageKind = void 0;
606
- (function (RecognitionImageKind) {
607
- RecognitionImageKind["Photo"] = "Photo";
608
- RecognitionImageKind["ScannedDocument"] = "ScannedDocument";
609
- RecognitionImageKind["ClearImage"] = "ClearImage";
610
- })(exports.RecognitionImageKind || (exports.RecognitionImageKind = {}));
611
- /**
612
- * Recognition mode.
613
- */
614
- exports.RecognitionMode = void 0;
615
- (function (RecognitionMode) {
616
- RecognitionMode["Fast"] = "Fast";
617
- RecognitionMode["Normal"] = "Normal";
618
- RecognitionMode["Excellent"] = "Excellent";
619
- })(exports.RecognitionMode || (exports.RecognitionMode = {}));
620
- /**
621
- * Barcode recognize request
622
- */
623
- class RecognizeBase64Request {
624
- constructor() {
625
- /**
626
- * Array of decode types to find on barcode
627
- */
628
- this['barcodeTypes'] = void 0;
629
- /**
630
- * Barcode image bytes encoded as base-64.
631
- */
632
- this['fileBase64'] = void 0;
633
- this['recognitionMode'] = void 0;
634
- this['recognitionImageKind'] = void 0;
635
- }
636
- static getAttributeTypeMap() {
637
- return RecognizeBase64Request.attributeTypeMap;
638
- }
639
- }
640
- /**
641
- * Wrapper around Drawing.Point for proper specification.
642
- */
643
- RecognizeBase64Request.attributeTypeMap = [{
644
- name: 'barcodeTypes',
645
- baseName: 'barcodeTypes',
646
- type: 'Array<DecodeBarcodeType>'
647
- }, {
648
- name: 'fileBase64',
649
- baseName: 'fileBase64',
650
- type: 'string'
651
- }, {
652
- name: 'recognitionMode',
653
- baseName: 'recognitionMode',
654
- type: 'RecognitionMode'
655
- }, {
656
- name: 'recognitionImageKind',
657
- baseName: 'recognitionImageKind',
658
- type: 'RecognitionImageKind'
659
- }];
660
- class RegionPoint {
661
- constructor() {
662
- /**
663
- * X-coordinate
664
- */
665
- this['x'] = void 0;
666
- /**
667
- * Y-coordinate
668
- */
669
- this['y'] = void 0;
670
- }
671
- static getAttributeTypeMap() {
672
- return RegionPoint.attributeTypeMap;
673
- }
674
- }
675
- /**
676
- * Scan barcode request.
677
- */
678
- RegionPoint.attributeTypeMap = [{
679
- name: 'x',
680
- baseName: 'x',
681
- type: 'number'
682
- }, {
683
- name: 'y',
684
- baseName: 'y',
685
- type: 'number'
686
- }];
687
- class ScanBase64Request {
688
- constructor() {
689
- /**
690
- * Barcode image bytes encoded as base-64.
691
- */
692
- this['fileBase64'] = void 0;
693
- }
694
- static getAttributeTypeMap() {
695
- return ScanBase64Request.attributeTypeMap;
696
- }
697
- }
698
- // GenerateApi
699
- /**
700
- * Generate barcode using GET request with parameters in route and query string.
701
- */
702
- ScanBase64Request.attributeTypeMap = [{
703
- name: 'fileBase64',
704
- baseName: 'fileBase64',
705
- type: 'string'
706
- }];
707
- class GenerateRequestWrapper {
708
- /**
709
- * @param barcodeType Type of barcode to generate.
710
-
711
- * @param data String represents data to encode
712
- */
713
- constructor(barcodeType, data) {
714
- /**
715
- * Type of barcode to generate.
716
- */
717
- this['barcodeType'] = void 0;
718
- /**
719
- * String represents data to encode
720
- */
721
- this['data'] = void 0;
722
- /**
723
- * Type of data to encode.
724
- Default value: StringData.
725
- */
726
- this['dataType'] = void 0;
727
- /**
728
- * Barcode output image format.
729
- Default value: png
730
- */
731
- this['imageFormat'] = void 0;
732
- /**
733
- * Specify the displaying Text Location, set to CodeLocation.None to hide CodeText.
734
- Default value: CodeLocation.Below.
735
- */
736
- this['textLocation'] = void 0;
737
- /**
738
- * Specify the displaying bars and content Color.
739
- Value: Color name from https://reference.aspose.com/drawing/net/system.drawing/color/ or ARGB value started with #.
740
- For example: AliceBlue or #FF000000
741
- Default value: Black.
742
- */
743
- this['foregroundColor'] = "'Black'";
744
- /**
745
- * Background color of the barcode image.
746
- Value: Color name from https://reference.aspose.com/drawing/net/system.drawing/color/ or ARGB value started with #.
747
- For example: AliceBlue or #FF000000
748
- Default value: White.
749
- */
750
- this['backgroundColor'] = "'White'";
751
- /**
752
- * Common Units for all measuring in query. Default units: pixel.
753
- */
754
- this['units'] = void 0;
755
- /**
756
- * Resolution of the BarCode image.
757
- One value for both dimensions.
758
- Default value: 96 dpi.
759
- Decimal separator is dot.
760
- */
761
- this['resolution'] = void 0;
762
- /**
763
- * Height of the barcode image in given units. Default units: pixel.
764
- Decimal separator is dot.
765
- */
766
- this['imageHeight'] = void 0;
767
- /**
768
- * Width of the barcode image in given units. Default units: pixel.
769
- Decimal separator is dot.
770
- */
771
- this['imageWidth'] = void 0;
772
- /**
773
- * BarCode image rotation angle, measured in degree, e.g. RotationAngle = 0 or RotationAngle = 360 means no rotation.
774
- If RotationAngle NOT equal to 90, 180, 270 or 0, it may increase the difficulty for the scanner to read the image.
775
- Default value: 0.
776
- */
777
- this['rotationAngle'] = void 0;
778
- this.barcodeType = barcodeType;
779
- this.data = data;
780
- }
781
- }
782
- /**
783
- * Generate barcode using POST request with parameters in body in json or xml format.
784
- */
785
- class GenerateBodyRequestWrapper {
786
- /**
787
- * @param generateParams
788
- */
789
- constructor(generateParams) {
790
- /**
791
- *
792
- */
793
- this['generateParams'] = void 0;
794
- this.generateParams = generateParams;
795
- }
796
- }
797
- /**
798
- * Generate barcode using POST request with parameters in multipart form.
799
- */
800
- class GenerateMultipartRequestWrapper {
801
- /**
802
- * @param barcodeType
803
-
804
- * @param data String represents data to encode
805
- */
806
- constructor(barcodeType, data) {
807
- /**
808
- *
809
- */
810
- this['barcodeType'] = void 0;
811
- /**
812
- * String represents data to encode
813
- */
814
- this['data'] = void 0;
815
- /**
816
- *
817
- */
818
- this['dataType'] = void 0;
819
- /**
820
- *
821
- */
822
- this['imageFormat'] = void 0;
823
- /**
824
- *
825
- */
826
- this['textLocation'] = void 0;
827
- /**
828
- * 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.
829
- */
830
- this['foregroundColor'] = "'Black'";
831
- /**
832
- * 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.
833
- */
834
- this['backgroundColor'] = "'White'";
835
- /**
836
- *
837
- */
838
- this['units'] = void 0;
839
- /**
840
- * Resolution of the BarCode image. One value for both dimensions. Default value: 96 dpi. Decimal separator is dot.
841
- */
842
- this['resolution'] = void 0;
843
- /**
844
- * Height of the barcode image in given units. Default units: pixel. Decimal separator is dot.
845
- */
846
- this['imageHeight'] = void 0;
847
- /**
848
- * Width of the barcode image in given units. Default units: pixel. Decimal separator is dot.
849
- */
850
- this['imageWidth'] = void 0;
851
- /**
852
- * 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.
853
- */
854
- this['rotationAngle'] = void 0;
855
- this.barcodeType = barcodeType;
856
- this.data = data;
857
- }
858
- }
859
- // RecognizeApi
860
- /**
861
- * Recognize barcode from file on server using GET requests with parameters in route and query string.
862
- */
863
- class RecognizeRequestWrapper {
864
- /**
865
- * @param barcodeType Type of barcode to recognize
866
-
867
- * @param fileUrl Url to barcode image
868
- */
869
- constructor(barcodeType, fileUrl) {
870
- /**
871
- * Type of barcode to recognize
872
- */
873
- this['barcodeType'] = void 0;
874
- /**
875
- * Url to barcode image
876
- */
877
- this['fileUrl'] = void 0;
878
- /**
879
- * Recognition mode
880
- */
881
- this['recognitionMode'] = void 0;
882
- /**
883
- * Image kind for recognition
884
- */
885
- this['recognitionImageKind'] = void 0;
886
- this.barcodeType = barcodeType;
887
- this.fileUrl = fileUrl;
888
- }
889
- }
890
- /**
891
- * Recognize barcode from file in request body using POST requests with parameters in body in json or xml format.
892
- */
893
- class RecognizeBase64RequestWrapper {
894
- /**
895
- * @param recognizeBase64Request
896
- */
897
- constructor(recognizeBase64Request) {
898
- /**
899
- *
900
- */
901
- this['recognizeBase64Request'] = void 0;
902
- this.recognizeBase64Request = recognizeBase64Request;
903
- }
904
- }
905
- /**
906
- * Recognize barcode from file in request body using POST requests with parameters in multipart form.
907
- */
908
- class RecognizeMultipartRequestWrapper {
909
- /**
910
- * @param barcodeType
911
-
912
- * @param fileBytes Barcode image file
913
- */
914
- constructor(barcodeType, fileBytes) {
915
- /**
916
- *
917
- */
918
- this['barcodeType'] = void 0;
919
- /**
920
- * Barcode image file
921
- */
922
- this['fileBytes'] = void 0;
923
- /**
924
- *
925
- */
926
- this['recognitionMode'] = void 0;
927
- /**
928
- *
929
- */
930
- this['recognitionImageKind'] = void 0;
931
- this.barcodeType = barcodeType;
932
- this.fileBytes = fileBytes;
933
- }
934
- }
935
- // ScanApi
936
- /**
937
- * Scan barcode from file on server using GET requests with parameter in query string.
938
- */
939
- class ScanRequestWrapper {
940
- /**
941
- * @param fileUrl Url to barcode image
942
- */
943
- constructor(fileUrl) {
944
- /**
945
- * Url to barcode image
946
- */
947
- this['fileUrl'] = void 0;
948
- this.fileUrl = fileUrl;
949
- }
950
- }
951
- /**
952
- * Scan barcode from file in request body using POST requests with parameter in body in json or xml format.
953
- */
954
- class ScanBase64RequestWrapper {
955
- /**
956
- * @param scanBase64Request
957
- */
958
- constructor(scanBase64Request) {
959
- /**
960
- *
961
- */
962
- this['scanBase64Request'] = void 0;
963
- this.scanBase64Request = scanBase64Request;
964
- }
965
- }
966
- /**
967
- * Scan barcode from file in request body using POST requests with parameter in multipart form.
968
- */
969
- class ScanMultipartRequestWrapper {
970
- /**
971
- * @param fileBytes Barcode image file
972
- */
973
- constructor(fileBytes) {
974
- /**
975
- * Barcode image file
976
- */
977
- this['fileBytes'] = void 0;
978
- this.fileBytes = fileBytes;
979
- }
980
- }
981
-
982
- let primitives = ['string', 'boolean', 'double', 'integer', 'long', 'float', 'number', 'any'];
983
- class ObjectSerializer {
984
- static findCorrectType(data, expectedType) {
985
- if (data == null) {
986
- return expectedType;
987
- }
988
- if (primitives.indexOf(expectedType.toLowerCase()) !== -1) {
989
- return expectedType;
990
- }
991
- if (expectedType === 'Date') {
992
- return expectedType;
993
- }
994
- if (enumsMap[expectedType]) {
995
- return expectedType;
996
- }
997
- if (!typeMap[expectedType]) {
998
- return expectedType; // w/e we don't know the type
999
- }
1000
- // Check the discriminator
1001
- let discriminatorProperty = typeMap[expectedType].discriminator;
1002
- if (discriminatorProperty == null) {
1003
- return expectedType; // the type does not have a discriminator. use it.
1004
- }
1005
- if (data[discriminatorProperty]) {
1006
- return data[discriminatorProperty]; // use the type given in the discriminator
1007
- }
1008
- return expectedType; // discriminator was not present (or an empty string)
1009
- }
1010
- static serialize(data, type) {
1011
- if (data == null) {
1012
- return data;
1013
- }
1014
- if (primitives.indexOf(type.toLowerCase()) !== -1) {
1015
- return data;
1016
- }
1017
- if (type.lastIndexOf('Array<', 0) === 0) {
1018
- // string.startsWith pre es6
1019
- let subType = type.replace('Array<', ''); // Array<Type> => Type>
1020
- subType = subType.substring(0, subType.length - 1); // Type> => Type
1021
- let transformedData = [];
1022
- for (let index in data) {
1023
- let date = data[index];
1024
- transformedData.push(ObjectSerializer.serialize(date, subType));
1025
- }
1026
- return transformedData;
1027
- }
1028
- if (type === 'Date') {
1029
- return data.toString();
1030
- }
1031
- if (enumsMap[type] && Object.values(enumsMap[type]).includes(data)) {
1032
- return data;
1033
- }
1034
- if (!typeMap[type]) {
1035
- // in case we don't know the type
1036
- return data;
1037
- }
1038
- // get the map for the correct type.
1039
- let attributeTypes = typeMap[type].getAttributeTypeMap();
1040
- let instance = {};
1041
- for (let index in attributeTypes) {
1042
- let attributeType = attributeTypes[index];
1043
- instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type);
1044
- }
1045
- return instance;
1046
- }
1047
- static deserialize(data, type) {
1048
- // polymorphism may change the actual type.
1049
- type = ObjectSerializer.findCorrectType(data, type);
1050
- if (data == null) {
1051
- return data;
1052
- }
1053
- if (primitives.indexOf(type.toLowerCase()) !== -1) {
1054
- return data;
1055
- }
1056
- if (type.lastIndexOf('Array<', 0) === 0) {
1057
- // string.startsWith pre es6
1058
- let subType = type.replace('Array<', ''); // Array<Type> => Type>
1059
- subType = subType.substring(0, subType.length - 1); // Type> => Type
1060
- let transformedData = [];
1061
- for (let index in data) {
1062
- let date = data[index];
1063
- transformedData.push(ObjectSerializer.deserialize(date, subType));
1064
- }
1065
- return transformedData;
1066
- }
1067
- if (type === 'Date') {
1068
- return new Date(data);
1069
- }
1070
- if (enumsMap[type]) {
1071
- // is Enum
1072
- return data;
1073
- }
1074
- if (!typeMap[type]) {
1075
- // don't know the type
1076
- return data;
1077
- }
1078
- if (typeof data === 'string') {
1079
- // data should be deserialized before usage
1080
- data = JSON.parse(data);
1081
- }
1082
- let instance = new typeMap[type]();
1083
- let attributeTypes = typeMap[type].getAttributeTypeMap();
1084
- for (const attributeType of attributeTypes) {
1085
- const key = attributeType.baseName.replace(/^(.)/, $1 => {
1086
- return $1.toLowerCase();
1087
- });
1088
- instance[attributeType.name] = ObjectSerializer.deserialize(data[key], attributeType.type);
1089
- }
1090
- return instance;
1091
- }
1092
- }
1093
- let enumsMap = {
1094
- BarcodeImageFormat: exports.BarcodeImageFormat,
1095
- CodeLocation: exports.CodeLocation,
1096
- DecodeBarcodeType: exports.DecodeBarcodeType,
1097
- EncodeBarcodeType: exports.EncodeBarcodeType,
1098
- EncodeDataType: exports.EncodeDataType,
1099
- GraphicsUnit: exports.GraphicsUnit,
1100
- RecognitionImageKind: exports.RecognitionImageKind,
1101
- RecognitionMode: exports.RecognitionMode
1102
- };
1103
- let typeMap = {
1104
- ApiError: ApiError,
1105
- ApiErrorResponse: ApiErrorResponse,
1106
- BarcodeImageParams: BarcodeImageParams,
1107
- BarcodeResponse: BarcodeResponse,
1108
- BarcodeResponseList: BarcodeResponseList,
1109
- EncodeData: EncodeData,
1110
- GenerateParams: GenerateParams,
1111
- RecognizeBase64Request: RecognizeBase64Request,
1112
- RegionPoint: RegionPoint,
1113
- ScanBase64Request: ScanBase64Request
1114
- };
1115
- class GenerateApi {
1116
- constructor(configuration) {
1117
- this.defaultHeaders = {
1118
- 'x-aspose-client': 'nodejs sdk',
1119
- 'x-aspose-client-version': '25.1.0'
1120
- };
1121
- this._configuration = void 0;
1122
- this._client = void 0;
1123
- this._configuration = configuration;
1124
- this._client = new HttpClient();
1125
- }
1126
- /**
1127
- *
1128
- * @summary Generate barcode using GET request with parameters in route and query string.
1129
- * @param request GenerateRequestWrapper
1130
- */
1131
- async generate(request) {
1132
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/generate/{barcodeType}'.replace(
1133
- // eslint-disable-next-line no-useless-concat
1134
- '{' + 'barcodeType' + '}', String(request.barcodeType));
1135
- let queryParameters = {};
1136
- let headerParams = Object.assign({}, this.defaultHeaders);
1137
- // verify required parameter 'request.barcodeType' is not null or undefined
1138
- if (request.barcodeType == null) {
1139
- throw new Error('Required parameter request.barcodeType was null or undefined when calling generate.');
1140
- }
1141
- // verify required parameter 'request.data' is not null or undefined
1142
- if (request.data == null) {
1143
- throw new Error('Required parameter request.data was null or undefined when calling generate.');
1144
- }
1145
- if (request.dataType != null) {
1146
- queryParameters['dataType'] = ObjectSerializer.serialize(request.dataType, 'EncodeDataType');
1147
- }
1148
- if (request.data != null) {
1149
- queryParameters['data'] = ObjectSerializer.serialize(request.data, 'string');
1150
- }
1151
- if (request.imageFormat != null) {
1152
- queryParameters['imageFormat'] = ObjectSerializer.serialize(request.imageFormat, 'BarcodeImageFormat');
1153
- }
1154
- if (request.textLocation != null) {
1155
- queryParameters['textLocation'] = ObjectSerializer.serialize(request.textLocation, 'CodeLocation');
1156
- }
1157
- if (request.foregroundColor != null) {
1158
- queryParameters['foregroundColor'] = ObjectSerializer.serialize(request.foregroundColor, 'string');
1159
- }
1160
- if (request.backgroundColor != null) {
1161
- queryParameters['backgroundColor'] = ObjectSerializer.serialize(request.backgroundColor, 'string');
1162
- }
1163
- if (request.units != null) {
1164
- queryParameters['units'] = ObjectSerializer.serialize(request.units, 'GraphicsUnit');
1165
- }
1166
- if (request.resolution != null) {
1167
- queryParameters['resolution'] = ObjectSerializer.serialize(request.resolution, 'number');
1168
- }
1169
- if (request.imageHeight != null) {
1170
- queryParameters['imageHeight'] = ObjectSerializer.serialize(request.imageHeight, 'number');
1171
- }
1172
- if (request.imageWidth != null) {
1173
- queryParameters['imageWidth'] = ObjectSerializer.serialize(request.imageWidth, 'number');
1174
- }
1175
- if (request.rotationAngle != null) {
1176
- queryParameters['rotationAngle'] = ObjectSerializer.serialize(request.rotationAngle, 'number');
1177
- }
1178
- const requestOptions = {
1179
- method: 'GET',
1180
- qs: queryParameters,
1181
- headers: headerParams,
1182
- uri: requestPath,
1183
- encoding: null
1184
- };
1185
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1186
- const result = await this._client.requestAsync(requestOptions);
1187
- return {
1188
- response: result.response,
1189
- body: ObjectSerializer.deserialize(result.body, 'Buffer')
1190
- };
1191
- }
1192
- /**
1193
- *
1194
- * @summary Generate barcode using POST request with parameters in body in json or xml format.
1195
- * @param request GenerateBodyRequestWrapper
1196
- */
1197
- async generateBody(request) {
1198
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/generate-body';
1199
- let queryParameters = {};
1200
- let headerParams = Object.assign({}, this.defaultHeaders);
1201
- // verify required parameter 'request.generateParams' is not null or undefined
1202
- if (request.generateParams == null) {
1203
- throw new Error('Required parameter request.generateParams was null or undefined when calling generateBody.');
1204
- }
1205
- const requestOptions = {
1206
- method: 'POST',
1207
- qs: queryParameters,
1208
- headers: headerParams,
1209
- uri: requestPath,
1210
- body: ObjectSerializer.serialize(request.generateParams, 'GenerateParams'),
1211
- json: true,
1212
- encoding: null
1213
- };
1214
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1215
- const result = await this._client.requestAsync(requestOptions);
1216
- return {
1217
- response: result.response,
1218
- body: ObjectSerializer.deserialize(result.body, 'Buffer')
1219
- };
1220
- }
1221
- /**
1222
- *
1223
- * @summary Generate barcode using POST request with parameters in multipart form.
1224
- * @param request GenerateMultipartRequestWrapper
1225
- */
1226
- async generateMultipart(request) {
1227
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/generate-multipart';
1228
- let queryParameters = {};
1229
- let headerParams = Object.assign({}, this.defaultHeaders);
1230
- const formParams = [];
1231
- // verify required parameter 'request.barcodeType' is not null or undefined
1232
- if (request.barcodeType == null) {
1233
- throw new Error('Required parameter request.barcodeType was null or undefined when calling generateMultipart.');
1234
- }
1235
- // verify required parameter 'request.data' is not null or undefined
1236
- if (request.data == null) {
1237
- throw new Error('Required parameter request.data was null or undefined when calling generateMultipart.');
1238
- }
1239
- if (request.barcodeType != null) {
1240
- formParams.push(['barcodeType', ObjectSerializer.serialize(request.barcodeType, 'EncodeBarcodeType')]);
1241
- }
1242
- if (request.dataType != null) {
1243
- formParams.push(['dataType', ObjectSerializer.serialize(request.dataType, 'EncodeDataType')]);
1244
- }
1245
- if (request.data != null) {
1246
- formParams.push(['data', ObjectSerializer.serialize(request.data, 'string')]);
1247
- }
1248
- if (request.imageFormat != null) {
1249
- formParams.push(['imageFormat', ObjectSerializer.serialize(request.imageFormat, 'BarcodeImageFormat')]);
1250
- }
1251
- if (request.textLocation != null) {
1252
- formParams.push(['textLocation', ObjectSerializer.serialize(request.textLocation, 'CodeLocation')]);
1253
- }
1254
- if (request.foregroundColor != null) {
1255
- formParams.push(['foregroundColor', ObjectSerializer.serialize(request.foregroundColor, 'string')]);
1256
- }
1257
- if (request.backgroundColor != null) {
1258
- formParams.push(['backgroundColor', ObjectSerializer.serialize(request.backgroundColor, 'string')]);
1259
- }
1260
- if (request.units != null) {
1261
- formParams.push(['units', ObjectSerializer.serialize(request.units, 'GraphicsUnit')]);
1262
- }
1263
- if (request.resolution != null) {
1264
- formParams.push(['resolution', ObjectSerializer.serialize(request.resolution, 'number')]);
1265
- }
1266
- if (request.imageHeight != null) {
1267
- formParams.push(['imageHeight', ObjectSerializer.serialize(request.imageHeight, 'number')]);
1268
- }
1269
- if (request.imageWidth != null) {
1270
- formParams.push(['imageWidth', ObjectSerializer.serialize(request.imageWidth, 'number')]);
1271
- }
1272
- if (request.rotationAngle != null) {
1273
- formParams.push(['rotationAngle', ObjectSerializer.serialize(request.rotationAngle, 'number')]);
1274
- }
1275
- const requestOptions = {
1276
- method: 'POST',
1277
- qs: queryParameters,
1278
- headers: headerParams,
1279
- uri: requestPath,
1280
- encoding: null
1281
- };
1282
- let fileArray = new Array();
1283
- const multipartForm = new Multipart(formParams, fileArray);
1284
- requestOptions.body = multipartForm.body;
1285
- requestOptions.headers = {
1286
- ...requestOptions.headers,
1287
- ...multipartForm.headers
1288
- };
1289
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1290
- const result = await this._client.requestAsync(requestOptions);
1291
- return {
1292
- response: result.response,
1293
- body: ObjectSerializer.deserialize(result.body, 'Buffer')
1294
- };
1295
- }
1296
- }
1297
- class RecognizeApi {
1298
- constructor(configuration) {
1299
- this.defaultHeaders = {
1300
- 'x-aspose-client': 'nodejs sdk',
1301
- 'x-aspose-client-version': '25.1.0'
1302
- };
1303
- this._configuration = void 0;
1304
- this._client = void 0;
1305
- this._configuration = configuration;
1306
- this._client = new HttpClient();
1307
- }
1308
- /**
1309
- *
1310
- * @summary Recognize barcode from file on server using GET requests with parameters in route and query string.
1311
- * @param request RecognizeRequestWrapper
1312
- */
1313
- async recognize(request) {
1314
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/recognize';
1315
- let queryParameters = {};
1316
- let headerParams = Object.assign({}, this.defaultHeaders);
1317
- // verify required parameter 'request.barcodeType' is not null or undefined
1318
- if (request.barcodeType == null) {
1319
- throw new Error('Required parameter request.barcodeType was null or undefined when calling recognize.');
1320
- }
1321
- // verify required parameter 'request.fileUrl' is not null or undefined
1322
- if (request.fileUrl == null) {
1323
- throw new Error('Required parameter request.fileUrl was null or undefined when calling recognize.');
1324
- }
1325
- if (request.barcodeType != null) {
1326
- queryParameters['barcodeType'] = ObjectSerializer.serialize(request.barcodeType, 'DecodeBarcodeType');
1327
- }
1328
- if (request.fileUrl != null) {
1329
- queryParameters['fileUrl'] = ObjectSerializer.serialize(request.fileUrl, 'string');
1330
- }
1331
- if (request.recognitionMode != null) {
1332
- queryParameters['recognitionMode'] = ObjectSerializer.serialize(request.recognitionMode, 'RecognitionMode');
1333
- }
1334
- if (request.recognitionImageKind != null) {
1335
- queryParameters['recognitionImageKind'] = ObjectSerializer.serialize(request.recognitionImageKind, 'RecognitionImageKind');
1336
- }
1337
- const requestOptions = {
1338
- method: 'GET',
1339
- qs: queryParameters,
1340
- headers: headerParams,
1341
- uri: requestPath
1342
- };
1343
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1344
- const result = await this._client.requestAsync(requestOptions);
1345
- return {
1346
- response: result.response,
1347
- body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
1348
- };
1349
- }
1350
- /**
1351
- *
1352
- * @summary Recognize barcode from file in request body using POST requests with parameters in body in json or xml format.
1353
- * @param request RecognizeBase64RequestWrapper
1354
- */
1355
- async recognizeBase64(request) {
1356
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/recognize-body';
1357
- let queryParameters = {};
1358
- let headerParams = Object.assign({}, this.defaultHeaders);
1359
- // verify required parameter 'request.recognizeBase64Request' is not null or undefined
1360
- if (request.recognizeBase64Request == null) {
1361
- throw new Error('Required parameter request.recognizeBase64Request was null or undefined when calling recognizeBase64.');
1362
- }
1363
- const requestOptions = {
1364
- method: 'POST',
1365
- qs: queryParameters,
1366
- headers: headerParams,
1367
- uri: requestPath,
1368
- body: ObjectSerializer.serialize(request.recognizeBase64Request, 'RecognizeBase64Request'),
1369
- json: true
1370
- };
1371
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1372
- const result = await this._client.requestAsync(requestOptions);
1373
- return {
1374
- response: result.response,
1375
- body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
1376
- };
1377
- }
1378
- /**
1379
- *
1380
- * @summary Recognize barcode from file in request body using POST requests with parameters in multipart form.
1381
- * @param request RecognizeMultipartRequestWrapper
1382
- */
1383
- async recognizeMultipart(request) {
1384
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/recognize-multipart';
1385
- let queryParameters = {};
1386
- let headerParams = Object.assign({}, this.defaultHeaders);
1387
- const formParams = [];
1388
- // verify required parameter 'request.barcodeType' is not null or undefined
1389
- if (request.barcodeType == null) {
1390
- throw new Error('Required parameter request.barcodeType was null or undefined when calling recognizeMultipart.');
1391
- }
1392
- // verify required parameter 'request.fileBytes' is not null or undefined
1393
- if (request.fileBytes == null) {
1394
- throw new Error('Required parameter request.fileBytes was null or undefined when calling recognizeMultipart.');
1395
- }
1396
- if (request.barcodeType != null) {
1397
- formParams.push(['barcodeType', ObjectSerializer.serialize(request.barcodeType, 'DecodeBarcodeType')]);
1398
- }
1399
- if (request.recognitionMode != null) {
1400
- formParams.push(['recognitionMode', ObjectSerializer.serialize(request.recognitionMode, 'RecognitionMode')]);
1401
- }
1402
- if (request.recognitionImageKind != null) {
1403
- formParams.push(['recognitionImageKind', ObjectSerializer.serialize(request.recognitionImageKind, 'RecognitionImageKind')]);
1404
- }
1405
- const requestOptions = {
1406
- method: 'POST',
1407
- qs: queryParameters,
1408
- headers: headerParams,
1409
- uri: requestPath
1410
- };
1411
- let fileArray = new Array();
1412
- fileArray = request.fileBytes == null ? [] : [new RequestFile('file', '', request.fileBytes)];
1413
- const multipartForm = new Multipart(formParams, fileArray);
1414
- requestOptions.body = multipartForm.body;
1415
- requestOptions.headers = {
1416
- ...requestOptions.headers,
1417
- ...multipartForm.headers
1418
- };
1419
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1420
- const result = await this._client.requestAsync(requestOptions);
1421
- return {
1422
- response: result.response,
1423
- body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
1424
- };
1425
- }
1426
- }
1427
- class ScanApi {
1428
- constructor(configuration) {
1429
- this.defaultHeaders = {
1430
- 'x-aspose-client': 'nodejs sdk',
1431
- 'x-aspose-client-version': '25.1.0'
1432
- };
1433
- this._configuration = void 0;
1434
- this._client = void 0;
1435
- this._configuration = configuration;
1436
- this._client = new HttpClient();
1437
- }
1438
- /**
1439
- *
1440
- * @summary Scan barcode from file on server using GET requests with parameter in query string.
1441
- * @param request ScanRequestWrapper
1442
- */
1443
- async scan(request) {
1444
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/scan';
1445
- let queryParameters = {};
1446
- let headerParams = Object.assign({}, this.defaultHeaders);
1447
- // verify required parameter 'request.fileUrl' is not null or undefined
1448
- if (request.fileUrl == null) {
1449
- throw new Error('Required parameter request.fileUrl was null or undefined when calling scan.');
1450
- }
1451
- if (request.fileUrl != null) {
1452
- queryParameters['fileUrl'] = ObjectSerializer.serialize(request.fileUrl, 'string');
1453
- }
1454
- const requestOptions = {
1455
- method: 'GET',
1456
- qs: queryParameters,
1457
- headers: headerParams,
1458
- uri: requestPath
1459
- };
1460
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1461
- const result = await this._client.requestAsync(requestOptions);
1462
- return {
1463
- response: result.response,
1464
- body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
1465
- };
1466
- }
1467
- /**
1468
- *
1469
- * @summary Scan barcode from file in request body using POST requests with parameter in body in json or xml format.
1470
- * @param request ScanBase64RequestWrapper
1471
- */
1472
- async scanBase64(request) {
1473
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/scan-body';
1474
- let queryParameters = {};
1475
- let headerParams = Object.assign({}, this.defaultHeaders);
1476
- // verify required parameter 'request.scanBase64Request' is not null or undefined
1477
- if (request.scanBase64Request == null) {
1478
- throw new Error('Required parameter request.scanBase64Request was null or undefined when calling scanBase64.');
1479
- }
1480
- const requestOptions = {
1481
- method: 'POST',
1482
- qs: queryParameters,
1483
- headers: headerParams,
1484
- uri: requestPath,
1485
- body: ObjectSerializer.serialize(request.scanBase64Request, 'ScanBase64Request'),
1486
- json: true
1487
- };
1488
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1489
- const result = await this._client.requestAsync(requestOptions);
1490
- return {
1491
- response: result.response,
1492
- body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
1493
- };
1494
- }
1495
- /**
1496
- *
1497
- * @summary Scan barcode from file in request body using POST requests with parameter in multipart form.
1498
- * @param request ScanMultipartRequestWrapper
1499
- */
1500
- async scanMultipart(request) {
1501
- const requestPath = this._configuration.getApiBaseUrl() + '/barcode/scan-multipart';
1502
- let queryParameters = {};
1503
- let headerParams = Object.assign({}, this.defaultHeaders);
1504
- const formParams = [];
1505
- // verify required parameter 'request.fileBytes' is not null or undefined
1506
- if (request.fileBytes == null) {
1507
- throw new Error('Required parameter request.fileBytes was null or undefined when calling scanMultipart.');
1508
- }
1509
- const requestOptions = {
1510
- method: 'POST',
1511
- qs: queryParameters,
1512
- headers: headerParams,
1513
- uri: requestPath
1514
- };
1515
- let fileArray = new Array();
1516
- fileArray = request.fileBytes == null ? [] : [new RequestFile('file', '', request.fileBytes)];
1517
- const multipartForm = new Multipart(formParams, fileArray);
1518
- requestOptions.body = multipartForm.body;
1519
- requestOptions.headers = {
1520
- ...requestOptions.headers,
1521
- ...multipartForm.headers
1522
- };
1523
- await this._configuration.authentication.applyToRequestAsync(requestOptions);
1524
- const result = await this._client.requestAsync(requestOptions);
1525
- return {
1526
- response: result.response,
1527
- body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
1528
- };
1529
- }
1530
- }
1531
-
1532
- class JWTAuth {
1533
- constructor(configuration) {
1534
- this._accessToken = void 0;
1535
- this._configuration = void 0;
1536
- this._client = void 0;
1537
- this._configuration = configuration;
1538
- if (configuration.accessToken) {
1539
- // Use saved token
1540
- this._accessToken = configuration.accessToken;
1541
- }
1542
- this._client = new HttpClient();
1543
- }
1544
- /**
1545
- * Apply authentication settings to header and query params.
1546
- */
1547
- async applyToRequestAsync(requestOptions) {
1548
- if (this._accessToken == null) {
1549
- this._accessToken = await this.requestToken();
1550
- }
1551
- if (requestOptions && requestOptions.headers) {
1552
- requestOptions.headers.Authorization = 'Bearer ' + this._accessToken;
1553
- }
1554
- return Promise.resolve();
1555
- }
1556
- async requestToken() {
1557
- if (!this._configuration.clientId || !this._configuration.clientSecret) {
1558
- throw new Error("Required 'clientId' or 'clientSecret' not specified in configuration.");
1559
- }
1560
- const requestOptions = {
1561
- method: 'POST',
1562
- uri: this._configuration.tokenUrl,
1563
- form: {
1564
- grant_type: 'client_credentials',
1565
- client_id: this._configuration.clientId,
1566
- client_secret: this._configuration.clientSecret
1567
- }
1568
- };
1569
- const result = await this._client.requestAsync(requestOptions);
1570
- const parsed = JSON.parse(result.body);
1571
- return parsed.access_token;
1572
- }
1573
- }
1574
-
1575
- exports.ApiVersion = void 0;
1576
- (function (ApiVersion) {
1577
- ApiVersion["v4"] = "v4.0";
1578
- })(exports.ApiVersion || (exports.ApiVersion = {}));
1579
- class Configuration {
1580
- constructor(clientId, clientSecret, baseUrl, accessToken, tokenUrl) {
1581
- /**
1582
- * Authentication type.
1583
- */
1584
- this.authentication = void 0;
1585
- /**
1586
- * Client Id.
1587
- */
1588
- this.clientId = void 0;
1589
- /**
1590
- * Client Secret.
1591
- */
1592
- this.clientSecret = void 0;
1593
- /**
1594
- * Base Url.
1595
- */
1596
- this.baseUrl = void 0;
1597
- this.version = exports.ApiVersion.v4;
1598
- this.accessToken = void 0;
1599
- this.tokenUrl = void 0;
1600
- this.clientId = clientId;
1601
- this.clientSecret = clientSecret;
1602
- if (baseUrl) {
1603
- this.baseUrl = baseUrl;
1604
- } else {
1605
- this.baseUrl = 'https://api.aspose.cloud';
1606
- }
1607
- this.tokenUrl = tokenUrl != null ? tokenUrl : 'https://id.aspose.cloud/connect/token';
1608
- if (accessToken) {
1609
- this.accessToken = accessToken;
1610
- } else {
1611
- this.accessToken = '';
1612
- }
1613
- this.authentication = new JWTAuth(this);
1614
- }
1615
- /**
1616
- * Returns api base url
1617
- */
1618
- getApiBaseUrl() {
1619
- return this.baseUrl + '/' + this.version;
1620
- }
1621
- }
1622
-
1623
- exports.ApiError = ApiError;
1624
- exports.ApiErrorResponse = ApiErrorResponse;
1625
- exports.BarcodeImageParams = BarcodeImageParams;
1626
- exports.BarcodeResponse = BarcodeResponse;
1627
- exports.BarcodeResponseList = BarcodeResponseList;
1628
- exports.Configuration = Configuration;
1629
- exports.EncodeData = EncodeData;
1630
- exports.GenerateApi = GenerateApi;
1631
- exports.GenerateBodyRequestWrapper = GenerateBodyRequestWrapper;
1632
- exports.GenerateMultipartRequestWrapper = GenerateMultipartRequestWrapper;
1633
- exports.GenerateParams = GenerateParams;
1634
- exports.GenerateRequestWrapper = GenerateRequestWrapper;
1635
- exports.RecognizeApi = RecognizeApi;
1636
- exports.RecognizeBase64Request = RecognizeBase64Request;
1637
- exports.RecognizeBase64RequestWrapper = RecognizeBase64RequestWrapper;
1638
- exports.RecognizeMultipartRequestWrapper = RecognizeMultipartRequestWrapper;
1639
- exports.RecognizeRequestWrapper = RecognizeRequestWrapper;
1640
- exports.RegionPoint = RegionPoint;
1641
- exports.ScanApi = ScanApi;
1642
- exports.ScanBase64Request = ScanBase64Request;
1643
- exports.ScanBase64RequestWrapper = ScanBase64RequestWrapper;
1644
- exports.ScanMultipartRequestWrapper = ScanMultipartRequestWrapper;
1645
- exports.ScanRequestWrapper = ScanRequestWrapper;
1646
- //# sourceMappingURL=aspose-barcode-cloud-node.cjs.development.js.map