@shipengine/js-api 0.14.2 → 0.16.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.
Files changed (4) hide show
  1. package/carriers/api.d.ts +7 -1
  2. package/index.js +139 -2095
  3. package/index.mjs +139 -2095
  4. package/package.json +4 -1
package/index.mjs CHANGED
@@ -1,2117 +1,155 @@
1
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
3
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
4
- var __objRest$1 = (source, exclude) => {
5
- var target = {};
6
- for (var prop in source)
7
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
8
- target[prop] = source[prop];
9
- if (source != null && __getOwnPropSymbols$3)
10
- for (var prop of __getOwnPropSymbols$3(source)) {
11
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
12
- target[prop] = source[prop];
13
- }
14
- return target;
15
- };
16
- class CodedError {
17
- constructor(message, options) {
18
- var _a, _b, _c;
19
- this.errorCode = (_a = options == null ? void 0 : options.errorCode) != null ? _a : "unknown";
20
- this.errorSource = (_b = options == null ? void 0 : options.errorSource) != null ? _b : "client";
21
- this.errorType = (_c = options == null ? void 0 : options.errorType) != null ? _c : "unknown";
22
- this.message = message;
23
- }
24
- static fromObject(_a) {
25
- var _b = _a, { message } = _b, options = __objRest$1(_b, ["message"]);
26
- return new CodedError(message, options);
27
- }
28
- }
29
-
30
- var CreditCardVendor = /* @__PURE__ */ ((CreditCardVendor2) => {
31
- CreditCardVendor2["AMERICAN_EXPRESS"] = "americanexpress";
32
- CreditCardVendor2["DISCOVER"] = "discover";
33
- CreditCardVendor2["MASTERCARD"] = "mastercard";
34
- CreditCardVendor2["VISA"] = "visa";
35
- return CreditCardVendor2;
36
- })(CreditCardVendor || {});
37
- var Currency = /* @__PURE__ */ ((Currency2) => {
38
- Currency2["USD"] = "usd";
39
- Currency2["CAD"] = "cad";
40
- Currency2["AUD"] = "aud";
41
- Currency2["GBP"] = "gbp";
42
- Currency2["EUR"] = "eur";
43
- Currency2["NZD"] = "nzd";
44
- return Currency2;
45
- })(Currency || {});
46
-
47
- var ConfirmationType = /* @__PURE__ */ ((ConfirmationType2) => {
48
- ConfirmationType2["DELIVERY"] = "delivery";
49
- ConfirmationType2["SIGNATURE"] = "signature";
50
- ConfirmationType2["ADULT_SIGNATURE"] = "adult_signature";
51
- ConfirmationType2["DIRECT_SIGNATURE"] = "direct_signature";
52
- ConfirmationType2["VERBAL_CONFIRMATION"] = "verbal_confirmation";
53
- ConfirmationType2["DELIVERY_MAILED"] = "delivery_mailed";
54
- ConfirmationType2["NONE"] = "none";
55
- return ConfirmationType2;
56
- })(ConfirmationType || {});
57
- var CustomsContentsType = /* @__PURE__ */ ((CustomsContentsType2) => {
58
- CustomsContentsType2["DOCUMENTS"] = "documents";
59
- CustomsContentsType2["GIFT"] = "gift";
60
- CustomsContentsType2["MERCHANDISE"] = "merchandise";
61
- CustomsContentsType2["RETURNED_GOODS"] = "returned_goods";
62
- CustomsContentsType2["SAMPLE"] = "sample";
63
- return CustomsContentsType2;
64
- })(CustomsContentsType || {});
65
- var CustomsNonDeliveryType = /* @__PURE__ */ ((CustomsNonDeliveryType2) => {
66
- CustomsNonDeliveryType2["RETURN_TO_SENDER"] = "return_to_sender";
67
- CustomsNonDeliveryType2["TREAT_AS_ABANDONED"] = "treat_as_abandoned";
68
- return CustomsNonDeliveryType2;
69
- })(CustomsNonDeliveryType || {});
70
- var InsuranceProviderType = /* @__PURE__ */ ((InsuranceProviderType2) => {
71
- InsuranceProviderType2["SHIPSURANCE"] = "shipsurance";
72
- InsuranceProviderType2["CARRIER"] = "carrier";
73
- InsuranceProviderType2["THIRD_PARTY"] = "third_party";
74
- InsuranceProviderType2["NONE"] = "none";
75
- return InsuranceProviderType2;
76
- })(InsuranceProviderType || {});
77
-
78
- const types = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
79
- __proto__: null,
80
- CodedError,
81
- ConfirmationType,
82
- CreditCardVendor,
83
- Currency,
84
- CustomsContentsType,
85
- CustomsNonDeliveryType,
86
- InsuranceProviderType
87
- }, Symbol.toStringTag, { value: 'Module' }));
88
-
89
- class AccountSettingsAPI {
90
- constructor(client) {
91
- this.client = client;
92
- this.get = () => {
93
- return this.client.get("/v1/account/settings");
94
- };
95
- this.update = (settings) => {
96
- return this.client.put("/v1/account/settings", settings);
97
- };
98
- this.client = client;
99
- }
100
- }
101
-
102
- class AddressesAPI {
103
- constructor(client) {
104
- this.client = client;
105
- this.validate = (addresses) => {
106
- return this.client.post("/v1/addresses/validate", addresses);
107
- };
108
- this.parse = (text, address) => {
109
- return this.client.put("/v1/addresses/recognize", {
110
- address,
111
- text
112
- });
113
- };
114
- this.client = client;
115
- }
116
- }
117
-
118
- const isCodedErrors = (errs) => Array.isArray(errs) && errs.every((err) => isCodedError(err));
119
- const isCodedError = (err) => !!err.errorCode;
120
-
121
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
122
-
123
- function getDefaultExportFromCjs (x) {
124
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
125
- }
126
-
127
- function getAugmentedNamespace(n) {
128
- if (n.__esModule) return n;
129
- var f = n.default;
130
- if (typeof f == "function") {
131
- var a = function a () {
132
- if (this instanceof a) {
133
- var args = [null];
134
- args.push.apply(args, arguments);
135
- var Ctor = Function.bind.apply(f, args);
136
- return new Ctor();
137
- }
138
- return f.apply(this, arguments);
139
- };
140
- a.prototype = f.prototype;
141
- } else a = {};
142
- Object.defineProperty(a, '__esModule', {value: true});
143
- Object.keys(n).forEach(function (k) {
144
- var d = Object.getOwnPropertyDescriptor(n, k);
145
- Object.defineProperty(a, k, d.get ? d : {
146
- enumerable: true,
147
- get: function () {
148
- return n[k];
149
- }
150
- });
151
- });
152
- return a;
153
- }
154
-
155
- var axiosExports$1 = {};
156
- var axios$3 = {
157
- get exports(){ return axiosExports$1; },
158
- set exports(v){ axiosExports$1 = v; },
159
- };
160
-
161
- var axiosExports = {};
162
- var axios$2 = {
163
- get exports(){ return axiosExports; },
164
- set exports(v){ axiosExports = v; },
165
- };
166
-
167
- var bind$4 = function bind(fn, thisArg) {
168
- return function wrap() {
169
- var args = new Array(arguments.length);
170
- for (var i = 0; i < args.length; i++) {
171
- args[i] = arguments[i];
172
- }
173
- return fn.apply(thisArg, args);
174
- };
175
- };
176
-
177
- var bind$3 = bind$4;
178
-
179
- // utils is a library of generic helper functions non-specific to axios
180
-
181
- var toString = Object.prototype.toString;
182
-
183
- /**
184
- * Determine if a value is an Array
185
- *
186
- * @param {Object} val The value to test
187
- * @returns {boolean} True if value is an Array, otherwise false
188
- */
189
- function isArray$4(val) {
190
- return Array.isArray(val);
191
- }
192
-
193
- /**
194
- * Determine if a value is undefined
195
- *
196
- * @param {Object} val The value to test
197
- * @returns {boolean} True if the value is undefined, otherwise false
198
- */
199
- function isUndefined(val) {
200
- return typeof val === 'undefined';
201
- }
202
-
203
- /**
204
- * Determine if a value is a Buffer
205
- *
206
- * @param {Object} val The value to test
207
- * @returns {boolean} True if value is a Buffer, otherwise false
208
- */
209
- function isBuffer$1(val) {
210
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
211
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
212
- }
213
-
214
- /**
215
- * Determine if a value is an ArrayBuffer
216
- *
217
- * @param {Object} val The value to test
218
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
219
- */
220
- function isArrayBuffer(val) {
221
- return toString.call(val) === '[object ArrayBuffer]';
222
- }
223
-
224
- /**
225
- * Determine if a value is a FormData
226
- *
227
- * @param {Object} val The value to test
228
- * @returns {boolean} True if value is an FormData, otherwise false
229
- */
230
- function isFormData(val) {
231
- return toString.call(val) === '[object FormData]';
232
- }
233
-
234
- /**
235
- * Determine if a value is a view on an ArrayBuffer
236
- *
237
- * @param {Object} val The value to test
238
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
239
- */
240
- function isArrayBufferView(val) {
241
- var result;
242
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
243
- result = ArrayBuffer.isView(val);
244
- } else {
245
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
246
- }
247
- return result;
248
- }
249
-
250
- /**
251
- * Determine if a value is a String
252
- *
253
- * @param {Object} val The value to test
254
- * @returns {boolean} True if value is a String, otherwise false
255
- */
256
- function isString$1(val) {
257
- return typeof val === 'string';
258
- }
259
-
260
- /**
261
- * Determine if a value is a Number
262
- *
263
- * @param {Object} val The value to test
264
- * @returns {boolean} True if value is a Number, otherwise false
265
- */
266
- function isNumber$1(val) {
267
- return typeof val === 'number';
268
- }
269
-
270
- /**
271
- * Determine if a value is an Object
272
- *
273
- * @param {Object} val The value to test
274
- * @returns {boolean} True if value is an Object, otherwise false
275
- */
276
- function isObject(val) {
277
- return val !== null && typeof val === 'object';
278
- }
279
-
280
- /**
281
- * Determine if a value is a plain Object
282
- *
283
- * @param {Object} val The value to test
284
- * @return {boolean} True if value is a plain Object, otherwise false
285
- */
286
- function isPlainObject(val) {
287
- if (toString.call(val) !== '[object Object]') {
288
- return false;
289
- }
290
-
291
- var prototype = Object.getPrototypeOf(val);
292
- return prototype === null || prototype === Object.prototype;
293
- }
294
-
295
- /**
296
- * Determine if a value is a Date
297
- *
298
- * @param {Object} val The value to test
299
- * @returns {boolean} True if value is a Date, otherwise false
300
- */
301
- function isDate$1(val) {
302
- return toString.call(val) === '[object Date]';
303
- }
304
-
305
- /**
306
- * Determine if a value is a File
307
- *
308
- * @param {Object} val The value to test
309
- * @returns {boolean} True if value is a File, otherwise false
310
- */
311
- function isFile(val) {
312
- return toString.call(val) === '[object File]';
313
- }
314
-
315
- /**
316
- * Determine if a value is a Blob
317
- *
318
- * @param {Object} val The value to test
319
- * @returns {boolean} True if value is a Blob, otherwise false
320
- */
321
- function isBlob(val) {
322
- return toString.call(val) === '[object Blob]';
323
- }
324
-
325
- /**
326
- * Determine if a value is a Function
327
- *
328
- * @param {Object} val The value to test
329
- * @returns {boolean} True if value is a Function, otherwise false
330
- */
331
- function isFunction(val) {
332
- return toString.call(val) === '[object Function]';
333
- }
334
-
335
- /**
336
- * Determine if a value is a Stream
337
- *
338
- * @param {Object} val The value to test
339
- * @returns {boolean} True if value is a Stream, otherwise false
340
- */
341
- function isStream(val) {
342
- return isObject(val) && isFunction(val.pipe);
343
- }
344
-
345
- /**
346
- * Determine if a value is a URLSearchParams object
347
- *
348
- * @param {Object} val The value to test
349
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
350
- */
351
- function isURLSearchParams(val) {
352
- return toString.call(val) === '[object URLSearchParams]';
353
- }
354
-
355
- /**
356
- * Trim excess whitespace off the beginning and end of a string
357
- *
358
- * @param {String} str The String to trim
359
- * @returns {String} The String freed of excess whitespace
360
- */
361
- function trim(str) {
362
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
363
- }
364
-
365
- /**
366
- * Determine if we're running in a standard browser environment
367
- *
368
- * This allows axios to run in a web worker, and react-native.
369
- * Both environments support XMLHttpRequest, but not fully standard globals.
370
- *
371
- * web workers:
372
- * typeof window -> undefined
373
- * typeof document -> undefined
374
- *
375
- * react-native:
376
- * navigator.product -> 'ReactNative'
377
- * nativescript
378
- * navigator.product -> 'NativeScript' or 'NS'
379
- */
380
- function isStandardBrowserEnv() {
381
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
382
- navigator.product === 'NativeScript' ||
383
- navigator.product === 'NS')) {
384
- return false;
385
- }
386
- return (
387
- typeof window !== 'undefined' &&
388
- typeof document !== 'undefined'
389
- );
390
- }
391
-
392
- /**
393
- * Iterate over an Array or an Object invoking a function for each item.
394
- *
395
- * If `obj` is an Array callback will be called passing
396
- * the value, index, and complete array for each item.
397
- *
398
- * If 'obj' is an Object callback will be called passing
399
- * the value, key, and complete object for each property.
400
- *
401
- * @param {Object|Array} obj The object to iterate
402
- * @param {Function} fn The callback to invoke for each item
403
- */
404
- function forEach(obj, fn) {
405
- // Don't bother if no value provided
406
- if (obj === null || typeof obj === 'undefined') {
407
- return;
408
- }
409
-
410
- // Force an array if not already something iterable
411
- if (typeof obj !== 'object') {
412
- /*eslint no-param-reassign:0*/
413
- obj = [obj];
414
- }
415
-
416
- if (isArray$4(obj)) {
417
- // Iterate over array values
418
- for (var i = 0, l = obj.length; i < l; i++) {
419
- fn.call(null, obj[i], i, obj);
420
- }
421
- } else {
422
- // Iterate over object keys
423
- for (var key in obj) {
424
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
425
- fn.call(null, obj[key], key, obj);
426
- }
427
- }
428
- }
429
- }
430
-
431
- /**
432
- * Accepts varargs expecting each argument to be an object, then
433
- * immutably merges the properties of each object and returns result.
434
- *
435
- * When multiple objects contain the same key the later object in
436
- * the arguments list will take precedence.
437
- *
438
- * Example:
439
- *
440
- * ```js
441
- * var result = merge({foo: 123}, {foo: 456});
442
- * console.log(result.foo); // outputs 456
443
- * ```
444
- *
445
- * @param {Object} obj1 Object to merge
446
- * @returns {Object} Result of all merge properties
447
- */
448
- function merge$1(/* obj1, obj2, obj3, ... */) {
449
- var result = {};
450
- function assignValue(val, key) {
451
- if (isPlainObject(result[key]) && isPlainObject(val)) {
452
- result[key] = merge$1(result[key], val);
453
- } else if (isPlainObject(val)) {
454
- result[key] = merge$1({}, val);
455
- } else if (isArray$4(val)) {
456
- result[key] = val.slice();
457
- } else {
458
- result[key] = val;
459
- }
460
- }
461
-
462
- for (var i = 0, l = arguments.length; i < l; i++) {
463
- forEach(arguments[i], assignValue);
464
- }
465
- return result;
466
- }
467
-
468
- /**
469
- * Extends object a by mutably adding to it the properties of object b.
470
- *
471
- * @param {Object} a The object to be extended
472
- * @param {Object} b The object to copy properties from
473
- * @param {Object} thisArg The object to bind function to
474
- * @return {Object} The resulting value of object a
475
- */
476
- function extend(a, b, thisArg) {
477
- forEach(b, function assignValue(val, key) {
478
- if (thisArg && typeof val === 'function') {
479
- a[key] = bind$3(val, thisArg);
480
- } else {
481
- a[key] = val;
482
- }
483
- });
484
- return a;
485
- }
486
-
487
- /**
488
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
489
- *
490
- * @param {string} content with BOM
491
- * @return {string} content value without BOM
492
- */
493
- function stripBOM(content) {
494
- if (content.charCodeAt(0) === 0xFEFF) {
495
- content = content.slice(1);
496
- }
497
- return content;
498
- }
499
-
500
- var utils$c = {
501
- isArray: isArray$4,
502
- isArrayBuffer: isArrayBuffer,
503
- isBuffer: isBuffer$1,
504
- isFormData: isFormData,
505
- isArrayBufferView: isArrayBufferView,
506
- isString: isString$1,
507
- isNumber: isNumber$1,
508
- isObject: isObject,
509
- isPlainObject: isPlainObject,
510
- isUndefined: isUndefined,
511
- isDate: isDate$1,
512
- isFile: isFile,
513
- isBlob: isBlob,
514
- isFunction: isFunction,
515
- isStream: isStream,
516
- isURLSearchParams: isURLSearchParams,
517
- isStandardBrowserEnv: isStandardBrowserEnv,
518
- forEach: forEach,
519
- merge: merge$1,
520
- extend: extend,
521
- trim: trim,
522
- stripBOM: stripBOM
523
- };
524
-
525
- var utils$b = utils$c;
526
-
527
- function encode$1(val) {
528
- return encodeURIComponent(val).
529
- replace(/%3A/gi, ':').
530
- replace(/%24/g, '$').
531
- replace(/%2C/gi, ',').
532
- replace(/%20/g, '+').
533
- replace(/%5B/gi, '[').
534
- replace(/%5D/gi, ']');
535
- }
536
-
537
- /**
538
- * Build a URL by appending params to the end
539
- *
540
- * @param {string} url The base of the url (e.g., http://www.google.com)
541
- * @param {object} [params] The params to be appended
542
- * @returns {string} The formatted url
543
- */
544
- var buildURL$1 = function buildURL(url, params, paramsSerializer) {
545
- /*eslint no-param-reassign:0*/
546
- if (!params) {
547
- return url;
548
- }
549
-
550
- var serializedParams;
551
- if (paramsSerializer) {
552
- serializedParams = paramsSerializer(params);
553
- } else if (utils$b.isURLSearchParams(params)) {
554
- serializedParams = params.toString();
555
- } else {
556
- var parts = [];
557
-
558
- utils$b.forEach(params, function serialize(val, key) {
559
- if (val === null || typeof val === 'undefined') {
560
- return;
561
- }
562
-
563
- if (utils$b.isArray(val)) {
564
- key = key + '[]';
565
- } else {
566
- val = [val];
567
- }
568
-
569
- utils$b.forEach(val, function parseValue(v) {
570
- if (utils$b.isDate(v)) {
571
- v = v.toISOString();
572
- } else if (utils$b.isObject(v)) {
573
- v = JSON.stringify(v);
574
- }
575
- parts.push(encode$1(key) + '=' + encode$1(v));
576
- });
577
- });
578
-
579
- serializedParams = parts.join('&');
580
- }
581
-
582
- if (serializedParams) {
583
- var hashmarkIndex = url.indexOf('#');
584
- if (hashmarkIndex !== -1) {
585
- url = url.slice(0, hashmarkIndex);
586
- }
587
-
588
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
589
- }
590
-
591
- return url;
592
- };
593
-
594
- var utils$a = utils$c;
595
-
596
- function InterceptorManager$1() {
597
- this.handlers = [];
598
- }
599
-
600
- /**
601
- * Add a new interceptor to the stack
602
- *
603
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
604
- * @param {Function} rejected The function to handle `reject` for a `Promise`
605
- *
606
- * @return {Number} An ID used to remove interceptor later
607
- */
608
- InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
609
- this.handlers.push({
610
- fulfilled: fulfilled,
611
- rejected: rejected,
612
- synchronous: options ? options.synchronous : false,
613
- runWhen: options ? options.runWhen : null
614
- });
615
- return this.handlers.length - 1;
616
- };
617
-
618
- /**
619
- * Remove an interceptor from the stack
620
- *
621
- * @param {Number} id The ID that was returned by `use`
622
- */
623
- InterceptorManager$1.prototype.eject = function eject(id) {
624
- if (this.handlers[id]) {
625
- this.handlers[id] = null;
626
- }
627
- };
628
-
629
- /**
630
- * Iterate over all the registered interceptors
631
- *
632
- * This method is particularly useful for skipping over any
633
- * interceptors that may have become `null` calling `eject`.
634
- *
635
- * @param {Function} fn The function to call for each interceptor
636
- */
637
- InterceptorManager$1.prototype.forEach = function forEach(fn) {
638
- utils$a.forEach(this.handlers, function forEachHandler(h) {
639
- if (h !== null) {
640
- fn(h);
641
- }
642
- });
643
- };
644
-
645
- var InterceptorManager_1 = InterceptorManager$1;
646
-
647
- var utils$9 = utils$c;
648
-
649
- var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
650
- utils$9.forEach(headers, function processHeader(value, name) {
651
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
652
- headers[normalizedName] = value;
653
- delete headers[name];
654
- }
655
- });
656
- };
657
-
658
- /**
659
- * Update an Error with the specified config, error code, and response.
660
- *
661
- * @param {Error} error The error to update.
662
- * @param {Object} config The config.
663
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
664
- * @param {Object} [request] The request.
665
- * @param {Object} [response] The response.
666
- * @returns {Error} The error.
667
- */
668
- var enhanceError$1 = function enhanceError(error, config, code, request, response) {
669
- error.config = config;
670
- if (code) {
671
- error.code = code;
672
- }
673
-
674
- error.request = request;
675
- error.response = response;
676
- error.isAxiosError = true;
677
-
678
- error.toJSON = function toJSON() {
679
- return {
680
- // Standard
681
- message: this.message,
682
- name: this.name,
683
- // Microsoft
684
- description: this.description,
685
- number: this.number,
686
- // Mozilla
687
- fileName: this.fileName,
688
- lineNumber: this.lineNumber,
689
- columnNumber: this.columnNumber,
690
- stack: this.stack,
691
- // Axios
692
- config: this.config,
693
- code: this.code,
694
- status: this.response && this.response.status ? this.response.status : null
695
- };
696
- };
697
- return error;
698
- };
699
-
700
- var transitional = {
701
- silentJSONParsing: true,
702
- forcedJSONParsing: true,
703
- clarifyTimeoutError: false
704
- };
705
-
706
- var createError;
707
- var hasRequiredCreateError;
708
-
709
- function requireCreateError () {
710
- if (hasRequiredCreateError) return createError;
711
- hasRequiredCreateError = 1;
712
-
713
- var enhanceError = enhanceError$1;
714
-
715
- /**
716
- * Create an Error with the specified message, config, error code, request and response.
717
- *
718
- * @param {string} message The error message.
719
- * @param {Object} config The config.
720
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
721
- * @param {Object} [request] The request.
722
- * @param {Object} [response] The response.
723
- * @returns {Error} The created error.
724
- */
725
- createError = function createError(message, config, code, request, response) {
726
- var error = new Error(message);
727
- return enhanceError(error, config, code, request, response);
728
- };
729
- return createError;
730
- }
731
-
732
- var settle;
733
- var hasRequiredSettle;
734
-
735
- function requireSettle () {
736
- if (hasRequiredSettle) return settle;
737
- hasRequiredSettle = 1;
738
-
739
- var createError = requireCreateError();
740
-
741
- /**
742
- * Resolve or reject a Promise based on response status.
743
- *
744
- * @param {Function} resolve A function that resolves the promise.
745
- * @param {Function} reject A function that rejects the promise.
746
- * @param {object} response The response.
747
- */
748
- settle = function settle(resolve, reject, response) {
749
- var validateStatus = response.config.validateStatus;
750
- if (!response.status || !validateStatus || validateStatus(response.status)) {
751
- resolve(response);
752
- } else {
753
- reject(createError(
754
- 'Request failed with status code ' + response.status,
755
- response.config,
756
- null,
757
- response.request,
758
- response
759
- ));
760
- }
761
- };
762
- return settle;
763
- }
764
-
765
- var cookies;
766
- var hasRequiredCookies;
767
-
768
- function requireCookies () {
769
- if (hasRequiredCookies) return cookies;
770
- hasRequiredCookies = 1;
771
-
772
- var utils = utils$c;
773
-
774
- cookies = (
775
- utils.isStandardBrowserEnv() ?
776
-
777
- // Standard browser envs support document.cookie
778
- (function standardBrowserEnv() {
779
- return {
780
- write: function write(name, value, expires, path, domain, secure) {
781
- var cookie = [];
782
- cookie.push(name + '=' + encodeURIComponent(value));
783
-
784
- if (utils.isNumber(expires)) {
785
- cookie.push('expires=' + new Date(expires).toGMTString());
786
- }
787
-
788
- if (utils.isString(path)) {
789
- cookie.push('path=' + path);
790
- }
791
-
792
- if (utils.isString(domain)) {
793
- cookie.push('domain=' + domain);
794
- }
795
-
796
- if (secure === true) {
797
- cookie.push('secure');
798
- }
799
-
800
- document.cookie = cookie.join('; ');
801
- },
802
-
803
- read: function read(name) {
804
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
805
- return (match ? decodeURIComponent(match[3]) : null);
806
- },
807
-
808
- remove: function remove(name) {
809
- this.write(name, '', Date.now() - 86400000);
810
- }
811
- };
812
- })() :
813
-
814
- // Non standard browser env (web workers, react-native) lack needed support.
815
- (function nonStandardBrowserEnv() {
816
- return {
817
- write: function write() {},
818
- read: function read() { return null; },
819
- remove: function remove() {}
820
- };
821
- })()
822
- );
823
- return cookies;
824
- }
825
-
826
- var isAbsoluteURL;
827
- var hasRequiredIsAbsoluteURL;
828
-
829
- function requireIsAbsoluteURL () {
830
- if (hasRequiredIsAbsoluteURL) return isAbsoluteURL;
831
- hasRequiredIsAbsoluteURL = 1;
832
-
833
- /**
834
- * Determines whether the specified URL is absolute
835
- *
836
- * @param {string} url The URL to test
837
- * @returns {boolean} True if the specified URL is absolute, otherwise false
838
- */
839
- isAbsoluteURL = function isAbsoluteURL(url) {
840
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
841
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
842
- // by any combination of letters, digits, plus, period, or hyphen.
843
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
844
- };
845
- return isAbsoluteURL;
846
- }
847
-
848
- var combineURLs;
849
- var hasRequiredCombineURLs;
850
-
851
- function requireCombineURLs () {
852
- if (hasRequiredCombineURLs) return combineURLs;
853
- hasRequiredCombineURLs = 1;
854
-
855
- /**
856
- * Creates a new URL by combining the specified URLs
857
- *
858
- * @param {string} baseURL The base URL
859
- * @param {string} relativeURL The relative URL
860
- * @returns {string} The combined URL
861
- */
862
- combineURLs = function combineURLs(baseURL, relativeURL) {
863
- return relativeURL
864
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
865
- : baseURL;
866
- };
867
- return combineURLs;
868
- }
869
-
870
- var buildFullPath;
871
- var hasRequiredBuildFullPath;
872
-
873
- function requireBuildFullPath () {
874
- if (hasRequiredBuildFullPath) return buildFullPath;
875
- hasRequiredBuildFullPath = 1;
876
-
877
- var isAbsoluteURL = requireIsAbsoluteURL();
878
- var combineURLs = requireCombineURLs();
879
-
880
- /**
881
- * Creates a new URL by combining the baseURL with the requestedURL,
882
- * only when the requestedURL is not already an absolute URL.
883
- * If the requestURL is absolute, this function returns the requestedURL untouched.
884
- *
885
- * @param {string} baseURL The base URL
886
- * @param {string} requestedURL Absolute or relative URL to combine
887
- * @returns {string} The combined full path
888
- */
889
- buildFullPath = function buildFullPath(baseURL, requestedURL) {
890
- if (baseURL && !isAbsoluteURL(requestedURL)) {
891
- return combineURLs(baseURL, requestedURL);
892
- }
893
- return requestedURL;
894
- };
895
- return buildFullPath;
896
- }
897
-
898
- var parseHeaders;
899
- var hasRequiredParseHeaders;
900
-
901
- function requireParseHeaders () {
902
- if (hasRequiredParseHeaders) return parseHeaders;
903
- hasRequiredParseHeaders = 1;
904
-
905
- var utils = utils$c;
906
-
907
- // Headers whose duplicates are ignored by node
908
- // c.f. https://nodejs.org/api/http.html#http_message_headers
909
- var ignoreDuplicateOf = [
910
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
911
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
912
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
913
- 'referer', 'retry-after', 'user-agent'
914
- ];
915
-
916
- /**
917
- * Parse headers into an object
918
- *
919
- * ```
920
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
921
- * Content-Type: application/json
922
- * Connection: keep-alive
923
- * Transfer-Encoding: chunked
924
- * ```
925
- *
926
- * @param {String} headers Headers needing to be parsed
927
- * @returns {Object} Headers parsed into an object
928
- */
929
- parseHeaders = function parseHeaders(headers) {
930
- var parsed = {};
931
- var key;
932
- var val;
933
- var i;
934
-
935
- if (!headers) { return parsed; }
936
-
937
- utils.forEach(headers.split('\n'), function parser(line) {
938
- i = line.indexOf(':');
939
- key = utils.trim(line.substr(0, i)).toLowerCase();
940
- val = utils.trim(line.substr(i + 1));
941
-
942
- if (key) {
943
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
944
- return;
945
- }
946
- if (key === 'set-cookie') {
947
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
948
- } else {
949
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
950
- }
951
- }
952
- });
953
-
954
- return parsed;
955
- };
956
- return parseHeaders;
957
- }
958
-
959
- var isURLSameOrigin;
960
- var hasRequiredIsURLSameOrigin;
961
-
962
- function requireIsURLSameOrigin () {
963
- if (hasRequiredIsURLSameOrigin) return isURLSameOrigin;
964
- hasRequiredIsURLSameOrigin = 1;
965
-
966
- var utils = utils$c;
967
-
968
- isURLSameOrigin = (
969
- utils.isStandardBrowserEnv() ?
970
-
971
- // Standard browser envs have full support of the APIs needed to test
972
- // whether the request URL is of the same origin as current location.
973
- (function standardBrowserEnv() {
974
- var msie = /(msie|trident)/i.test(navigator.userAgent);
975
- var urlParsingNode = document.createElement('a');
976
- var originURL;
977
-
978
- /**
979
- * Parse a URL to discover it's components
980
- *
981
- * @param {String} url The URL to be parsed
982
- * @returns {Object}
983
- */
984
- function resolveURL(url) {
985
- var href = url;
986
-
987
- if (msie) {
988
- // IE needs attribute set twice to normalize properties
989
- urlParsingNode.setAttribute('href', href);
990
- href = urlParsingNode.href;
991
- }
992
-
993
- urlParsingNode.setAttribute('href', href);
994
-
995
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
996
- return {
997
- href: urlParsingNode.href,
998
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
999
- host: urlParsingNode.host,
1000
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1001
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1002
- hostname: urlParsingNode.hostname,
1003
- port: urlParsingNode.port,
1004
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
1005
- urlParsingNode.pathname :
1006
- '/' + urlParsingNode.pathname
1007
- };
1008
- }
1009
-
1010
- originURL = resolveURL(window.location.href);
1011
-
1012
- /**
1013
- * Determine if a URL shares the same origin as the current location
1014
- *
1015
- * @param {String} requestURL The URL to test
1016
- * @returns {boolean} True if URL shares the same origin, otherwise false
1017
- */
1018
- return function isURLSameOrigin(requestURL) {
1019
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
1020
- return (parsed.protocol === originURL.protocol &&
1021
- parsed.host === originURL.host);
1022
- };
1023
- })() :
1024
-
1025
- // Non standard browser envs (web workers, react-native) lack needed support.
1026
- (function nonStandardBrowserEnv() {
1027
- return function isURLSameOrigin() {
1028
- return true;
1029
- };
1030
- })()
1031
- );
1032
- return isURLSameOrigin;
1033
- }
1034
-
1035
- var Cancel_1;
1036
- var hasRequiredCancel;
1037
-
1038
- function requireCancel () {
1039
- if (hasRequiredCancel) return Cancel_1;
1040
- hasRequiredCancel = 1;
1041
-
1042
- /**
1043
- * A `Cancel` is an object that is thrown when an operation is canceled.
1044
- *
1045
- * @class
1046
- * @param {string=} message The message.
1047
- */
1048
- function Cancel(message) {
1049
- this.message = message;
1050
- }
1051
-
1052
- Cancel.prototype.toString = function toString() {
1053
- return 'Cancel' + (this.message ? ': ' + this.message : '');
1054
- };
1055
-
1056
- Cancel.prototype.__CANCEL__ = true;
1057
-
1058
- Cancel_1 = Cancel;
1059
- return Cancel_1;
1060
- }
1061
-
1062
- var xhr;
1063
- var hasRequiredXhr;
1064
-
1065
- function requireXhr () {
1066
- if (hasRequiredXhr) return xhr;
1067
- hasRequiredXhr = 1;
1068
-
1069
- var utils = utils$c;
1070
- var settle = requireSettle();
1071
- var cookies = requireCookies();
1072
- var buildURL = buildURL$1;
1073
- var buildFullPath = requireBuildFullPath();
1074
- var parseHeaders = requireParseHeaders();
1075
- var isURLSameOrigin = requireIsURLSameOrigin();
1076
- var createError = requireCreateError();
1077
- var transitionalDefaults = transitional;
1078
- var Cancel = requireCancel();
1079
-
1080
- xhr = function xhrAdapter(config) {
1081
- return new Promise(function dispatchXhrRequest(resolve, reject) {
1082
- var requestData = config.data;
1083
- var requestHeaders = config.headers;
1084
- var responseType = config.responseType;
1085
- var onCanceled;
1086
- function done() {
1087
- if (config.cancelToken) {
1088
- config.cancelToken.unsubscribe(onCanceled);
1089
- }
1090
-
1091
- if (config.signal) {
1092
- config.signal.removeEventListener('abort', onCanceled);
1093
- }
1094
- }
1095
-
1096
- if (utils.isFormData(requestData)) {
1097
- delete requestHeaders['Content-Type']; // Let the browser set it
1098
- }
1099
-
1100
- var request = new XMLHttpRequest();
1101
-
1102
- // HTTP basic authentication
1103
- if (config.auth) {
1104
- var username = config.auth.username || '';
1105
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
1106
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
1107
- }
1108
-
1109
- var fullPath = buildFullPath(config.baseURL, config.url);
1110
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
1111
-
1112
- // Set the request timeout in MS
1113
- request.timeout = config.timeout;
1114
-
1115
- function onloadend() {
1116
- if (!request) {
1117
- return;
1118
- }
1119
- // Prepare the response
1120
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
1121
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
1122
- request.responseText : request.response;
1123
- var response = {
1124
- data: responseData,
1125
- status: request.status,
1126
- statusText: request.statusText,
1127
- headers: responseHeaders,
1128
- config: config,
1129
- request: request
1130
- };
1131
-
1132
- settle(function _resolve(value) {
1133
- resolve(value);
1134
- done();
1135
- }, function _reject(err) {
1136
- reject(err);
1137
- done();
1138
- }, response);
1139
-
1140
- // Clean up request
1141
- request = null;
1142
- }
1143
-
1144
- if ('onloadend' in request) {
1145
- // Use onloadend if available
1146
- request.onloadend = onloadend;
1147
- } else {
1148
- // Listen for ready state to emulate onloadend
1149
- request.onreadystatechange = function handleLoad() {
1150
- if (!request || request.readyState !== 4) {
1151
- return;
1152
- }
1153
-
1154
- // The request errored out and we didn't get a response, this will be
1155
- // handled by onerror instead
1156
- // With one exception: request that using file: protocol, most browsers
1157
- // will return status as 0 even though it's a successful request
1158
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
1159
- return;
1160
- }
1161
- // readystate handler is calling before onerror or ontimeout handlers,
1162
- // so we should call onloadend on the next 'tick'
1163
- setTimeout(onloadend);
1164
- };
1165
- }
1166
-
1167
- // Handle browser request cancellation (as opposed to a manual cancellation)
1168
- request.onabort = function handleAbort() {
1169
- if (!request) {
1170
- return;
1171
- }
1172
-
1173
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
1174
-
1175
- // Clean up request
1176
- request = null;
1177
- };
1178
-
1179
- // Handle low level network errors
1180
- request.onerror = function handleError() {
1181
- // Real errors are hidden from us by the browser
1182
- // onerror should only fire if it's a network error
1183
- reject(createError('Network Error', config, null, request));
1184
-
1185
- // Clean up request
1186
- request = null;
1187
- };
1188
-
1189
- // Handle timeout
1190
- request.ontimeout = function handleTimeout() {
1191
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
1192
- var transitional = config.transitional || transitionalDefaults;
1193
- if (config.timeoutErrorMessage) {
1194
- timeoutErrorMessage = config.timeoutErrorMessage;
1195
- }
1196
- reject(createError(
1197
- timeoutErrorMessage,
1198
- config,
1199
- transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
1200
- request));
1201
-
1202
- // Clean up request
1203
- request = null;
1204
- };
1205
-
1206
- // Add xsrf header
1207
- // This is only done if running in a standard browser environment.
1208
- // Specifically not if we're in a web worker, or react-native.
1209
- if (utils.isStandardBrowserEnv()) {
1210
- // Add xsrf header
1211
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
1212
- cookies.read(config.xsrfCookieName) :
1213
- undefined;
1214
-
1215
- if (xsrfValue) {
1216
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
1217
- }
1218
- }
1219
-
1220
- // Add headers to the request
1221
- if ('setRequestHeader' in request) {
1222
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
1223
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
1224
- // Remove Content-Type if data is undefined
1225
- delete requestHeaders[key];
1226
- } else {
1227
- // Otherwise add header to the request
1228
- request.setRequestHeader(key, val);
1229
- }
1230
- });
1231
- }
1232
-
1233
- // Add withCredentials to request if needed
1234
- if (!utils.isUndefined(config.withCredentials)) {
1235
- request.withCredentials = !!config.withCredentials;
1236
- }
1237
-
1238
- // Add responseType to request if needed
1239
- if (responseType && responseType !== 'json') {
1240
- request.responseType = config.responseType;
1241
- }
1242
-
1243
- // Handle progress if needed
1244
- if (typeof config.onDownloadProgress === 'function') {
1245
- request.addEventListener('progress', config.onDownloadProgress);
1246
- }
1247
-
1248
- // Not all browsers support upload events
1249
- if (typeof config.onUploadProgress === 'function' && request.upload) {
1250
- request.upload.addEventListener('progress', config.onUploadProgress);
1251
- }
1252
-
1253
- if (config.cancelToken || config.signal) {
1254
- // Handle cancellation
1255
- // eslint-disable-next-line func-names
1256
- onCanceled = function(cancel) {
1257
- if (!request) {
1258
- return;
1259
- }
1260
- reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
1261
- request.abort();
1262
- request = null;
1263
- };
1264
-
1265
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
1266
- if (config.signal) {
1267
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
1268
- }
1269
- }
1270
-
1271
- if (!requestData) {
1272
- requestData = null;
1273
- }
1274
-
1275
- // Send the request
1276
- request.send(requestData);
1277
- });
1278
- };
1279
- return xhr;
1280
- }
1281
-
1282
- var utils$8 = utils$c;
1283
- var normalizeHeaderName = normalizeHeaderName$1;
1284
- var enhanceError = enhanceError$1;
1285
- var transitionalDefaults = transitional;
1286
-
1287
- var DEFAULT_CONTENT_TYPE = {
1288
- 'Content-Type': 'application/x-www-form-urlencoded'
1289
- };
1290
-
1291
- function setContentTypeIfUnset(headers, value) {
1292
- if (!utils$8.isUndefined(headers) && utils$8.isUndefined(headers['Content-Type'])) {
1293
- headers['Content-Type'] = value;
1294
- }
1295
- }
1296
-
1297
- function getDefaultAdapter() {
1298
- var adapter;
1299
- if (typeof XMLHttpRequest !== 'undefined') {
1300
- // For browsers use XHR adapter
1301
- adapter = requireXhr();
1302
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
1303
- // For node use HTTP adapter
1304
- adapter = requireXhr();
1305
- }
1306
- return adapter;
1307
- }
1308
-
1309
- function stringifySafely(rawValue, parser, encoder) {
1310
- if (utils$8.isString(rawValue)) {
1311
- try {
1312
- (parser || JSON.parse)(rawValue);
1313
- return utils$8.trim(rawValue);
1314
- } catch (e) {
1315
- if (e.name !== 'SyntaxError') {
1316
- throw e;
1317
- }
1318
- }
1319
- }
1320
-
1321
- return (encoder || JSON.stringify)(rawValue);
1322
- }
1323
-
1324
- var defaults$5 = {
1325
-
1326
- transitional: transitionalDefaults,
1327
-
1328
- adapter: getDefaultAdapter(),
1329
-
1330
- transformRequest: [function transformRequest(data, headers) {
1331
- normalizeHeaderName(headers, 'Accept');
1332
- normalizeHeaderName(headers, 'Content-Type');
1333
-
1334
- if (utils$8.isFormData(data) ||
1335
- utils$8.isArrayBuffer(data) ||
1336
- utils$8.isBuffer(data) ||
1337
- utils$8.isStream(data) ||
1338
- utils$8.isFile(data) ||
1339
- utils$8.isBlob(data)
1340
- ) {
1341
- return data;
1342
- }
1343
- if (utils$8.isArrayBufferView(data)) {
1344
- return data.buffer;
1345
- }
1346
- if (utils$8.isURLSearchParams(data)) {
1347
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
1348
- return data.toString();
1349
- }
1350
- if (utils$8.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
1351
- setContentTypeIfUnset(headers, 'application/json');
1352
- return stringifySafely(data);
1353
- }
1354
- return data;
1355
- }],
1356
-
1357
- transformResponse: [function transformResponse(data) {
1358
- var transitional = this.transitional || defaults$5.transitional;
1359
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
1360
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1361
- var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
1362
-
1363
- if (strictJSONParsing || (forcedJSONParsing && utils$8.isString(data) && data.length)) {
1364
- try {
1365
- return JSON.parse(data);
1366
- } catch (e) {
1367
- if (strictJSONParsing) {
1368
- if (e.name === 'SyntaxError') {
1369
- throw enhanceError(e, this, 'E_JSON_PARSE');
1370
- }
1371
- throw e;
1372
- }
1373
- }
1374
- }
1375
-
1376
- return data;
1377
- }],
1378
-
1379
- /**
1380
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
1381
- * timeout is not created.
1382
- */
1383
- timeout: 0,
1384
-
1385
- xsrfCookieName: 'XSRF-TOKEN',
1386
- xsrfHeaderName: 'X-XSRF-TOKEN',
1387
-
1388
- maxContentLength: -1,
1389
- maxBodyLength: -1,
1390
-
1391
- validateStatus: function validateStatus(status) {
1392
- return status >= 200 && status < 300;
1393
- },
1394
-
1395
- headers: {
1396
- common: {
1397
- 'Accept': 'application/json, text/plain, */*'
1398
- }
1399
- }
1400
- };
1401
-
1402
- utils$8.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1403
- defaults$5.headers[method] = {};
1404
- });
1405
-
1406
- utils$8.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1407
- defaults$5.headers[method] = utils$8.merge(DEFAULT_CONTENT_TYPE);
1408
- });
1409
-
1410
- var defaults_1 = defaults$5;
1411
-
1412
- var utils$7 = utils$c;
1413
- var defaults$4 = defaults_1;
1414
-
1415
- /**
1416
- * Transform the data for a request or a response
1417
- *
1418
- * @param {Object|String} data The data to be transformed
1419
- * @param {Array} headers The headers for the request or response
1420
- * @param {Array|Function} fns A single function or Array of functions
1421
- * @returns {*} The resulting transformed data
1422
- */
1423
- var transformData$1 = function transformData(data, headers, fns) {
1424
- var context = this || defaults$4;
1425
- /*eslint no-param-reassign:0*/
1426
- utils$7.forEach(fns, function transform(fn) {
1427
- data = fn.call(context, data, headers);
1428
- });
1429
-
1430
- return data;
1431
- };
1432
-
1433
- var isCancel$1;
1434
- var hasRequiredIsCancel;
1435
-
1436
- function requireIsCancel () {
1437
- if (hasRequiredIsCancel) return isCancel$1;
1438
- hasRequiredIsCancel = 1;
1439
-
1440
- isCancel$1 = function isCancel(value) {
1441
- return !!(value && value.__CANCEL__);
1442
- };
1443
- return isCancel$1;
1444
- }
1445
-
1446
- var utils$6 = utils$c;
1447
- var transformData = transformData$1;
1448
- var isCancel = requireIsCancel();
1449
- var defaults$3 = defaults_1;
1450
- var Cancel = requireCancel();
1451
-
1452
- /**
1453
- * Throws a `Cancel` if cancellation has been requested.
1454
- */
1455
- function throwIfCancellationRequested(config) {
1456
- if (config.cancelToken) {
1457
- config.cancelToken.throwIfRequested();
1458
- }
1459
-
1460
- if (config.signal && config.signal.aborted) {
1461
- throw new Cancel('canceled');
1462
- }
1463
- }
1464
-
1465
- /**
1466
- * Dispatch a request to the server using the configured adapter.
1467
- *
1468
- * @param {object} config The config that is to be used for the request
1469
- * @returns {Promise} The Promise to be fulfilled
1470
- */
1471
- var dispatchRequest$1 = function dispatchRequest(config) {
1472
- throwIfCancellationRequested(config);
1473
-
1474
- // Ensure headers exist
1475
- config.headers = config.headers || {};
1476
-
1477
- // Transform request data
1478
- config.data = transformData.call(
1479
- config,
1480
- config.data,
1481
- config.headers,
1482
- config.transformRequest
1483
- );
1484
-
1485
- // Flatten headers
1486
- config.headers = utils$6.merge(
1487
- config.headers.common || {},
1488
- config.headers[config.method] || {},
1489
- config.headers
1490
- );
1491
-
1492
- utils$6.forEach(
1493
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
1494
- function cleanHeaderConfig(method) {
1495
- delete config.headers[method];
1496
- }
1497
- );
1498
-
1499
- var adapter = config.adapter || defaults$3.adapter;
1500
-
1501
- return adapter(config).then(function onAdapterResolution(response) {
1502
- throwIfCancellationRequested(config);
1503
-
1504
- // Transform response data
1505
- response.data = transformData.call(
1506
- config,
1507
- response.data,
1508
- response.headers,
1509
- config.transformResponse
1510
- );
1511
-
1512
- return response;
1513
- }, function onAdapterRejection(reason) {
1514
- if (!isCancel(reason)) {
1515
- throwIfCancellationRequested(config);
1516
-
1517
- // Transform response data
1518
- if (reason && reason.response) {
1519
- reason.response.data = transformData.call(
1520
- config,
1521
- reason.response.data,
1522
- reason.response.headers,
1523
- config.transformResponse
1524
- );
1525
- }
1526
- }
1527
-
1528
- return Promise.reject(reason);
1529
- });
1530
- };
1531
-
1532
- var utils$5 = utils$c;
1533
-
1534
- /**
1535
- * Config-specific merge-function which creates a new config-object
1536
- * by merging two configuration objects together.
1537
- *
1538
- * @param {Object} config1
1539
- * @param {Object} config2
1540
- * @returns {Object} New object resulting from merging config2 to config1
1541
- */
1542
- var mergeConfig$2 = function mergeConfig(config1, config2) {
1543
- // eslint-disable-next-line no-param-reassign
1544
- config2 = config2 || {};
1545
- var config = {};
1546
-
1547
- function getMergedValue(target, source) {
1548
- if (utils$5.isPlainObject(target) && utils$5.isPlainObject(source)) {
1549
- return utils$5.merge(target, source);
1550
- } else if (utils$5.isPlainObject(source)) {
1551
- return utils$5.merge({}, source);
1552
- } else if (utils$5.isArray(source)) {
1553
- return source.slice();
1554
- }
1555
- return source;
1556
- }
1557
-
1558
- // eslint-disable-next-line consistent-return
1559
- function mergeDeepProperties(prop) {
1560
- if (!utils$5.isUndefined(config2[prop])) {
1561
- return getMergedValue(config1[prop], config2[prop]);
1562
- } else if (!utils$5.isUndefined(config1[prop])) {
1563
- return getMergedValue(undefined, config1[prop]);
1564
- }
1565
- }
1566
-
1567
- // eslint-disable-next-line consistent-return
1568
- function valueFromConfig2(prop) {
1569
- if (!utils$5.isUndefined(config2[prop])) {
1570
- return getMergedValue(undefined, config2[prop]);
1571
- }
1572
- }
1573
-
1574
- // eslint-disable-next-line consistent-return
1575
- function defaultToConfig2(prop) {
1576
- if (!utils$5.isUndefined(config2[prop])) {
1577
- return getMergedValue(undefined, config2[prop]);
1578
- } else if (!utils$5.isUndefined(config1[prop])) {
1579
- return getMergedValue(undefined, config1[prop]);
1580
- }
1581
- }
1582
-
1583
- // eslint-disable-next-line consistent-return
1584
- function mergeDirectKeys(prop) {
1585
- if (prop in config2) {
1586
- return getMergedValue(config1[prop], config2[prop]);
1587
- } else if (prop in config1) {
1588
- return getMergedValue(undefined, config1[prop]);
1589
- }
1590
- }
1591
-
1592
- var mergeMap = {
1593
- 'url': valueFromConfig2,
1594
- 'method': valueFromConfig2,
1595
- 'data': valueFromConfig2,
1596
- 'baseURL': defaultToConfig2,
1597
- 'transformRequest': defaultToConfig2,
1598
- 'transformResponse': defaultToConfig2,
1599
- 'paramsSerializer': defaultToConfig2,
1600
- 'timeout': defaultToConfig2,
1601
- 'timeoutMessage': defaultToConfig2,
1602
- 'withCredentials': defaultToConfig2,
1603
- 'adapter': defaultToConfig2,
1604
- 'responseType': defaultToConfig2,
1605
- 'xsrfCookieName': defaultToConfig2,
1606
- 'xsrfHeaderName': defaultToConfig2,
1607
- 'onUploadProgress': defaultToConfig2,
1608
- 'onDownloadProgress': defaultToConfig2,
1609
- 'decompress': defaultToConfig2,
1610
- 'maxContentLength': defaultToConfig2,
1611
- 'maxBodyLength': defaultToConfig2,
1612
- 'transport': defaultToConfig2,
1613
- 'httpAgent': defaultToConfig2,
1614
- 'httpsAgent': defaultToConfig2,
1615
- 'cancelToken': defaultToConfig2,
1616
- 'socketPath': defaultToConfig2,
1617
- 'responseEncoding': defaultToConfig2,
1618
- 'validateStatus': mergeDirectKeys
1619
- };
1620
-
1621
- utils$5.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
1622
- var merge = mergeMap[prop] || mergeDeepProperties;
1623
- var configValue = merge(prop);
1624
- (utils$5.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
1625
- });
1626
-
1627
- return config;
1628
- };
1629
-
1630
- var data;
1631
- var hasRequiredData;
1632
-
1633
- function requireData () {
1634
- if (hasRequiredData) return data;
1635
- hasRequiredData = 1;
1636
- data = {
1637
- "version": "0.26.1"
1638
- };
1639
- return data;
1640
- }
1641
-
1642
- var VERSION = requireData().version;
1643
-
1644
- var validators$1 = {};
1645
-
1646
- // eslint-disable-next-line func-names
1647
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
1648
- validators$1[type] = function validator(thing) {
1649
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1650
- };
1651
- });
1
+ import axios from 'axios';
1652
2
 
