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