aspose-barcode-cloud-node 23.3.0 → 23.5.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,4 +1,83 @@
1
- import Request from 'request';
1
+ import http from 'https';
2
+
3
+ class HttpClient {
4
+ requestAsync(options) {
5
+ //return this.doWithRequest(options);
6
+ return this.doWithHttp(options);
7
+ }
8
+ doWithHttp(options) {
9
+ const url = options.qs ? new URL(`?${new URLSearchParams(options.qs).toString()}`, options.uri) : new URL(options.uri);
10
+ const requestBody = this.buildRequestBody(options);
11
+ const requestOptions = {
12
+ method: options.method,
13
+ headers: options.headers
14
+ };
15
+ const responseEncoding = options.encoding === null ? null : options.encoding || 'utf-8';
16
+ return this.doHttpRequest(url, requestBody, requestOptions, responseEncoding);
17
+ }
18
+ buildRequestBody(options) {
19
+ let requestBody = options.body;
20
+ if (options.form) {
21
+ // Override requestBody for form with form content
22
+ requestBody = new URLSearchParams(options.form).toString();
23
+ options.headers = Object.assign({
24
+ 'Content-Type': 'application/x-www-form-urlencoded'
25
+ }, options.headers);
26
+ }
27
+ if (options.json) {
28
+ // Override requestBody with JSON value
29
+ requestBody = JSON.stringify(options.body);
30
+ options.headers = Object.assign({
31
+ 'Content-Type': 'application/json'
32
+ }, options.headers);
33
+ }
34
+ return requestBody;
35
+ }
36
+ doHttpRequest(url, requestBody, requestOptions, responseEncoding) {
37
+ return new Promise((resolve, reject) => {
38
+ const req = http.request(url, requestOptions, res => {
39
+ if (responseEncoding) {
40
+ // encoding = null for binary responses
41
+ res.setEncoding(responseEncoding);
42
+ }
43
+ const chunks = [];
44
+ res.on('data', chunk => {
45
+ chunks.push(chunk);
46
+ });
47
+ res.on('end', () => {
48
+ const respBody = responseEncoding ? chunks.join('') : Buffer.concat(chunks);
49
+ const response = {
50
+ statusCode: res.statusCode,
51
+ statusMessage: res.statusMessage,
52
+ headers: res.headers,
53
+ body: respBody
54
+ };
55
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
56
+ resolve({
57
+ response: response,
58
+ body: respBody
59
+ });
60
+ } else {
61
+ reject({
62
+ response: response,
63
+ error: new Error(`Error on '${url}': ${res.statusCode} ${res.statusMessage}`)
64
+ });
65
+ }
66
+ });
67
+ });
68
+ req.on('error', error => {
69
+ reject({
70
+ response: null,
71
+ error: error
72
+ });
73
+ });
74
+ if (requestBody) {
75
+ req.write(requestBody);
76
+ }
77
+ req.end();
78
+ });
79
+ }
80
+ }
2
81
 
3
82
  /*
4
83
  * MIT License
@@ -299,6 +378,32 @@ var Code128Emulation;
299
378
  Code128Emulation["Code904"] = "Code904";
300
379
  Code128Emulation["Code905"] = "Code905";
301
380
  })(Code128Emulation || (Code128Emulation = {}));
381
+ /**
382
+ *
383
+ */
384
+ var Code128EncodeMode;
385
+ (function (Code128EncodeMode) {
386
+ Code128EncodeMode["Auto"] = "Auto";
387
+ Code128EncodeMode["CodeA"] = "CodeA";
388
+ Code128EncodeMode["CodeB"] = "CodeB";
389
+ Code128EncodeMode["CodeAB"] = "CodeAB";
390
+ Code128EncodeMode["CodeC"] = "CodeC";
391
+ Code128EncodeMode["CodeAC"] = "CodeAC";
392
+ Code128EncodeMode["CodeBC"] = "CodeBC";
393
+ })(Code128EncodeMode || (Code128EncodeMode = {}));
394
+ /**
395
+ * Code128 params.
396
+ */
397
+ class Code128Params {
398
+ static getAttributeTypeMap() {
399
+ return Code128Params.attributeTypeMap;
400
+ }
401
+ }
402
+ Code128Params.attributeTypeMap = [{
403
+ name: 'encodeMode',
404
+ baseName: 'EncodeMode',
405
+ type: 'Code128EncodeMode'
406
+ }];
302
407
  /**
303
408
  * Code16K parameters.
304
409
  */