1653
- var deprecatedWarnings = {};
1654
-
1655
- /**
1656
- * Transitional option validator
1657
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
1658
- * @param {string?} version - deprecated version / removed since version
1659
- * @param {string?} message - some message with additional info
1660
- * @returns {function}
1661
- */
1662
- validators$1.transitional = function transitional(validator, version, message) {
1663
- function formatMessage(opt, desc) {
1664
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1665
- }
1666
-
1667
- // eslint-disable-next-line func-names
1668
- return function(value, opt, opts) {
1669
- if (validator === false) {
1670
- throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
1671
- }
1672
-
1673
- if (version && !deprecatedWarnings[opt]) {
1674
- deprecatedWarnings[opt] = true;
1675
- // eslint-disable-next-line no-console
1676
- console.warn(
1677
- formatMessage(
1678
- opt,
1679
- ' has been deprecated since v' + version + ' and will be removed in the near future'
1680
- )
1681
- );
3
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
6
+ var __objRest$1 = (source, exclude) => {
7
+ var target = {};
8
+ for (var prop in source)
9
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
10
+ target[prop] = source[prop];
11
+ if (source != null && __getOwnPropSymbols$3)
12
+ for (var prop of __getOwnPropSymbols$3(source)) {
13
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
14
+ target[prop] = source[prop];
1682
15
  }
1683
-
1684
- return validator ? validator(value, opt, opts) : true;
1685
- };
16
+ return target;
1686
17
  };
1687
-
1688
- /**
1689
- * Assert object's properties type
1690
- * @param {object} options
1691
- * @param {object} schema
1692
- * @param {boolean?} allowUnknown
1693
- */
1694
-
1695
- function assertOptions(options, schema, allowUnknown) {
1696
- if (typeof options !== 'object') {
1697
- throw new TypeError('options must be an object');
18
+ class CodedError {
19
+ constructor(message, options) {
20
+ var _a, _b, _c;
21
+ this.errorCode = (_a = options == null ? void 0 : options.errorCode) != null ? _a : "unknown";
22
+ this.errorSource = (_b = options == null ? void 0 : options.errorSource) != null ? _b : "client";
23
+ this.errorType = (_c = options == null ? void 0 : options.errorType) != null ? _c : "unknown";
24
+ this.message = message;
1698
25
  }
1699
- var keys = Object.keys(options);
1700
- var i = keys.length;
1701
- while (i-- > 0) {
1702
- var opt = keys[i];
1703
- var validator = schema[opt];
1704
- if (validator) {
1705
- var value = options[opt];
1706
- var result = value === undefined || validator(value, opt, options);
1707
- if (result !== true) {
1708
- throw new TypeError('option ' + opt + ' must be ' + result);
1709
- }
1710
- continue;
1711
- }
1712
- if (allowUnknown !== true) {
1713
- throw Error('Unknown option ' + opt);
1714
- }
26
+ static fromObject(_a) {
27
+ var _b = _a, { message } = _b, options = __objRest$1(_b, ["message"]);
28
+ return new CodedError(message, options);
1715
29
  }
1716
30
  }
1717
31
 
1718
- var validator$1 = {
1719
- assertOptions: assertOptions,
1720
- validators: validators$1
1721
- };
1722
-
1723
- var utils$4 = utils$c;
1724
- var buildURL = buildURL$1;
1725
- var InterceptorManager = InterceptorManager_1;
1726
- var dispatchRequest = dispatchRequest$1;
1727
- var mergeConfig$1 = mergeConfig$2;
1728
- var validator = validator$1;
1729
-
1730
- var validators = validator.validators;
1731
- /**
1732
- * Create a new instance of Axios
1733
- *
1734
- * @param {Object} instanceConfig The default config for the instance
1735
- */
1736
- function Axios$1(instanceConfig) {
1737
- this.defaults = instanceConfig;
1738
- this.interceptors = {
1739
- request: new InterceptorManager(),
1740
- response: new InterceptorManager()
1741
- };
1742
- }
1743
-
1744
- /**
1745
- * Dispatch a request
1746
- *
1747
- * @param {Object} config The config specific for this request (merged with this.defaults)
1748
- */
1749
- Axios$1.prototype.request = function request(configOrUrl, config) {
1750
- /*eslint no-param-reassign:0*/
1751
- // Allow for axios('example/url'[, config]) a la fetch API
1752
- if (typeof configOrUrl === 'string') {
1753
- config = config || {};
1754
- config.url = configOrUrl;
1755
- } else {
1756
- config = configOrUrl || {};
1757
- }
1758
-
1759
- config = mergeConfig$1(this.defaults, config);
1760
-
1761
- // Set config.method
1762
- if (config.method) {
1763
- config.method = config.method.toLowerCase();
1764
- } else if (this.defaults.method) {
1765
- config.method = this.defaults.method.toLowerCase();
1766
- } else {
1767
- config.method = 'get';
1768
- }
1769
-
1770
- var transitional = config.transitional;
1771
-
1772
- if (transitional !== undefined) {
1773
- validator.assertOptions(transitional, {
1774
- silentJSONParsing: validators.transitional(validators.boolean),
1775
- forcedJSONParsing: validators.transitional(validators.boolean),
1776
- clarifyTimeoutError: validators.transitional(validators.boolean)
1777
- }, false);
1778
- }
1779
-
1780
- // filter out skipped interceptors
1781
- var requestInterceptorChain = [];
1782
- var synchronousRequestInterceptors = true;
1783
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
1784
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
1785
- return;
1786
- }
1787
-
1788
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
1789
-
1790
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
1791
- });
1792
-
1793
- var responseInterceptorChain = [];
1794
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
1795
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
1796
- });
1797
-
1798
- var promise;
1799
-
1800
- if (!synchronousRequestInterceptors) {
1801
- var chain = [dispatchRequest, undefined];
1802
-
1803
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
1804
- chain = chain.concat(responseInterceptorChain);
1805
-
1806
- promise = Promise.resolve(config);
1807
- while (chain.length) {
1808
- promise = promise.then(chain.shift(), chain.shift());
1809
- }
1810
-
1811
- return promise;
1812
- }
1813
-
32
+ var CreditCardVendor = /* @__PURE__ */ ((CreditCardVendor2) => {
33
+ CreditCardVendor2["AMERICAN_EXPRESS"] = "americanexpress";
34
+ CreditCardVendor2["DISCOVER"] = "discover";
35
+ CreditCardVendor2["MASTERCARD"] = "mastercard";
36
+ CreditCardVendor2["VISA"] = "visa";
37
+ return CreditCardVendor2;
38
+ })(CreditCardVendor || {});
39
+ var Currency = /* @__PURE__ */ ((Currency2) => {
40
+ Currency2["USD"] = "usd";
41
+ Currency2["CAD"] = "cad";
42
+ Currency2["AUD"] = "aud";
43
+ Currency2["GBP"] = "gbp";
44
+ Currency2["EUR"] = "eur";
45
+ Currency2["NZD"] = "nzd";
46
+ return Currency2;
47
+ })(Currency || {});
1814
48
 
1815
- var newConfig = config;
1816
- while (requestInterceptorChain.length) {
1817
- var onFulfilled = requestInterceptorChain.shift();
1818
- var onRejected = requestInterceptorChain.shift();
1819
- try {
1820
- newConfig = onFulfilled(newConfig);
1821
- } catch (error) {
1822
- onRejected(error);
1823
- break;
1824
- }
1825
- }
49
+ var ConfirmationType = /* @__PURE__ */ ((ConfirmationType2) => {
50
+ ConfirmationType2["DELIVERY"] = "delivery";
51
+ ConfirmationType2["SIGNATURE"] = "signature";
52
+ ConfirmationType2["ADULT_SIGNATURE"] = "adult_signature";
53
+ ConfirmationType2["DIRECT_SIGNATURE"] = "direct_signature";
54
+ ConfirmationType2["VERBAL_CONFIRMATION"] = "verbal_confirmation";
55
+ ConfirmationType2["DELIVERY_MAILED"] = "delivery_mailed";
56
+ ConfirmationType2["NONE"] = "none";
57
+ return ConfirmationType2;
58
+ })(ConfirmationType || {});
59
+ var CustomsContentsType = /* @__PURE__ */ ((CustomsContentsType2) => {
60
+ CustomsContentsType2["DOCUMENTS"] = "documents";
61
+ CustomsContentsType2["GIFT"] = "gift";
62
+ CustomsContentsType2["MERCHANDISE"] = "merchandise";
63
+ CustomsContentsType2["RETURNED_GOODS"] = "returned_goods";
64
+ CustomsContentsType2["SAMPLE"] = "sample";
65
+ return CustomsContentsType2;
66
+ })(CustomsContentsType || {});
67
+ var CustomsNonDeliveryType = /* @__PURE__ */ ((CustomsNonDeliveryType2) => {
68
+ CustomsNonDeliveryType2["RETURN_TO_SENDER"] = "return_to_sender";
69
+ CustomsNonDeliveryType2["TREAT_AS_ABANDONED"] = "treat_as_abandoned";
70
+ return CustomsNonDeliveryType2;
71
+ })(CustomsNonDeliveryType || {});
72
+ var InsuranceProviderType = /* @__PURE__ */ ((InsuranceProviderType2) => {
73
+ InsuranceProviderType2["SHIPSURANCE"] = "shipsurance";
74
+ InsuranceProviderType2["CARRIER"] = "carrier";
75
+ InsuranceProviderType2["THIRD_PARTY"] = "third_party";
76
+ InsuranceProviderType2["NONE"] = "none";
77
+ return InsuranceProviderType2;
78
+ })(InsuranceProviderType || {});
1826
79
 
1827
- try {
1828
- promise = dispatchRequest(newConfig);
1829
- } catch (error) {
1830
- return Promise.reject(error);
1831
- }
80
+ const types = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
81
+ __proto__: null,
82
+ CodedError,
83
+ ConfirmationType,
84
+ CreditCardVendor,
85
+ Currency,
86
+ CustomsContentsType,
87
+ CustomsNonDeliveryType,
88
+ InsuranceProviderType
89
+ }, Symbol.toStringTag, { value: 'Module' }));
1832
90
 
1833
- while (responseInterceptorChain.length) {
1834
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
91
+ class AccountSettingsAPI {
92
+ constructor(client) {
93
+ this.client = client;
94
+ this.get = () => {
95
+ return this.client.get("/v1/account/settings");
96
+ };
97
+ this.update = (settings) => {
98
+ return this.client.put("/v1/account/settings", settings);
99
+ };
100
+ this.client = client;
1835
101
  }
1836
-
1837
- return promise;
1838
- };
1839
-
1840
- Axios$1.prototype.getUri = function getUri(config) {
1841
- config = mergeConfig$1(this.defaults, config);
1842
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
1843
- };
1844
-
1845
- // Provide aliases for supported request methods
1846
- utils$4.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
1847
- /*eslint func-names:0*/
1848
- Axios$1.prototype[method] = function(url, config) {
1849
- return this.request(mergeConfig$1(config || {}, {
1850
- method: method,
1851
- url: url,
1852
- data: (config || {}).data
1853
- }));
1854
- };
1855
- });
1856
-
1857
- utils$4.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1858
- /*eslint func-names:0*/
1859
- Axios$1.prototype[method] = function(url, data, config) {
1860
- return this.request(mergeConfig$1(config || {}, {
1861
- method: method,
1862
- url: url,
1863
- data: data
1864
- }));
1865
- };
1866
- });
1867
-
1868
- var Axios_1 = Axios$1;
1869
-
1870
- var CancelToken_1;
1871
- var hasRequiredCancelToken;
1872
-
1873
- function requireCancelToken () {
1874
- if (hasRequiredCancelToken) return CancelToken_1;
1875
- hasRequiredCancelToken = 1;
1876
-
1877
- var Cancel = requireCancel();
1878
-
1879
- /**
1880
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
1881
- *
1882
- * @class
1883
- * @param {Function} executor The executor function.
1884
- */
1885
- function CancelToken(executor) {
1886
- if (typeof executor !== 'function') {
1887
- throw new TypeError('executor must be a function.');
1888
- }
1889
-
1890
- var resolvePromise;
1891
-
1892
- this.promise = new Promise(function promiseExecutor(resolve) {
1893
- resolvePromise = resolve;
1894
- });
1895
-
1896
- var token = this;
1897
-
1898
- // eslint-disable-next-line func-names
1899
- this.promise.then(function(cancel) {
1900
- if (!token._listeners) return;
1901
-
1902
- var i;
1903
- var l = token._listeners.length;
1904
-
1905
- for (i = 0; i < l; i++) {
1906
- token._listeners[i](cancel);
1907
- }
1908
- token._listeners = null;
1909
- });
1910
-
1911
- // eslint-disable-next-line func-names
1912
- this.promise.then = function(onfulfilled) {
1913
- var _resolve;
1914
- // eslint-disable-next-line func-names
1915
- var promise = new Promise(function(resolve) {
1916
- token.subscribe(resolve);
1917
- _resolve = resolve;
1918
- }).then(onfulfilled);
1919
-
1920
- promise.cancel = function reject() {
1921
- token.unsubscribe(_resolve);
1922
- };
1923
-
1924
- return promise;
1925
- };
1926
-
1927
- executor(function cancel(message) {
1928
- if (token.reason) {
1929
- // Cancellation has already been requested
1930
- return;
1931
- }
1932
-
1933
- token.reason = new Cancel(message);
1934
- resolvePromise(token.reason);
1935
- });
1936
- }
1937
-
1938
- /**
1939
- * Throws a `Cancel` if cancellation has been requested.
1940
- */
1941
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
1942
- if (this.reason) {
1943
- throw this.reason;
1944
- }
1945
- };
1946
-
1947
- /**
1948
- * Subscribe to the cancel signal
1949
- */
1950
-
1951
- CancelToken.prototype.subscribe = function subscribe(listener) {
1952
- if (this.reason) {
1953
- listener(this.reason);
1954
- return;
1955
- }
1956
-
1957
- if (this._listeners) {
1958
- this._listeners.push(listener);
1959
- } else {
1960
- this._listeners = [listener];
1961
- }
1962
- };
1963
-
1964
- /**
1965
- * Unsubscribe from the cancel signal
1966
- */
1967
-
1968
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
1969
- if (!this._listeners) {
1970
- return;
1971
- }
1972
- var index = this._listeners.indexOf(listener);
1973
- if (index !== -1) {
1974
- this._listeners.splice(index, 1);
1975
- }
1976
- };
1977
-
1978
- /**
1979
- * Returns an object that contains a new `CancelToken` and a function that, when called,
1980
- * cancels the `CancelToken`.
1981
- */
1982
- CancelToken.source = function source() {
1983
- var cancel;
1984
- var token = new CancelToken(function executor(c) {
1985
- cancel = c;
1986
- });
1987
- return {
1988
- token: token,
1989
- cancel: cancel
1990
- };
1991
- };
1992
-
1993
- CancelToken_1 = CancelToken;
1994
- return CancelToken_1;
1995
- }
1996
-
1997
- var spread;
1998
- var hasRequiredSpread;
1999
-
2000
- function requireSpread () {
2001
- if (hasRequiredSpread) return spread;
2002
- hasRequiredSpread = 1;
2003
-
2004
- /**
2005
- * Syntactic sugar for invoking a function and expanding an array for arguments.
2006
- *
2007
- * Common use case would be to use `Function.prototype.apply`.
2008
- *
2009
- * ```js
2010
- * function f(x, y, z) {}
2011
- * var args = [1, 2, 3];
2012
- * f.apply(null, args);
2013
- * ```
2014
- *
2015
- * With `spread` this example can be re-written.
2016
- *
2017
- * ```js
2018
- * spread(function(x, y, z) {})([1, 2, 3]);
2019
- * ```
2020
- *
2021
- * @param {Function} callback
2022
- * @returns {Function}
2023
- */
2024
- spread = function spread(callback) {
2025
- return function wrap(arr) {
2026
- return callback.apply(null, arr);
2027
- };
2028
- };
2029
- return spread;
2030
102
  }