@@ -965,6 +1070,10 @@ GeneratorParams.attributeTypeMap = [{
965
1070
  name: 'barWidthReduction',
966
1071
  baseName: 'BarWidthReduction',
967
1072
  type: 'number'
1073
+ }, {
1074
+ name: 'useAntiAlias',
1075
+ baseName: 'UseAntiAlias',
1076
+ type: 'boolean'
968
1077
  }, {
969
1078
  name: 'australianPost',
970
1079
  baseName: 'AustralianPost',
@@ -1025,6 +1134,10 @@ GeneratorParams.attributeTypeMap = [{
1025
1134
  name: 'patchCode',
1026
1135
  baseName: 'PatchCode',
1027
1136
  type: 'PatchCodeParams'
1137
+ }, {
1138
+ name: 'code128',
1139
+ baseName: 'Code128',
1140
+ type: 'Code128Params'
1028
1141
  }];
1029
1142
  /**
1030
1143
  * Represents list of barcode generators
@@ -2200,6 +2313,7 @@ let enumsMap = {
2200
2313
  CodabarChecksumMode: CodabarChecksumMode,
2201
2314
  CodabarSymbol: CodabarSymbol,
2202
2315
  Code128Emulation: Code128Emulation,
2316
+ Code128EncodeMode: Code128EncodeMode,
2203
2317
  CodeLocation: CodeLocation,
2204
2318
  CustomerInformationInterpretingType: CustomerInformationInterpretingType,
2205
2319
  DataMatrixEccType: DataMatrixEccType,
@@ -2236,6 +2350,7 @@ let typeMap = {
2236
2350
  CaptionParams: CaptionParams,
2237
2351
  CodabarParams: CodabarParams,
2238
2352
  CodablockParams: CodablockParams,
2353
+ Code128Params: Code128Params,
2239
2354
  Code16KParams: Code16KParams,
2240
2355
  CouponParams: CouponParams,
2241
2356
  DataBarParams: DataBarParams,
@@ -2270,6 +2385,7 @@ class BarcodeApi {
2270
2385
  constructor(configuration) {
2271
2386
  this.defaultHeaders = {};
2272
2387
  this._configuration = configuration;
2388
+ this._client = new HttpClient();
2273
2389
  }
2274
2390
  /**
2275
2391
  *
@@ -2390,6 +2506,9 @@ class BarcodeApi {
2390
2506
  if (request.barWidthReduction != null) {
2391
2507
  requestQueryParameters['BarWidthReduction'] = ObjectSerializer.serialize(request.barWidthReduction, 'number');
2392
2508
  }
2509
+ if (request.useAntiAlias != null) {
2510
+ requestQueryParameters['UseAntiAlias'] = ObjectSerializer.serialize(request.useAntiAlias, 'boolean');
2511
+ }
2393
2512
  if (request.format != null) {
2394
2513
  requestQueryParameters['format'] = ObjectSerializer.serialize(request.format, 'string');
2395
2514
  }
@@ -2401,29 +2520,11 @@ class BarcodeApi {
2401
2520
  encoding: null
2402
2521
  };
2403
2522
  await this._configuration.authentication.applyToRequest(requestOptions);
2404
- return await new Promise((resolve, reject) => {
2405
- const handler = async (error, response, body, allowRepeat) => {
2406
- if (error) {
2407
- reject(error);
2408
- } else {
2409
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2410
- resolve({
2411
- response: response,
2412
- body: ObjectSerializer.deserialize(body, 'Buffer')
2413
- });
2414
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
2415
- await this._configuration.authentication.applyUnauthorized();
2416
- await handler(error, response, body, false);
2417
- } else {
2418
- reject({
2419
- response: response,
2420
- body: body
2421
- });
2422
- }
2423
- }
2424
- };
2425
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
2426
- });
2523
+ const result = await this._client.requestAsync(requestOptions);
2524
+ return {
2525
+ response: result.response,
2526
+ body: ObjectSerializer.deserialize(result.body, 'Buffer')
2527
+ };
2427
2528
  }
2428
2529
  /**
2429
2530
  *
@@ -2540,9 +2641,6 @@ class BarcodeApi {
2540
2641
  if (request.ignoreEndingFillingPatternsForCTable != null) {
2541
2642
  requestQueryParameters['IgnoreEndingFillingPatternsForCTable'] = ObjectSerializer.serialize(request.ignoreEndingFillingPatternsForCTable, 'boolean');
2542
2643
  }
2543
- if (request.rectangleRegion != null) {
2544
- requestQueryParameters['RectangleRegion'] = ObjectSerializer.serialize(request.rectangleRegion, 'string');
2545
- }
2546
2644
  if (request.storage != null) {
2547
2645
  requestQueryParameters['storage'] = ObjectSerializer.serialize(request.storage, 'string');
2548
2646
  }
@@ -2556,29 +2654,11 @@ class BarcodeApi {
2556
2654
  uri: requestPath
2557
2655
  };
2558
2656
  await this._configuration.authentication.applyToRequest(requestOptions);
2559
- return await new Promise((resolve, reject) => {
2560
- const handler = async (error, response, body, allowRepeat) => {
2561
- if (error) {
2562
- reject(error);
2563
- } else {
2564
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2565
- resolve({
2566
- response: response,
2567
- body: ObjectSerializer.deserialize(body, 'BarcodeResponseList')
2568
- });
2569
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
2570
- await this._configuration.authentication.applyUnauthorized();
2571
- await handler(error, response, body, false);
2572
- } else {
2573
- reject({
2574
- response: response,
2575
- body: body
2576
- });
2577
- }
2578
- }
2579
- };
2580
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
2581
- });
2657
+ const result = await this._client.requestAsync(requestOptions);
2658
+ return {
2659
+ response: result.response,
2660
+ body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
2661
+ };
2582
2662
  }
2583
2663
  /**
2584
2664
  *
@@ -2691,9 +2771,6 @@ class BarcodeApi {
2691
2771
  if (request.ignoreEndingFillingPatternsForCTable != null) {
2692
2772
  requestQueryParameters['IgnoreEndingFillingPatternsForCTable'] = ObjectSerializer.serialize(request.ignoreEndingFillingPatternsForCTable, 'boolean');
2693
2773
  }
2694
- if (request.rectangleRegion != null) {
2695
- requestQueryParameters['RectangleRegion'] = ObjectSerializer.serialize(request.rectangleRegion, 'string');
2696
- }
2697
2774
  if (request.url != null) {
2698
2775
  requestQueryParameters['url'] = ObjectSerializer.serialize(request.url, 'string');
2699
2776
  }
@@ -2705,29 +2782,11 @@ class BarcodeApi {
2705
2782
  body: request.image
2706
2783
  };
2707
2784
  await this._configuration.authentication.applyToRequest(requestOptions);
2708
- return await new Promise((resolve, reject) => {
2709
- const handler = async (error, response, body, allowRepeat) => {
2710
- if (error) {
2711
- reject(error);
2712
- } else {
2713
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2714
- resolve({
2715
- response: response,
2716
- body: ObjectSerializer.deserialize(body, 'BarcodeResponseList')
2717
- });
2718
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
2719
- await this._configuration.authentication.applyUnauthorized();
2720
- await handler(error, response, body, false);
2721
- } else {
2722
- reject({
2723
- response: response,
2724
- body: body
2725
- });
2726
- }
2727
- }
2728
- };
2729
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
2730
- });
2785
+ const result = await this._client.requestAsync(requestOptions);
2786
+ return {
2787
+ response: result.response,
2788
+ body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
2789
+ };
2731
2790
  }
2732
2791
  /**
2733
2792
  *
@@ -2755,29 +2814,11 @@ class BarcodeApi {
2755
2814
  encoding: null
2756
2815
  };
2757
2816
  await this._configuration.authentication.applyToRequest(requestOptions);
2758
- return await new Promise((resolve, reject) => {
2759
- const handler = async (error, response, body, allowRepeat) => {
2760
- if (error) {
2761
- reject(error);
2762
- } else {
2763
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2764
- resolve({
2765
- response: response,
2766
- body: ObjectSerializer.deserialize(body, 'Buffer')
2767
- });
2768
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
2769
- await this._configuration.authentication.applyUnauthorized();
2770
- await handler(error, response, body, false);
2771
- } else {
2772
- reject({
2773
- response: response,
2774
- body: body
2775
- });
2776
- }
2777
- }
2778
- };
2779
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
2780
- });
2817
+ const result = await this._client.requestAsync(requestOptions);
2818
+ return {
2819
+ response: result.response,
2820
+ body: ObjectSerializer.deserialize(result.body, 'Buffer')
2821
+ };
2781
2822
  }
2782
2823
  /**
2783
2824
  *
@@ -2902,6 +2943,9 @@ class BarcodeApi {
2902
2943
  if (request.barWidthReduction != null) {
2903
2944
  requestQueryParameters['BarWidthReduction'] = ObjectSerializer.serialize(request.barWidthReduction, 'number');
2904
2945
  }
2946
+ if (request.useAntiAlias != null) {
2947
+ requestQueryParameters['UseAntiAlias'] = ObjectSerializer.serialize(request.useAntiAlias, 'boolean');
2948
+ }
2905
2949
  if (request.storage != null) {
2906
2950
  requestQueryParameters['storage'] = ObjectSerializer.serialize(request.storage, 'string');
2907
2951
  }
@@ -2918,29 +2962,11 @@ class BarcodeApi {
2918
2962
  uri: requestPath
2919
2963
  };
2920
2964
  await this._configuration.authentication.applyToRequest(requestOptions);
2921
- return await new Promise((resolve, reject) => {
2922
- const handler = async (error, response, body, allowRepeat) => {
2923
- if (error) {
2924
- reject(error);
2925
- } else {
2926
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2927
- resolve({
2928
- response: response,
2929
- body: ObjectSerializer.deserialize(body, 'ResultImageInfo')
2930
- });
2931
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
2932
- await this._configuration.authentication.applyUnauthorized();
2933
- await handler(error, response, body, false);
2934
- } else {
2935
- reject({
2936
- response: response,
2937
- body: body
2938
- });
2939
- }
2940
- }
2941
- };
2942
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
2943
- });
2965
+ const result = await this._client.requestAsync(requestOptions);
2966
+ return {
2967
+ response: result.response,
2968
+ body: ObjectSerializer.deserialize(result.body, 'ResultImageInfo')
2969
+ };
2944
2970
  }
2945
2971
  /**
2946
2972
  *
@@ -2977,29 +3003,11 @@ class BarcodeApi {
2977
3003
  json: true
2978
3004
  };
2979
3005
  await this._configuration.authentication.applyToRequest(requestOptions);
2980
- return await new Promise((resolve, reject) => {
2981
- const handler = async (error, response, body, allowRepeat) => {
2982
- if (error) {
2983
- reject(error);
2984
- } else {
2985
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2986
- resolve({
2987
- response: response,
2988
- body: ObjectSerializer.deserialize(body, 'BarcodeResponseList')
2989
- });
2990
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
2991
- await this._configuration.authentication.applyUnauthorized();
2992
- await handler(error, response, body, false);
2993
- } else {
2994
- reject({
2995
- response: response,
2996
- body: body
2997
- });
2998
- }
2999
- }
3000
- };
3001
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3002
- });
3006
+ const result = await this._client.requestAsync(requestOptions);
3007
+ return {
3008
+ response: result.response,
3009
+ body: ObjectSerializer.deserialize(result.body, 'BarcodeResponseList')
3010
+ };
3003
3011
  }
3004
3012
  /**
3005
3013
  *
@@ -3036,35 +3044,18 @@ class BarcodeApi {
3036
3044
  json: true
3037
3045
  };
3038
3046
  await this._configuration.authentication.applyToRequest(requestOptions);
3039
- return await new Promise((resolve, reject) => {
3040
- const handler = async (error, response, body, allowRepeat) => {
3041
- if (error) {
3042
- reject(error);
3043
- } else {
3044
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3045
- resolve({
3046
- response: response,
3047
- body: ObjectSerializer.deserialize(body, 'ResultImageInfo')
3048
- });
3049
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3050
- await this._configuration.authentication.applyUnauthorized();
3051
- await handler(error, response, body, false);
3052
- } else {
3053
- reject({
3054
- response: response,
3055
- body: body
3056
- });
3057
- }
3058
- }
3059
- };
3060
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3061
- });
3047
+ const result = await this._client.requestAsync(requestOptions);
3048
+ return {
3049
+ response: result.response,
3050
+ body: ObjectSerializer.deserialize(result.body, 'ResultImageInfo')
3051
+ };
3062
3052
  }
3063
3053
  }
3064
3054
  class FileApi {
3065
3055
  constructor(configuration) {
3066
3056
  this.defaultHeaders = {};
3067
3057
  this._configuration = configuration;
3058
+ this._client = new HttpClient();
3068
3059
  }
3069
3060
  /**
3070
3061
  *
@@ -3102,28 +3093,8 @@ class FileApi {
3102
3093
  uri: requestPath
3103
3094
  };
3104
3095
  await this._configuration.authentication.applyToRequest(requestOptions);
3105
- return await new Promise((resolve, reject) => {
3106
- const handler = async (error, response, body, allowRepeat) => {
3107
- if (error) {
3108
- reject(error);
3109
- } else {
3110
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3111
- resolve({
3112
- response: response
3113
- });
3114
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3115
- await this._configuration.authentication.applyUnauthorized();
3116
- await handler(error, response, body, false);
3117
- } else {
3118
- reject({
3119
- response: response,
3120
- body: body
3121
- });
3122
- }
3123
- }
3124
- };
3125
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3126
- });
3096
+ const result = await this._client.requestAsync(requestOptions);
3097
+ return result;
3127
3098
  }
3128
3099
  /**
3129
3100
  *
@@ -3151,28 +3122,8 @@ class FileApi {
3151
3122
  uri: requestPath
3152
3123
  };
3153
3124
  await this._configuration.authentication.applyToRequest(requestOptions);
3154
- return await new Promise((resolve, reject) => {
3155
- const handler = async (error, response, body, allowRepeat) => {
3156
- if (error) {
3157
- reject(error);
3158
- } else {
3159
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3160
- resolve({
3161
- response: response
3162
- });
3163
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3164
- await this._configuration.authentication.applyUnauthorized();
3165
- await handler(error, response, body, false);
3166
- } else {
3167
- reject({
3168
- response: response,
3169
- body: body
3170
- });
3171
- }
3172
- }
3173
- };
3174
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3175
- });
3125
+ const result = await this._client.requestAsync(requestOptions);
3126
+ return result;
3176
3127
  }
3177
3128
  /**
3178
3129
  *
@@ -3201,29 +3152,11 @@ class FileApi {
3201
3152
  encoding: null
3202
3153
  };
3203
3154
  await this._configuration.authentication.applyToRequest(requestOptions);
3204
- return await new Promise((resolve, reject) => {
3205
- const handler = async (error, response, body, allowRepeat) => {
3206
- if (error) {
3207
- reject(error);
3208
- } else {
3209
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3210
- resolve({
3211
- response: response,
3212
- body: ObjectSerializer.deserialize(body, 'Buffer')
3213
- });
3214
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3215
- await this._configuration.authentication.applyUnauthorized();
3216
- await handler(error, response, body, false);
3217
- } else {
3218
- reject({
3219
- response: response,
3220
- body: body
3221
- });
3222
- }
3223
- }
3224
- };
3225
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3226
- });
3155
+ const result = await this._client.requestAsync(requestOptions);
3156
+ return {
3157
+ response: result.response,
3158
+ body: ObjectSerializer.deserialize(result.body, 'Buffer')
3159
+ };
3227
3160
  }
3228
3161
  /**
3229
3162
  *
@@ -3261,28 +3194,8 @@ class FileApi {
3261
3194
  uri: requestPath
3262
3195
  };
3263
3196
  await this._configuration.authentication.applyToRequest(requestOptions);
3264
- return await new Promise((resolve, reject) => {
3265
- const handler = async (error, response, body, allowRepeat) => {
3266
- if (error) {
3267
- reject(error);
3268
- } else {
3269
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3270
- resolve({
3271
- response: response
3272
- });
3273
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3274
- await this._configuration.authentication.applyUnauthorized();
3275
- await handler(error, response, body, false);
3276
- } else {
3277
- reject({
3278
- response: response,
3279
- body: body
3280
- });
3281
- }
3282
- }
3283
- };
3284
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3285
- });
3197
+ const result = await this._client.requestAsync(requestOptions);
3198
+ return result;
3286
3199
  }
3287
3200
  /**
3288
3201
  *
@@ -3312,35 +3225,18 @@ class FileApi {
3312
3225
  body: request.file
3313
3226
  };
3314
3227
  await this._configuration.authentication.applyToRequest(requestOptions);
3315
- return await new Promise((resolve, reject) => {
3316
- const handler = async (error, response, body, allowRepeat) => {
3317
- if (error) {
3318
- reject(error);
3319
- } else {
3320
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3321
- resolve({
3322
- response: response,
3323
- body: ObjectSerializer.deserialize(body, 'FilesUploadResult')
3324
- });
3325
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3326
- await this._configuration.authentication.applyUnauthorized();
3327
- await handler(error, response, body, false);
3328
- } else {
3329
- reject({
3330
- response: response,
3331
- body: body
3332
- });
3333
- }
3334
- }
3335
- };
3336
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3337
- });
3228
+ const result = await this._client.requestAsync(requestOptions);
3229
+ return {
3230
+ response: result.response,
3231
+ body: ObjectSerializer.deserialize(result.body, 'FilesUploadResult')
3232
+ };
3338
3233
  }
3339
3234
  }
3340
3235
  class FolderApi {
3341
3236
  constructor(configuration) {
3342
3237
  this.defaultHeaders = {};
3343
3238
  this._configuration = configuration;
3239
+ this._client = new HttpClient();
3344
3240
  }
3345
3241
  /**
3346
3242
  *
@@ -3375,28 +3271,8 @@ class FolderApi {
3375
3271
  uri: requestPath
3376
3272
  };
3377
3273
  await this._configuration.authentication.applyToRequest(requestOptions);
3378
- return await new Promise((resolve, reject) => {
3379
- const handler = async (error, response, body, allowRepeat) => {
3380
- if (error) {
3381
- reject(error);
3382
- } else {
3383
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3384
- resolve({
3385
- response: response
3386
- });
3387
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3388
- await this._configuration.authentication.applyUnauthorized();
3389
- await handler(error, response, body, false);
3390
- } else {
3391
- reject({
3392
- response: response,
3393
- body: body
3394
- });
3395
- }
3396
- }
3397
- };
3398
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3399
- });
3274
+ const result = await this._client.requestAsync(requestOptions);
3275
+ return result;
3400
3276
  }
3401
3277
  /**
3402
3278
  *
@@ -3421,28 +3297,8 @@ class FolderApi {
3421
3297
  uri: requestPath
3422
3298
  };
3423
3299
  await this._configuration.authentication.applyToRequest(requestOptions);
3424
- return await new Promise((resolve, reject) => {
3425
- const handler = async (error, response, body, allowRepeat) => {
3426
- if (error) {
3427
- reject(error);
3428
- } else {
3429
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3430
- resolve({
3431
- response: response
3432
- });
3433
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3434
- await this._configuration.authentication.applyUnauthorized();
3435
- await handler(error, response, body, false);
3436
- } else {
3437
- reject({
3438
- response: response,
3439
- body: body
3440
- });
3441
- }
3442
- }
3443
- };
3444
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3445
- });
3300
+ const result = await this._client.requestAsync(requestOptions);
3301
+ return result;
3446
3302
  }
3447
3303
  /**
3448
3304
  *
@@ -3470,28 +3326,8 @@ class FolderApi {
3470
3326
  uri: requestPath
3471
3327
  };
3472
3328
  await this._configuration.authentication.applyToRequest(requestOptions);
3473
- return await new Promise((resolve, reject) => {
3474
- const handler = async (error, response, body, allowRepeat) => {
3475
- if (error) {
3476
- reject(error);
3477
- } else {
3478
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3479
- resolve({
3480
- response: response
3481
- });
3482
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3483
- await this._configuration.authentication.applyUnauthorized();
3484
- await handler(error, response, body, false);
3485
- } else {
3486
- reject({
3487
- response: response,
3488
- body: body
3489
- });
3490
- }
3491
- }
3492
- };
3493
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3494
- });
3329
+ const result = await this._client.requestAsync(requestOptions);
3330
+ return result;
3495
3331
  }
3496
3332
  /**
3497
3333
  *
@@ -3516,29 +3352,11 @@ class FolderApi {
3516
3352
  uri: requestPath
3517
3353
  };
3518
3354
  await this._configuration.authentication.applyToRequest(requestOptions);
3519
- return await new Promise((resolve, reject) => {
3520
- const handler = async (error, response, body, allowRepeat) => {
3521
- if (error) {
3522
- reject(error);
3523
- } else {
3524
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3525
- resolve({
3526
- response: response,
3527
- body: ObjectSerializer.deserialize(body, 'FilesList')
3528
- });
3529
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3530
- await this._configuration.authentication.applyUnauthorized();
3531
- await handler(error, response, body, false);
3532
- } else {
3533
- reject({
3534
- response: response,
3535
- body: body
3536
- });
3537
- }
3538
- }
3539
- };
3540
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3541
- });
3355
+ const result = await this._client.requestAsync(requestOptions);
3356
+ return {
3357
+ response: result.response,
3358
+ body: ObjectSerializer.deserialize(result.body, 'FilesList')
3359
+ };
3542
3360
  }
3543
3361
  /**
3544
3362
  *
@@ -3573,34 +3391,15 @@ class FolderApi {
3573
3391
  uri: requestPath
3574
3392
  };
3575
3393
  await this._configuration.authentication.applyToRequest(requestOptions);
3576
- return await new Promise((resolve, reject) => {
3577
- const handler = async (error, response, body, allowRepeat) => {
3578
- if (error) {
3579
- reject(error);
3580
- } else {
3581
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3582
- resolve({
3583
- response: response
3584
- });
3585
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3586
- await this._configuration.authentication.applyUnauthorized();
3587
- await handler(error, response, body, false);
3588
- } else {
3589
- reject({
3590
- response: response,
3591
- body: body
3592
- });
3593
- }
3594
- }
3595
- };
3596
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3597
- });
3394
+ const result = await this._client.requestAsync(requestOptions);
3395
+ return result;
3598
3396
  }
3599
3397
  }
3600
3398
  class StorageApi {
3601
3399
  constructor(configuration) {
3602
3400
  this.defaultHeaders = {};
3603
3401
  this._configuration = configuration;
3402
+ this._client = new HttpClient();
3604
3403
  }
3605
3404
  /**
3606
3405
  *
@@ -3621,29 +3420,11 @@ class StorageApi {
3621
3420
  uri: requestPath
3622
3421
  };
3623
3422
  await this._configuration.authentication.applyToRequest(requestOptions);
3624
- return await new Promise((resolve, reject) => {
3625
- const handler = async (error, response, body, allowRepeat) => {
3626
- if (error) {
3627
- reject(error);
3628
- } else {
3629
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3630
- resolve({
3631
- response: response,
3632
- body: ObjectSerializer.deserialize(body, 'DiscUsage')
3633
- });
3634
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3635
- await this._configuration.authentication.applyUnauthorized();
3636
- await handler(error, response, body, false);
3637
- } else {
3638
- reject({
3639
- response: response,
3640
- body: body
3641
- });
3642
- }
3643
- }
3644
- };
3645
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3646
- });
3423
+ const result = await this._client.requestAsync(requestOptions);
3424
+ return {
3425
+ response: result.response,
3426
+ body: ObjectSerializer.deserialize(result.body, 'DiscUsage')
3427
+ };
3647
3428
  }
3648
3429
  /**
3649
3430
  *
@@ -3668,29 +3449,11 @@ class StorageApi {
3668
3449
  uri: requestPath
3669
3450
  };
3670
3451
  await this._configuration.authentication.applyToRequest(requestOptions);
3671
- return await new Promise((resolve, reject) => {
3672
- const handler = async (error, response, body, allowRepeat) => {
3673
- if (error) {
3674
- reject(error);
3675
- } else {
3676
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3677
- resolve({
3678
- response: response,
3679
- body: ObjectSerializer.deserialize(body, 'FileVersions')
3680
- });
3681
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3682
- await this._configuration.authentication.applyUnauthorized();
3683
- await handler(error, response, body, false);
3684
- } else {
3685
- reject({
3686
- response: response,
3687
- body: body
3688
- });
3689
- }
3690
- }
3691
- };
3692
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3693
- });
3452
+ const result = await this._client.requestAsync(requestOptions);
3453
+ return {
3454
+ response: result.response,
3455
+ body: ObjectSerializer.deserialize(result.body, 'FileVersions')
3456
+ };
3694
3457
  }
3695
3458
  /**
3696
3459
  *
@@ -3718,29 +3481,11 @@ class StorageApi {
3718
3481
  uri: requestPath
3719
3482
  };
3720
3483
  await this._configuration.authentication.applyToRequest(requestOptions);
3721
- return await new Promise((resolve, reject) => {
3722
- const handler = async (error, response, body, allowRepeat) => {
3723
- if (error) {
3724
- reject(error);
3725
- } else {
3726
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3727
- resolve({
3728
- response: response,
3729
- body: ObjectSerializer.deserialize(body, 'ObjectExist')
3730
- });
3731
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3732
- await this._configuration.authentication.applyUnauthorized();
3733
- await handler(error, response, body, false);
3734
- } else {
3735
- reject({
3736
- response: response,
3737
- body: body
3738
- });
3739
- }
3740
- }
3741
- };
3742
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3743
- });
3484
+ const result = await this._client.requestAsync(requestOptions);
3485
+ return {
3486
+ response: result.response,
3487
+ body: ObjectSerializer.deserialize(result.body, 'ObjectExist')
3488
+ };
3744
3489
  }
3745
3490
  /**
3746
3491
  *
@@ -3762,29 +3507,11 @@ class StorageApi {
3762
3507
  uri: requestPath
3763
3508
  };
3764
3509
  await this._configuration.authentication.applyToRequest(requestOptions);
3765
- return await new Promise((resolve, reject) => {
3766
- const handler = async (error, response, body, allowRepeat) => {
3767
- if (error) {
3768
- reject(error);
3769
- } else {
3770
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3771
- resolve({
3772
- response: response,
3773
- body: ObjectSerializer.deserialize(body, 'StorageExist')
3774
- });
3775
- } else if (allowRepeat && response.statusCode && response.statusCode === 401) {
3776
- await this._configuration.authentication.applyUnauthorized();
3777
- await handler(error, response, body, false);
3778
- } else {
3779
- reject({
3780
- response: response,
3781
- body: body
3782
- });
3783
- }
3784
- }
3785
- };
3786
- Request(requestOptions, (error, response, body) => handler(error, response, body, true));
3787
- });
3510
+ const result = await this._client.requestAsync(requestOptions);
3511
+ return {
3512
+ response: result.response,
3513
+ body: ObjectSerializer.deserialize(result.body, 'StorageExist')
3514
+ };
3788
3515
  }
3789
3516
  }
3790
3517
 
@@ -3795,30 +3522,26 @@ class JWTAuth {
3795
3522
  // Use saved token
3796
3523
  this._accessToken = configuration.accessToken;
3797
3524
  }
3525
+ this._client = new HttpClient();
3798
3526
  }
3799
3527
  /**
3800
3528
  * Apply authentication settings to header and query params.
3801
3529
  */
3802
3530
  async applyToRequest(requestOptions) {
3803
3531
  if (this._accessToken == null) {
3804
- await this.requestToken();
3532
+ this._accessToken = await this.requestToken();
3805
3533
  }
3806
3534
  if (requestOptions && requestOptions.headers) {
3807
3535
  requestOptions.headers.Authorization = 'Bearer ' + this._accessToken;
3808
3536
  }
3809
3537
  return Promise.resolve();
3810
3538
  }
3811
- async applyUnauthorized() {
3812
- if (this._configuration.clientId && this._configuration.clientSecret) {
3813
- await this.requestToken();
3814
- } else {
3539
+ async requestToken() {
3540
+ if (!this._configuration.clientId || !this._configuration.clientSecret) {
3815
3541
  throw new Error("Required 'clientId' or 'clientSecret' not specified in configuration.");
3816
3542
  }
3817
- }
3818
- requestToken() {
3819
3543
  const requestOptions = {
3820
3544
  method: 'POST',
3821
- json: true,
3822
3545
  uri: this._configuration.tokenUrl,
3823
3546
  form: {
3824
3547
  grant_type: 'client_credentials',
@@ -3826,22 +3549,9 @@ class JWTAuth {
3826
3549
  client_secret: this._configuration.clientSecret
3827
3550
  }
3828
3551
  };
3829
- return new Promise((resolve, reject) => {
3830
- const self = this;
3831
- Request(requestOptions, (error, response) => {
3832
- if (error) {
3833
- reject(error);
3834
- } else {
3835
- if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
3836
- self._accessToken = response.body.access_token;
3837
- resolve();
3838
- } else {
3839
- var _response$body;
3840
- reject((_response$body = response.body) != null ? _response$body : `Error fetching token from '${requestOptions.uri}': ${response.statusCode} ${response.statusMessage}`);
3841
- }
3842
- }
3843
- });
3844
- });
3552
+ const result = await this._client.requestAsync(requestOptions);
3553
+ const parsed = JSON.parse(result.body);
3554
+ return parsed.access_token;
3845
3555
  }
3846
3556
  }
3847
3557
 
@@ -3875,5 +3585,5 @@ class Configuration {
3875
3585
  }
3876
3586
  }
3877
3587
 
3878
- export { ApiError, ApiErrorResponse, ApiVersion, AustralianPostParams, AutoSizeMode, AvailableGraphicsUnit, AztecParams, AztecSymbolMode, BarcodeApi, BarcodeResponse, BarcodeResponseList, BorderDashStyle, CaptionParams, ChecksumValidation, CodabarChecksumMode, CodabarParams, CodabarSymbol, CodablockParams, Code128Emulation, Code16KParams, CodeLocation, Configuration, CopyFileRequest, CopyFolderRequest, CouponParams, CreateFolderRequest, CustomerInformationInterpretingType, DataBarParams, DataMatrixEccType, DataMatrixEncodeMode, DataMatrixParams, DecodeBarcodeType, DeleteFileRequest, DeleteFolderRequest, DiscUsage, DotCodeEncodeMode, DotCodeParams, DownloadFileRequest, ECIEncodings, EnableChecksum, EncodeBarcodeType, ErrorDetails, FileApi, FileVersion, FileVersions, FilesList, FilesUploadResult, FolderApi, FontMode, FontParams, FontStyle, GeneratorParams, GeneratorParamsList, GetBarcodeGenerateRequest, GetBarcodeRecognizeRequest, GetDiscUsageRequest, GetFileVersionsRequest, GetFilesListRequest, ITF14BorderType, ITFParams, MacroCharacter, MaxiCodeEncodeMode, MaxiCodeMode, MaxiCodeParams, ModelError, MoveFileRequest, MoveFolderRequest, ObjectExist, ObjectExistsRequest, Padding, PatchCodeParams, PatchFormat, Pdf417CompactionMode, Pdf417ErrorLevel, Pdf417MacroTerminator, Pdf417Params, PostBarcodeRecognizeFromUrlOrContentRequest, PostGenerateMultipleRequest, PostalParams, PresetType, PutBarcodeGenerateFileRequest, PutBarcodeRecognizeFromBodyRequest, PutGenerateMultipleRequest, QREncodeMode, QREncodeType, QRErrorLevel, QRVersion, QrParams, ReaderParams, RegionPoint, ResultImageInfo, StorageApi, StorageExist, StorageExistsRequest, StorageFile, StructuredAppend, TextAlignment, UploadFileRequest };
3588
+ export { ApiError, ApiErrorResponse, ApiVersion, AustralianPostParams, AutoSizeMode, AvailableGraphicsUnit, AztecParams, AztecSymbolMode, BarcodeApi, BarcodeResponse, BarcodeResponseList, BorderDashStyle, CaptionParams, ChecksumValidation, CodabarChecksumMode, CodabarParams, CodabarSymbol, CodablockParams, Code128Emulation, Code128EncodeMode, Code128Params, Code16KParams, CodeLocation, Configuration, CopyFileRequest, CopyFolderRequest, CouponParams, CreateFolderRequest, CustomerInformationInterpretingType, DataBarParams, DataMatrixEccType, DataMatrixEncodeMode, DataMatrixParams, DecodeBarcodeType, DeleteFileRequest, DeleteFolderRequest, DiscUsage, DotCodeEncodeMode, DotCodeParams, DownloadFileRequest, ECIEncodings, EnableChecksum, EncodeBarcodeType, ErrorDetails, FileApi, FileVersion, FileVersions, FilesList, FilesUploadResult, FolderApi, FontMode, FontParams, FontStyle, GeneratorParams, GeneratorParamsList, GetBarcodeGenerateRequest, GetBarcodeRecognizeRequest, GetDiscUsageRequest, GetFileVersionsRequest, GetFilesListRequest, HttpClient, ITF14BorderType, ITFParams, MacroCharacter, MaxiCodeEncodeMode, MaxiCodeMode, MaxiCodeParams, ModelError, MoveFileRequest, MoveFolderRequest, ObjectExist, ObjectExistsRequest, Padding, PatchCodeParams, PatchFormat, Pdf417CompactionMode, Pdf417ErrorLevel, Pdf417MacroTerminator, Pdf417Params, PostBarcodeRecognizeFromUrlOrContentRequest, PostGenerateMultipleRequest, PostalParams, PresetType, PutBarcodeGenerateFileRequest, PutBarcodeRecognizeFromBodyRequest, PutGenerateMultipleRequest, QREncodeMode, QREncodeType, QRErrorLevel, QRVersion, QrParams, ReaderParams, RegionPoint, ResultImageInfo, StorageApi, StorageExist, StorageExistsRequest, StorageFile, StructuredAppend, TextAlignment, UploadFileRequest };
3879
3589
  //# sourceMappingURL=aspose-barcode-cloud-node.esm.js.map