2031
103
 
2032
- var isAxiosError;
2033
- var hasRequiredIsAxiosError;
2034
-
2035
- function requireIsAxiosError () {
2036
- if (hasRequiredIsAxiosError) return isAxiosError;
2037
- hasRequiredIsAxiosError = 1;
2038
-
2039
- var utils = utils$c;
2040
-
2041
- /**
2042
- * Determines whether the payload is an error thrown by Axios
2043
- *
2044
- * @param {*} payload The value to test
2045
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2046
- */
2047
- isAxiosError = function isAxiosError(payload) {
2048
- return utils.isObject(payload) && (payload.isAxiosError === true);
2049
- };
2050
- return isAxiosError;
104
+ class AddressesAPI {
105
+ constructor(client) {
106
+ this.client = client;
107
+ this.validate = (addresses) => {
108
+ return this.client.post("/v1/addresses/validate", addresses);
109
+ };
110
+ this.parse = (text, address) => {
111
+ return this.client.put("/v1/addresses/recognize", {
112
+ address,
113
+ text
114
+ });
115
+ };
116
+ this.client = client;
117
+ }
2051
118
  }
2052
119
 
2053
- var utils$3 = utils$c;
2054
- var bind$2 = bind$4;
2055
- var Axios = Axios_1;
2056
- var mergeConfig = mergeConfig$2;
2057
- var defaults$2 = defaults_1;
2058
-
2059
- /**
2060
- * Create an instance of Axios
2061
- *
2062
- * @param {Object} defaultConfig The default config for the instance
2063
- * @return {Axios} A new instance of Axios
2064
- */
2065
- function createInstance(defaultConfig) {
2066
- var context = new Axios(defaultConfig);
2067
- var instance = bind$2(Axios.prototype.request, context);
2068
-
2069
- // Copy axios.prototype to instance
2070
- utils$3.extend(instance, Axios.prototype, context);
2071
-
2072
- // Copy context to instance
2073
- utils$3.extend(instance, context);
120
+ const isCodedErrors = (errs) => Array.isArray(errs) && errs.every((err) => isCodedError(err));
121
+ const isCodedError = (err) => !!err.errorCode;
2074
122
 
2075
- // Factory for creating new instances
2076
- instance.create = function create(instanceConfig) {
2077
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
2078
- };
123
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2079
124
 
2080
- return instance;
125
+ function getAugmentedNamespace(n) {
126
+ if (n.__esModule) return n;
127
+ var f = n.default;
128
+ if (typeof f == "function") {
129
+ var a = function a () {
130
+ if (this instanceof a) {
131
+ var args = [null];
132
+ args.push.apply(args, arguments);
133
+ var Ctor = Function.bind.apply(f, args);
134
+ return new Ctor();
135
+ }
136
+ return f.apply(this, arguments);
137
+ };
138
+ a.prototype = f.prototype;
139
+ } else a = {};
140
+ Object.defineProperty(a, '__esModule', {value: true});
141
+ Object.keys(n).forEach(function (k) {
142
+ var d = Object.getOwnPropertyDescriptor(n, k);
143
+ Object.defineProperty(a, k, d.get ? d : {
144
+ enumerable: true,
145
+ get: function () {
146
+ return n[k];
147
+ }
148
+ });
149
+ });
150
+ return a;
2081
151
  }
2082
152
 
2083
- // Create the default instance to be exported
2084
- var axios$1 = createInstance(defaults$2);
2085
-
2086
- // Expose Axios class to allow class inheritance
2087
- axios$1.Axios = Axios;
2088
-
2089
- // Expose Cancel & CancelToken
2090
- axios$1.Cancel = requireCancel();
2091
- axios$1.CancelToken = requireCancelToken();
2092
- axios$1.isCancel = requireIsCancel();
2093
- axios$1.VERSION = requireData().version;
2094
-
2095
- // Expose all/spread
2096
- axios$1.all = function all(promises) {
2097
- return Promise.all(promises);
2098
- };
2099
- axios$1.spread = requireSpread();
2100
-
2101
- // Expose isAxiosError
2102
- axios$1.isAxiosError = requireIsAxiosError();
2103
-
2104
- axios$2.exports = axios$1;
2105
-
2106
- // Allow use of default import syntax in TypeScript
2107
- axiosExports.default = axios$1;
2108
-
2109
- (function (module) {
2110
- module.exports = axiosExports;
2111
- } (axios$3));
2112
-
2113
- const axios = /*@__PURE__*/getDefaultExportFromCjs(axiosExports$1);
2114
-
2115
153
  var ipaddrExports = {};
2116
154
  var ipaddr = {
2117
155
  get exports(){ return ipaddrExports; },
@@ -2910,6 +948,12 @@ class CarriersAPI {
2910
948
  }
2911
949
  });
2912
950
  };
951
+ this.getCountries = (carrierId) => {
952
+ return this.client.get(`/v1/carriers/${carrierId}/countries`);
953
+ };
954
+ this.getCurrencies = (carrierId) => {
955
+ return this.client.get(`/v1/carriers/${carrierId}/currencies`);
956
+ };
2913
957
  this.client = client;
2914
958
  }
2915
959
  }