@shipengine/js-api 3.1.0 → 3.2.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.
- package/funding-sources/api.d.ts +1 -0
- package/funding-sources/types.d.ts +32 -0
- package/index.js +36 -141
- package/index.mjs +35 -142
- package/package.json +1 -1
- package/utilities/casing.d.ts +2 -0
- package/utilities/index.d.ts +1 -0
package/funding-sources/api.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Money } from "../payments";
|
|
|
3
3
|
import { CreationRangeQuery, PageableQuery } from "../resources";
|
|
4
4
|
import { AddFundsResponse, CarrierRegistration, CarrierRegistrationResponse, CreateFundingSource, CreditCardInfo, FundingSource, FundingSourceAddress, FundingSourceCreateResponse, FundingSourceTransactionsResponse, InsuranceFundingSourceAcceptedTermsResponse, MetadataResponse } from "./types";
|
|
5
5
|
/**
|
|
6
|
+
* @internal
|
|
6
7
|
* # Funding Sources API module - /v1/funding_sources
|
|
7
8
|
* Docs: https://auctane.atlassian.net/wiki/spaces/SE/pages/3628370266/ShipEngine+Funding+Sources+API
|
|
8
9
|
*/
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { PageableResult } from "../resources";
|
|
2
2
|
/**
|
|
3
|
+
* @internal
|
|
3
4
|
* An encoded device fingerprint string containing information about the end-user's computing device such as OS, browser, etc.
|
|
4
5
|
* Required for carrier registration and US Wallet creation.
|
|
5
6
|
*/
|
|
6
7
|
type IovationBlackBox = string;
|
|
8
|
+
/** @internal */
|
|
7
9
|
export type CreateFundingSource = {
|
|
8
10
|
acceptedTerms: Term[];
|
|
9
11
|
agreeToTerms: boolean;
|
|
@@ -13,7 +15,9 @@ export type CreateFundingSource = {
|
|
|
13
15
|
creditCardInfo: CreditCardInfo;
|
|
14
16
|
};
|
|
15
17
|
};
|
|
18
|
+
/** @internal */
|
|
16
19
|
export type FundingSource = {
|
|
20
|
+
balance: number;
|
|
17
21
|
billingInfo: FundingSourceAddress;
|
|
18
22
|
currencyCode: string;
|
|
19
23
|
defaultCarrierId: string;
|
|
@@ -22,16 +26,21 @@ export type FundingSource = {
|
|
|
22
26
|
creditCardInfo: AbbreviatedCreditCardInfo | null;
|
|
23
27
|
};
|
|
24
28
|
};
|
|
29
|
+
/** @internal */
|
|
25
30
|
export type AbbreviatedCreditCardInfo = {
|
|
26
31
|
cardNumberLastFour: string;
|
|
27
32
|
provider: Provider;
|
|
28
33
|
};
|
|
34
|
+
/** @internal */
|
|
29
35
|
export type FundingSourceInsuranceProvider = "parcelguard" | "x_cover";
|
|
36
|
+
/** @internal */
|
|
30
37
|
export type Provider = "visa" | "mastercard" | "americanExpress" | "discover";
|
|
38
|
+
/** @internal */
|
|
31
39
|
export interface FundingSourcePickupAddress extends Omit<FundingSourceAddress, "email" | "phone"> {
|
|
32
40
|
email?: string;
|
|
33
41
|
phone?: string;
|
|
34
42
|
}
|
|
43
|
+
/** @internal */
|
|
35
44
|
export type FundingSourceCarrier = {
|
|
36
45
|
acceptedTerms: Term[];
|
|
37
46
|
agreeToTerms: boolean;
|
|
@@ -40,16 +49,19 @@ export type FundingSourceCarrier = {
|
|
|
40
49
|
iovationBlackBox: IovationBlackBox;
|
|
41
50
|
pickupAddress?: FundingSourcePickupAddress;
|
|
42
51
|
};
|
|
52
|
+
/** @internal */
|
|
43
53
|
export type CarrierRegistrationInsuranceProvider = {
|
|
44
54
|
acceptedTerms: Term[];
|
|
45
55
|
agreeToTerms: boolean;
|
|
46
56
|
fundingSourceId: string;
|
|
47
57
|
provider: FundingSourceInsuranceProvider;
|
|
48
58
|
};
|
|
59
|
+
/** @internal */
|
|
49
60
|
export interface CarrierRegistration {
|
|
50
61
|
carriers?: FundingSourceCarrier[];
|
|
51
62
|
insuranceProviders?: CarrierRegistrationInsuranceProvider[];
|
|
52
63
|
}
|
|
64
|
+
/** @internal */
|
|
53
65
|
export interface FundingSourceAddress {
|
|
54
66
|
addressLine1: string;
|
|
55
67
|
addressLine2?: string;
|
|
@@ -62,6 +74,7 @@ export interface FundingSourceAddress {
|
|
|
62
74
|
postalCode: string;
|
|
63
75
|
stateProvince: string;
|
|
64
76
|
}
|
|
77
|
+
/** @internal */
|
|
65
78
|
export interface CreditCardInfo {
|
|
66
79
|
cardNumber: string;
|
|
67
80
|
cvv: string;
|
|
@@ -70,21 +83,26 @@ export interface CreditCardInfo {
|
|
|
70
83
|
name: string;
|
|
71
84
|
provider: Provider;
|
|
72
85
|
}
|
|
86
|
+
/** @internal */
|
|
73
87
|
export interface Term {
|
|
74
88
|
termType: string;
|
|
75
89
|
version: string;
|
|
76
90
|
}
|
|
91
|
+
/** @internal */
|
|
77
92
|
export interface MetadataTermLink {
|
|
78
93
|
link: string;
|
|
79
94
|
locale: string;
|
|
80
95
|
title: string;
|
|
81
96
|
}
|
|
97
|
+
/** @internal */
|
|
82
98
|
export interface MetadataOptionalTerm extends Term {
|
|
83
99
|
links: MetadataTermLink[];
|
|
84
100
|
}
|
|
101
|
+
/** @internal */
|
|
85
102
|
export interface MetadataRequiredTerm extends Term {
|
|
86
103
|
links: MetadataTermLink[];
|
|
87
104
|
}
|
|
105
|
+
/** @internal */
|
|
88
106
|
export declare enum MetadataCapability {
|
|
89
107
|
AutoFunding = "auto_funding",
|
|
90
108
|
UpdatePaymentMethod = "update_payment_method",
|
|
@@ -97,6 +115,7 @@ export declare enum MetadataCapability {
|
|
|
97
115
|
AccountSettingsLink = "account_settings_link",
|
|
98
116
|
Unknown = "unknown"
|
|
99
117
|
}
|
|
118
|
+
/** @internal */
|
|
100
119
|
export declare enum MetadataRequirement {
|
|
101
120
|
BillingAddress = "billing_address",
|
|
102
121
|
CurrencyCode = "currency_code",
|
|
@@ -106,6 +125,7 @@ export declare enum MetadataRequirement {
|
|
|
106
125
|
PickupAddress = "pickup_address",
|
|
107
126
|
Unknown = "unknown"
|
|
108
127
|
}
|
|
128
|
+
/** @internal */
|
|
109
129
|
export declare enum MetadataSatisfyingFormTypes {
|
|
110
130
|
Address = "address",
|
|
111
131
|
CreditCard = "credit_card",
|
|
@@ -113,17 +133,21 @@ export declare enum MetadataSatisfyingFormTypes {
|
|
|
113
133
|
StampsSellerLabelProvider = "stamps_seller_label_provider",
|
|
114
134
|
Unknown = "unknown"
|
|
115
135
|
}
|
|
136
|
+
/** @internal */
|
|
116
137
|
export type MetadataRegistrationRequirement = {
|
|
117
138
|
requirementType: MetadataRequirement;
|
|
118
139
|
satisfyingFormTypes: MetadataSatisfyingFormTypes[];
|
|
119
140
|
};
|
|
141
|
+
/** @internal */
|
|
120
142
|
export type MetadataCarrierProfile = {
|
|
121
143
|
capabilities: MetadataCapability[] | null;
|
|
122
144
|
carrierCode: string;
|
|
123
145
|
registrationRequirements: MetadataRegistrationRequirement[];
|
|
124
146
|
requiredTerms: MetadataRequiredTerm[];
|
|
125
147
|
};
|
|
148
|
+
/** @internal */
|
|
126
149
|
export type TransactionCategory = "adjustment" | "credit" | "debit" | "funds_added" | "insurance" | "label" | "refund" | "service_charge" | "unknown";
|
|
150
|
+
/** @internal */
|
|
127
151
|
export type FundingSourceTransactionInvoice = {
|
|
128
152
|
invoiceDownload: {
|
|
129
153
|
pdf: string;
|
|
@@ -131,6 +155,7 @@ export type FundingSourceTransactionInvoice = {
|
|
|
131
155
|
invoiceId: string;
|
|
132
156
|
reference: string;
|
|
133
157
|
};
|
|
158
|
+
/** @internal */
|
|
134
159
|
export type FundingSourceTransaction = {
|
|
135
160
|
description?: string | null;
|
|
136
161
|
endingBalance: {
|
|
@@ -151,16 +176,19 @@ export type FundingSourceTransaction = {
|
|
|
151
176
|
transactionCategory: TransactionCategory;
|
|
152
177
|
transactionDate: string;
|
|
153
178
|
};
|
|
179
|
+
/** @internal */
|
|
154
180
|
export interface FundingSourceInsuranceProviderResponse {
|
|
155
181
|
errorMessage: null | string;
|
|
156
182
|
fundingSourceId: string;
|
|
157
183
|
isSuccessful: boolean;
|
|
158
184
|
provider: FundingSourceInsuranceProvider;
|
|
159
185
|
}
|
|
186
|
+
/** @internal */
|
|
160
187
|
export interface FundingSourceCreateResponse {
|
|
161
188
|
fundingSource: FundingSource;
|
|
162
189
|
insuranceProviderAttachmentResults: FundingSourceInsuranceProviderResponse[];
|
|
163
190
|
}
|
|
191
|
+
/** @internal */
|
|
164
192
|
export interface CarrierRegistrationResponse {
|
|
165
193
|
carrierAttachmentResults: [
|
|
166
194
|
{
|
|
@@ -173,6 +201,7 @@ export interface CarrierRegistrationResponse {
|
|
|
173
201
|
];
|
|
174
202
|
insuranceProviderAttachmentResults: FundingSourceInsuranceProviderResponse[];
|
|
175
203
|
}
|
|
204
|
+
/** @internal */
|
|
176
205
|
export interface MetadataResponse {
|
|
177
206
|
defaultFundingSourceProfile: {
|
|
178
207
|
capabilities: MetadataCapability[] | null;
|
|
@@ -188,15 +217,18 @@ export interface MetadataResponse {
|
|
|
188
217
|
currencyCode: string;
|
|
189
218
|
};
|
|
190
219
|
}
|
|
220
|
+
/** @internal */
|
|
191
221
|
export type AddFundsResponse = {
|
|
192
222
|
balance: {
|
|
193
223
|
amount: number;
|
|
194
224
|
currency: string;
|
|
195
225
|
};
|
|
196
226
|
};
|
|
227
|
+
/** @internal */
|
|
197
228
|
export type FundingSourceTransactionsResponse = {
|
|
198
229
|
transactions: FundingSourceTransaction[];
|
|
199
230
|
} & PageableResult;
|
|
231
|
+
/** @internal */
|
|
200
232
|
export type InsuranceFundingSourceAcceptedTermsResponse = {
|
|
201
233
|
acceptedTerms: Term[];
|
|
202
234
|
};
|
package/index.js
CHANGED
|
@@ -1007,6 +1007,37 @@ const getEndUserIpAddress = () => __async$6(void 0, null, function* () {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
});
|
|
1009
1009
|
|
|
1010
|
+
const camelizeKeys = (obj) => {
|
|
1011
|
+
if (Array.isArray(obj)) {
|
|
1012
|
+
return obj.map(camelizeKeys);
|
|
1013
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
1014
|
+
const newObj = {};
|
|
1015
|
+
for (const key in obj) {
|
|
1016
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1017
|
+
const newKey = key.replace(/_([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
1018
|
+
newObj[newKey] = camelizeKeys(obj[key]);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
return newObj;
|
|
1022
|
+
}
|
|
1023
|
+
return obj;
|
|
1024
|
+
};
|
|
1025
|
+
const decamelizeKeys = (obj, separator = "_") => {
|
|
1026
|
+
if (Array.isArray(obj)) {
|
|
1027
|
+
return obj.map((item) => decamelizeKeys(item, separator));
|
|
1028
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
1029
|
+
const newObj = {};
|
|
1030
|
+
for (const key in obj) {
|
|
1031
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1032
|
+
const newKey = key.replace(/([A-Z])/g, (match) => separator + match.toLowerCase());
|
|
1033
|
+
newObj[newKey] = decamelizeKeys(obj[key], separator);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return newObj;
|
|
1037
|
+
}
|
|
1038
|
+
return obj;
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1010
1041
|
var __defProp$4 = Object.defineProperty;
|
|
1011
1042
|
var __defProps$1 = Object.defineProperties;
|
|
1012
1043
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
@@ -1259,144 +1290,6 @@ class ConnectionsAPI {
|
|
|
1259
1290
|
|
|
1260
1291
|
var o={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},l={};function a(e){return "string"==typeof e?o[e.toLowerCase()]:e}function c(e,r){return c=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},c(e,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return !1}}function f(e,r,t){return f=u()?Reflect.construct:function(e,r,t){var s=[null];s.push.apply(s,r);var i=new(Function.bind.apply(e,s));return t&&c(i,t.prototype),i},f.apply(null,arguments)}function h(e){if(null==e)return e;if(Array.isArray(e))return e.slice();if("object"==typeof e){var r={};return Object.keys(e).forEach(function(t){r[t]=e[t];}),r}return e}function v(e){return void 0===e?"undefined":null===e?"null":Array.isArray(e)?"[ "+e.map(function(e){return v(e)}).join(", ")+" ]":"object"==typeof e?JSON.stringify(e):"function"==typeof e?"[Function: "+e.name+"]":"boolean"==typeof e||"number"==typeof e?e:"'"+e.toString()+"'"}function p(e){if("string"!=typeof e){for(var r=new Array(arguments.length),t=0;t<arguments.length;t++)r[t]=v(arguments[t]);return r.join(" ")}for(var s=/%[sdj%]/g,i=1,n=arguments,o=n.length,l=String(e).replace(s,function(e){if("%%"===e)return "%";if(i>=o)return e;switch(e){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(e){return "[Circular]"}default:return e}}),a=n[i];i<o;a=n[++i])l+=null===a||"object"!=typeof a?" "+a:" "+v(a);return l}function m(e,r){var t=e.split("\n");t[0]&&t[0].indexOf("call-stack-error")>=0&&t.shift();var s=t[r],i=null;if(s){var n=/^\s*(at|.*@)\s*(.+)?$/.exec(s);i=Array.isArray(n)&&n[2]?n[2]:s;}return i}Object.keys(o).forEach(function(e){l[o[e]]=e;});var y={};function d(e,r){if(r){if(y[r])return;y[r]=!0;}console.error(e+"\n");}function g(e){return y[e]}function w(){var e=[];return function(r,t){return t&&"object"==typeof t?-1!==e.indexOf(t)?"[Circular]":(e.push(t),t):t}}var b=/*#__PURE__*/function(){function e(){}return e.prototype.write=function(e){e.level<30?console.log(e):e.level<40?console.info(e):e.level<50?console.warn(e):console.error(e),e.err&&e.err.stack&&console.error(e.err.stack),e.obj&&console.log(e.obj);},e}(),j=/*#__PURE__*/function(){function e(r,t,s){var i,n,o,l,a=this;if(!(this instanceof e))return new e(r,t);if(void 0!==t&&(i=r,r=t,!(i instanceof e)))throw new TypeError("invalid Logger creation: do not pass a second arg");if(!r)throw new TypeError("options (object) is required");if(i){if(r.name)throw new TypeError("invalid options.name: child cannot set logger name")}else if(!r.name)throw new TypeError("options.name (string) is required");if(r.stream&&r.streams)throw new TypeError('cannot mix "streams" and "stream" options');if(r.streams&&!Array.isArray(r.streams))throw new TypeError("invalid options.streams: must be an array");if(r.serializers&&("object"!=typeof r.serializers||Array.isArray(r.serializers)))throw new TypeError("invalid options.serializers: must be an object");if(i&&s){this._level=i._level,this.streams=i.streams,this.serializers=i.serializers,this.src=i.src,n=this.fields={};var c=Object.keys(i.fields);for(l=0;l<c.length;l++)n[o=c[l]]=i.fields[o];var u=Object.keys(r);for(l=0;l<u.length;l++)n[o=u[l]]=r[o];}else {if(i){for(this._level=i._level,this.streams=[],l=0;l<i.streams.length;l++){var f=h(i.streams[l]);this.streams.push(f);}this.serializers=h(i.serializers),this.src=i.src,this.fields=h(i.fields),r.level&&this.level(r.level);}else this._level=Number.POSITIVE_INFINITY,this.streams=[],this.serializers=null,this.src=!1,this.fields={};r.stream?this.addStream({type:"stream",stream:r.stream,level:r.level}):r.streams?r.streams.forEach(function(e){a.addStream(e,r.level);}):i&&r.level?this.level(r.level):i||this.addStream({type:"raw",stream:new b,level:r.level}),r.serializers&&this.addSerializers(r.serializers),r.src&&(this.src=!0),delete(n=h(r)).stream,delete n.level,delete n.streams,delete n.serializers,delete n.src,this.serializers&&this._applySerializers(n),Object.keys(n).forEach(function(e){a.fields[e]=n[e];});}}var r=e.prototype;return r.addStream=function(e,r){void 0===r&&(r=30),(e=h(e)).type="raw",e.level=a(e.level||r),e.level<this._level&&(this._level=e.level),this.streams.push(e),delete this.haveNonRawStreams;},r.addSerializers=function(e){var r=this;this.serializers||(this.serializers={}),Object.keys(e).forEach(function(t){var s=e[t];if("function"!=typeof s)throw new TypeError(p('invalid serializer for "%s" field: must be a function',t));r.serializers[t]=s;});},r.child=function(e,r){return new this.constructor(this,e||{},r)},r.level=function(e){if(void 0===e)return this._level;for(var r=a(e),t=this.streams.length,s=0;s<t;s++)this.streams[s].level=r;this._level=r;},r.levels=function(e,r){if(void 0===e)return this.streams.map(function(e){return e.level});var t;if("number"==typeof e){if(void 0===(t=this.streams[e]))throw new Error("invalid stream index: "+e)}else {for(var s=this.streams.length,i=0;i<s;i++){var n=this.streams[i];if(n.name===e){t=n;break}}if(!t)throw new Error(p('no stream with name "%s"',e))}if(void 0===r)return t.level;var o=a(r);t.level=o,o<this._level&&(this._level=o);},r._applySerializers=function(e,r){var t=this;Object.keys(this.serializers).forEach(function(s){if(!(void 0===e[s]||r&&r[s]))try{e[s]=t.serializers[s](e[s]);}catch(r){d(p('bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.\n%s',s,r.stack||r)),e[s]=p('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)',s);}});},r._emit=function(e,r){var t,s;if(void 0===this.haveNonRawStreams)for(this.haveNonRawStreams=!1,t=0;t<this.streams.length;t++)if(!this.streams[t].raw){this.haveNonRawStreams=!0;break}if(r||this.haveNonRawStreams)try{s=JSON.stringify(e,w())+"\n";}catch(r){var i=r.stack.split(/\n/g,2).join("\n");d('bunyan: ERROR: Exception in `JSON.stringify(rec)`. You can install the "safe-json-stringify" module to have Bunyan fallback to safer stringification. Record:\n'+function(e,r){return r||(r=" "),r+e.split(/\r?\n/g).join("\n"+r)}(p("%s\n%s",e,r.stack)),i),s=p("(Exception in JSON.stringify(rec): %j. See stderr for details.)\n",r.message);}if(r)return s;var n=e.level;for(t=0;t<this.streams.length;t++){var o=this.streams[t];o.level<=n&&o.stream.write(e);}return s},e}();function z(e){return function(){var r=this;function t(t){var n;t[0]instanceof Error?(s={err:r.serializers&&r.serializers.err?r.serializers.err(t[0]):k.err(t[0])},n={err:!0},i=1===t.length?[s.err.message]:Array.prototype.slice.call(t,1)):"object"!=typeof t[0]&&null!==t[0]||Array.isArray(t[0])?(s=null,i=Array.prototype.slice.call(t)):(s=t[0],i=1===t.length&&s.err&&s.err instanceof Error?[s.err.message]:Array.prototype.slice.call(t,1));var o=h(r.fields);o.level=e;var a=s?h(s):null;if(a&&(r.serializers&&r._applySerializers(a,n),Object.keys(a).forEach(function(e){o[e]=a[e];})),o.levelName=l[e],o.msg=i.length?p.apply(r,i):"",o.time||(o.time=new Date),r.src&&!o.src)try{throw new Error("call-stack-error")}catch(e){var c=e.stack?m(e.stack,2):"";c||g("src")||d("Unable to determine src line info","src"),o.src=c||"";}return o.v=1,o}var s=null,i=arguments,n=null;if(0===arguments.length)return this._level<=e;this._level>e||(n=t(i),this._emit(n));}}function S(e){var r=e.stack||e.toString();if(e.cause&&"function"==typeof e.cause){var t=e.cause();t&&(r+="\nCaused by: "+S(t));}return r}j.prototype.trace=z(10),j.prototype.debug=z(20),j.prototype.info=z(30),j.prototype.warn=z(40),j.prototype.error=z(50),j.prototype.fatal=z(60);var k={err:function(e){return e&&e.stack?{message:e.message,name:e.name,stack:S(e),code:e.code,signal:e.signal}:e}};function E(){return f(j,[].slice.call(arguments))}var A={levels:{trace:"color: DeepPink",debug:"color: GoldenRod",info:"color: DarkTurquoise",warn:"color: Purple",error:"color: Crimson",fatal:"color: Black"},def:"color: DimGray",msg:"color: SteelBlue",src:"color: DimGray; font-style: italic; font-size: 0.9em"},R=/*#__PURE__*/function(){function e(e){var r=void 0===e?{}:e,t=r.logByLevel,s=r.css,i=void 0===s?A:s;this.logByLevel=void 0!==t&&t,this.css=i;}return e.prototype.write=function(e){var r,t,s=this.css.def,i=this.css.msg,n=this.css.src,o=e.childName?e.name+"/"+e.childName:e.name,a=l[e.level],c=(Array(6-a.length).join(" ")+a).toUpperCase();this.logByLevel?(10===e.level?a="debug":60===e.level&&(a="error"),t="function"==typeof console[a]?console[a]:console.log):t=console.log,r=e.level<20?this.css.levels.trace:e.level<30?this.css.levels.debug:e.level<40?this.css.levels.info:e.level<50?this.css.levels.warn:e.level<60?this.css.levels.error:this.css.levels.fatal;var u=function(e,r){return Array(r+1-(e+"").length).join("0")+e},f=[];f.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s "+(e.src?"%c%s":"")),f.push(u(e.time.getHours(),2)),f.push(u(e.time.getMinutes(),2)),f.push(u(e.time.getSeconds(),2)),f.push(u(e.time.getMilliseconds(),4)),f.push(r),f.push(c),f.push(s),f.push(o),f.push(i),f.push(e.msg),e.src&&(f.push(n),f.push(e.src)),e.obj&&(f.push("\n"),f.push(e.obj)),e.err&&e.err.stack&&(f.push("\n"),f.push(e.err.stack)),t.apply(console,f);},e.getDefaultCss=function(){return A},e}();
|
|
1261
1292
|
|
|
1262
|
-
var humpsExports = {};
|
|
1263
|
-
var humps = {
|
|
1264
|
-
get exports(){ return humpsExports; },
|
|
1265
|
-
set exports(v){ humpsExports = v; },
|
|
1266
|
-
};
|
|
1267
|
-
|
|
1268
|
-
(function (module) {
|
|
1269
|
-
(function(global) {
|
|
1270
|
-
|
|
1271
|
-
var _processKeys = function(convert, obj, options) {
|
|
1272
|
-
if(!_isObject(obj) || _isDate(obj) || _isRegExp(obj) || _isBoolean(obj) || _isFunction(obj)) {
|
|
1273
|
-
return obj;
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
var output,
|
|
1277
|
-
i = 0,
|
|
1278
|
-
l = 0;
|
|
1279
|
-
|
|
1280
|
-
if(_isArray(obj)) {
|
|
1281
|
-
output = [];
|
|
1282
|
-
for(l=obj.length; i<l; i++) {
|
|
1283
|
-
output.push(_processKeys(convert, obj[i], options));
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
else {
|
|
1287
|
-
output = {};
|
|
1288
|
-
for(var key in obj) {
|
|
1289
|
-
if(Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1290
|
-
output[convert(key, options)] = _processKeys(convert, obj[key], options);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
return output;
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1297
|
-
// String conversion methods
|
|
1298
|
-
|
|
1299
|
-
var separateWords = function(string, options) {
|
|
1300
|
-
options = options || {};
|
|
1301
|
-
var separator = options.separator || '_';
|
|
1302
|
-
var split = options.split || /(?=[A-Z])/;
|
|
1303
|
-
|
|
1304
|
-
return string.split(split).join(separator);
|
|
1305
|
-
};
|
|
1306
|
-
|
|
1307
|
-
var camelize = function(string) {
|
|
1308
|
-
if (_isNumerical(string)) {
|
|
1309
|
-
return string;
|
|
1310
|
-
}
|
|
1311
|
-
string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) {
|
|
1312
|
-
return chr ? chr.toUpperCase() : '';
|
|
1313
|
-
});
|
|
1314
|
-
// Ensure 1st char is always lowercase
|
|
1315
|
-
return string.substr(0, 1).toLowerCase() + string.substr(1);
|
|
1316
|
-
};
|
|
1317
|
-
|
|
1318
|
-
var pascalize = function(string) {
|
|
1319
|
-
var camelized = camelize(string);
|
|
1320
|
-
// Ensure 1st char is always uppercase
|
|
1321
|
-
return camelized.substr(0, 1).toUpperCase() + camelized.substr(1);
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
|
-
var decamelize = function(string, options) {
|
|
1325
|
-
return separateWords(string, options).toLowerCase();
|
|
1326
|
-
};
|
|
1327
|
-
|
|
1328
|
-
// Utilities
|
|
1329
|
-
// Taken from Underscore.js
|
|
1330
|
-
|
|
1331
|
-
var toString = Object.prototype.toString;
|
|
1332
|
-
|
|
1333
|
-
var _isFunction = function(obj) {
|
|
1334
|
-
return typeof(obj) === 'function';
|
|
1335
|
-
};
|
|
1336
|
-
var _isObject = function(obj) {
|
|
1337
|
-
return obj === Object(obj);
|
|
1338
|
-
};
|
|
1339
|
-
var _isArray = function(obj) {
|
|
1340
|
-
return toString.call(obj) == '[object Array]';
|
|
1341
|
-
};
|
|
1342
|
-
var _isDate = function(obj) {
|
|
1343
|
-
return toString.call(obj) == '[object Date]';
|
|
1344
|
-
};
|
|
1345
|
-
var _isRegExp = function(obj) {
|
|
1346
|
-
return toString.call(obj) == '[object RegExp]';
|
|
1347
|
-
};
|
|
1348
|
-
var _isBoolean = function(obj) {
|
|
1349
|
-
return toString.call(obj) == '[object Boolean]';
|
|
1350
|
-
};
|
|
1351
|
-
|
|
1352
|
-
// Performant way to determine if obj coerces to a number
|
|
1353
|
-
var _isNumerical = function(obj) {
|
|
1354
|
-
obj = obj - 0;
|
|
1355
|
-
return obj === obj;
|
|
1356
|
-
};
|
|
1357
|
-
|
|
1358
|
-
// Sets up function which handles processing keys
|
|
1359
|
-
// allowing the convert function to be modified by a callback
|
|
1360
|
-
var _processor = function(convert, options) {
|
|
1361
|
-
var callback = options && 'process' in options ? options.process : options;
|
|
1362
|
-
|
|
1363
|
-
if(typeof(callback) !== 'function') {
|
|
1364
|
-
return convert;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
return function(string, options) {
|
|
1368
|
-
return callback(string, convert, options);
|
|
1369
|
-
}
|
|
1370
|
-
};
|
|
1371
|
-
|
|
1372
|
-
var humps = {
|
|
1373
|
-
camelize: camelize,
|
|
1374
|
-
decamelize: decamelize,
|
|
1375
|
-
pascalize: pascalize,
|
|
1376
|
-
depascalize: decamelize,
|
|
1377
|
-
camelizeKeys: function(object, options) {
|
|
1378
|
-
return _processKeys(_processor(camelize, options), object);
|
|
1379
|
-
},
|
|
1380
|
-
decamelizeKeys: function(object, options) {
|
|
1381
|
-
return _processKeys(_processor(decamelize, options), object, options);
|
|
1382
|
-
},
|
|
1383
|
-
pascalizeKeys: function(object, options) {
|
|
1384
|
-
return _processKeys(_processor(pascalize, options), object);
|
|
1385
|
-
},
|
|
1386
|
-
depascalizeKeys: function () {
|
|
1387
|
-
return this.decamelizeKeys.apply(this, arguments);
|
|
1388
|
-
}
|
|
1389
|
-
};
|
|
1390
|
-
|
|
1391
|
-
if (module.exports) {
|
|
1392
|
-
module.exports = humps;
|
|
1393
|
-
} else {
|
|
1394
|
-
global.humps = humps;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
})(commonjsGlobal);
|
|
1398
|
-
} (humps));
|
|
1399
|
-
|
|
1400
1293
|
class InvalidTokenError extends Error {
|
|
1401
1294
|
}
|
|
1402
1295
|
InvalidTokenError.prototype.name = "InvalidTokenError";
|
|
@@ -21611,11 +21504,11 @@ class ShipEngineAPI {
|
|
|
21611
21504
|
headers: __spreadProps(__spreadValues({}, headers), {
|
|
21612
21505
|
"Content-Type": "application/json"
|
|
21613
21506
|
}),
|
|
21614
|
-
paramsSerializer: (params) => lib.stringify(
|
|
21507
|
+
paramsSerializer: (params) => lib.stringify(decamelizeKeys(params), { arrayFormat: "brackets" }),
|
|
21615
21508
|
transformRequest: [
|
|
21616
21509
|
(data) => {
|
|
21617
21510
|
if (data && !(data instanceof FormData))
|
|
21618
|
-
return
|
|
21511
|
+
return decamelizeKeys(data);
|
|
21619
21512
|
else
|
|
21620
21513
|
return data;
|
|
21621
21514
|
},
|
|
@@ -21635,7 +21528,7 @@ class ShipEngineAPI {
|
|
|
21635
21528
|
},
|
|
21636
21529
|
(data) => {
|
|
21637
21530
|
if (data && !(data instanceof Blob))
|
|
21638
|
-
return
|
|
21531
|
+
return camelizeKeys(data);
|
|
21639
21532
|
else
|
|
21640
21533
|
return data;
|
|
21641
21534
|
}
|
|
@@ -21957,6 +21850,8 @@ exports.ShippingRulesAPI = ShippingRulesAPI;
|
|
|
21957
21850
|
exports.ThemesAPI = ThemesAPI;
|
|
21958
21851
|
exports.WarehousesAPI = WarehousesAPI;
|
|
21959
21852
|
exports.WebhooksAPI = WebhooksAPI;
|
|
21853
|
+
exports.camelizeKeys = camelizeKeys;
|
|
21854
|
+
exports.decamelizeKeys = decamelizeKeys;
|
|
21960
21855
|
exports.getEndUserIpAddress = getEndUserIpAddress;
|
|
21961
21856
|
exports.isCodedError = isCodedError;
|
|
21962
21857
|
exports.isCodedErrors = isCodedErrors;
|
package/index.mjs
CHANGED
|
@@ -1003,6 +1003,37 @@ const getEndUserIpAddress = () => __async$6(void 0, null, function* () {
|
|
|
1003
1003
|
}
|
|
1004
1004
|
});
|
|
1005
1005
|
|
|
1006
|
+
const camelizeKeys = (obj) => {
|
|
1007
|
+
if (Array.isArray(obj)) {
|
|
1008
|
+
return obj.map(camelizeKeys);
|
|
1009
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
1010
|
+
const newObj = {};
|
|
1011
|
+
for (const key in obj) {
|
|
1012
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1013
|
+
const newKey = key.replace(/_([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
1014
|
+
newObj[newKey] = camelizeKeys(obj[key]);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return newObj;
|
|
1018
|
+
}
|
|
1019
|
+
return obj;
|
|
1020
|
+
};
|
|
1021
|
+
const decamelizeKeys = (obj, separator = "_") => {
|
|
1022
|
+
if (Array.isArray(obj)) {
|
|
1023
|
+
return obj.map((item) => decamelizeKeys(item, separator));
|
|
1024
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
1025
|
+
const newObj = {};
|
|
1026
|
+
for (const key in obj) {
|
|
1027
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1028
|
+
const newKey = key.replace(/([A-Z])/g, (match) => separator + match.toLowerCase());
|
|
1029
|
+
newObj[newKey] = decamelizeKeys(obj[key], separator);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
return newObj;
|
|
1033
|
+
}
|
|
1034
|
+
return obj;
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1006
1037
|
var __defProp$4 = Object.defineProperty;
|
|
1007
1038
|
var __defProps$1 = Object.defineProperties;
|
|
1008
1039
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
@@ -1255,144 +1286,6 @@ class ConnectionsAPI {
|
|
|
1255
1286
|
|
|
1256
1287
|
var o={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},l={};function a(e){return "string"==typeof e?o[e.toLowerCase()]:e}function c(e,r){return c=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},c(e,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return !1}}function f(e,r,t){return f=u()?Reflect.construct:function(e,r,t){var s=[null];s.push.apply(s,r);var i=new(Function.bind.apply(e,s));return t&&c(i,t.prototype),i},f.apply(null,arguments)}function h(e){if(null==e)return e;if(Array.isArray(e))return e.slice();if("object"==typeof e){var r={};return Object.keys(e).forEach(function(t){r[t]=e[t];}),r}return e}function v(e){return void 0===e?"undefined":null===e?"null":Array.isArray(e)?"[ "+e.map(function(e){return v(e)}).join(", ")+" ]":"object"==typeof e?JSON.stringify(e):"function"==typeof e?"[Function: "+e.name+"]":"boolean"==typeof e||"number"==typeof e?e:"'"+e.toString()+"'"}function p(e){if("string"!=typeof e){for(var r=new Array(arguments.length),t=0;t<arguments.length;t++)r[t]=v(arguments[t]);return r.join(" ")}for(var s=/%[sdj%]/g,i=1,n=arguments,o=n.length,l=String(e).replace(s,function(e){if("%%"===e)return "%";if(i>=o)return e;switch(e){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(e){return "[Circular]"}default:return e}}),a=n[i];i<o;a=n[++i])l+=null===a||"object"!=typeof a?" "+a:" "+v(a);return l}function m(e,r){var t=e.split("\n");t[0]&&t[0].indexOf("call-stack-error")>=0&&t.shift();var s=t[r],i=null;if(s){var n=/^\s*(at|.*@)\s*(.+)?$/.exec(s);i=Array.isArray(n)&&n[2]?n[2]:s;}return i}Object.keys(o).forEach(function(e){l[o[e]]=e;});var y={};function d(e,r){if(r){if(y[r])return;y[r]=!0;}console.error(e+"\n");}function g(e){return y[e]}function w(){var e=[];return function(r,t){return t&&"object"==typeof t?-1!==e.indexOf(t)?"[Circular]":(e.push(t),t):t}}var b=/*#__PURE__*/function(){function e(){}return e.prototype.write=function(e){e.level<30?console.log(e):e.level<40?console.info(e):e.level<50?console.warn(e):console.error(e),e.err&&e.err.stack&&console.error(e.err.stack),e.obj&&console.log(e.obj);},e}(),j=/*#__PURE__*/function(){function e(r,t,s){var i,n,o,l,a=this;if(!(this instanceof e))return new e(r,t);if(void 0!==t&&(i=r,r=t,!(i instanceof e)))throw new TypeError("invalid Logger creation: do not pass a second arg");if(!r)throw new TypeError("options (object) is required");if(i){if(r.name)throw new TypeError("invalid options.name: child cannot set logger name")}else if(!r.name)throw new TypeError("options.name (string) is required");if(r.stream&&r.streams)throw new TypeError('cannot mix "streams" and "stream" options');if(r.streams&&!Array.isArray(r.streams))throw new TypeError("invalid options.streams: must be an array");if(r.serializers&&("object"!=typeof r.serializers||Array.isArray(r.serializers)))throw new TypeError("invalid options.serializers: must be an object");if(i&&s){this._level=i._level,this.streams=i.streams,this.serializers=i.serializers,this.src=i.src,n=this.fields={};var c=Object.keys(i.fields);for(l=0;l<c.length;l++)n[o=c[l]]=i.fields[o];var u=Object.keys(r);for(l=0;l<u.length;l++)n[o=u[l]]=r[o];}else {if(i){for(this._level=i._level,this.streams=[],l=0;l<i.streams.length;l++){var f=h(i.streams[l]);this.streams.push(f);}this.serializers=h(i.serializers),this.src=i.src,this.fields=h(i.fields),r.level&&this.level(r.level);}else this._level=Number.POSITIVE_INFINITY,this.streams=[],this.serializers=null,this.src=!1,this.fields={};r.stream?this.addStream({type:"stream",stream:r.stream,level:r.level}):r.streams?r.streams.forEach(function(e){a.addStream(e,r.level);}):i&&r.level?this.level(r.level):i||this.addStream({type:"raw",stream:new b,level:r.level}),r.serializers&&this.addSerializers(r.serializers),r.src&&(this.src=!0),delete(n=h(r)).stream,delete n.level,delete n.streams,delete n.serializers,delete n.src,this.serializers&&this._applySerializers(n),Object.keys(n).forEach(function(e){a.fields[e]=n[e];});}}var r=e.prototype;return r.addStream=function(e,r){void 0===r&&(r=30),(e=h(e)).type="raw",e.level=a(e.level||r),e.level<this._level&&(this._level=e.level),this.streams.push(e),delete this.haveNonRawStreams;},r.addSerializers=function(e){var r=this;this.serializers||(this.serializers={}),Object.keys(e).forEach(function(t){var s=e[t];if("function"!=typeof s)throw new TypeError(p('invalid serializer for "%s" field: must be a function',t));r.serializers[t]=s;});},r.child=function(e,r){return new this.constructor(this,e||{},r)},r.level=function(e){if(void 0===e)return this._level;for(var r=a(e),t=this.streams.length,s=0;s<t;s++)this.streams[s].level=r;this._level=r;},r.levels=function(e,r){if(void 0===e)return this.streams.map(function(e){return e.level});var t;if("number"==typeof e){if(void 0===(t=this.streams[e]))throw new Error("invalid stream index: "+e)}else {for(var s=this.streams.length,i=0;i<s;i++){var n=this.streams[i];if(n.name===e){t=n;break}}if(!t)throw new Error(p('no stream with name "%s"',e))}if(void 0===r)return t.level;var o=a(r);t.level=o,o<this._level&&(this._level=o);},r._applySerializers=function(e,r){var t=this;Object.keys(this.serializers).forEach(function(s){if(!(void 0===e[s]||r&&r[s]))try{e[s]=t.serializers[s](e[s]);}catch(r){d(p('bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.\n%s',s,r.stack||r)),e[s]=p('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)',s);}});},r._emit=function(e,r){var t,s;if(void 0===this.haveNonRawStreams)for(this.haveNonRawStreams=!1,t=0;t<this.streams.length;t++)if(!this.streams[t].raw){this.haveNonRawStreams=!0;break}if(r||this.haveNonRawStreams)try{s=JSON.stringify(e,w())+"\n";}catch(r){var i=r.stack.split(/\n/g,2).join("\n");d('bunyan: ERROR: Exception in `JSON.stringify(rec)`. You can install the "safe-json-stringify" module to have Bunyan fallback to safer stringification. Record:\n'+function(e,r){return r||(r=" "),r+e.split(/\r?\n/g).join("\n"+r)}(p("%s\n%s",e,r.stack)),i),s=p("(Exception in JSON.stringify(rec): %j. See stderr for details.)\n",r.message);}if(r)return s;var n=e.level;for(t=0;t<this.streams.length;t++){var o=this.streams[t];o.level<=n&&o.stream.write(e);}return s},e}();function z(e){return function(){var r=this;function t(t){var n;t[0]instanceof Error?(s={err:r.serializers&&r.serializers.err?r.serializers.err(t[0]):k.err(t[0])},n={err:!0},i=1===t.length?[s.err.message]:Array.prototype.slice.call(t,1)):"object"!=typeof t[0]&&null!==t[0]||Array.isArray(t[0])?(s=null,i=Array.prototype.slice.call(t)):(s=t[0],i=1===t.length&&s.err&&s.err instanceof Error?[s.err.message]:Array.prototype.slice.call(t,1));var o=h(r.fields);o.level=e;var a=s?h(s):null;if(a&&(r.serializers&&r._applySerializers(a,n),Object.keys(a).forEach(function(e){o[e]=a[e];})),o.levelName=l[e],o.msg=i.length?p.apply(r,i):"",o.time||(o.time=new Date),r.src&&!o.src)try{throw new Error("call-stack-error")}catch(e){var c=e.stack?m(e.stack,2):"";c||g("src")||d("Unable to determine src line info","src"),o.src=c||"";}return o.v=1,o}var s=null,i=arguments,n=null;if(0===arguments.length)return this._level<=e;this._level>e||(n=t(i),this._emit(n));}}function S(e){var r=e.stack||e.toString();if(e.cause&&"function"==typeof e.cause){var t=e.cause();t&&(r+="\nCaused by: "+S(t));}return r}j.prototype.trace=z(10),j.prototype.debug=z(20),j.prototype.info=z(30),j.prototype.warn=z(40),j.prototype.error=z(50),j.prototype.fatal=z(60);var k={err:function(e){return e&&e.stack?{message:e.message,name:e.name,stack:S(e),code:e.code,signal:e.signal}:e}};function E(){return f(j,[].slice.call(arguments))}var A={levels:{trace:"color: DeepPink",debug:"color: GoldenRod",info:"color: DarkTurquoise",warn:"color: Purple",error:"color: Crimson",fatal:"color: Black"},def:"color: DimGray",msg:"color: SteelBlue",src:"color: DimGray; font-style: italic; font-size: 0.9em"},R=/*#__PURE__*/function(){function e(e){var r=void 0===e?{}:e,t=r.logByLevel,s=r.css,i=void 0===s?A:s;this.logByLevel=void 0!==t&&t,this.css=i;}return e.prototype.write=function(e){var r,t,s=this.css.def,i=this.css.msg,n=this.css.src,o=e.childName?e.name+"/"+e.childName:e.name,a=l[e.level],c=(Array(6-a.length).join(" ")+a).toUpperCase();this.logByLevel?(10===e.level?a="debug":60===e.level&&(a="error"),t="function"==typeof console[a]?console[a]:console.log):t=console.log,r=e.level<20?this.css.levels.trace:e.level<30?this.css.levels.debug:e.level<40?this.css.levels.info:e.level<50?this.css.levels.warn:e.level<60?this.css.levels.error:this.css.levels.fatal;var u=function(e,r){return Array(r+1-(e+"").length).join("0")+e},f=[];f.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s "+(e.src?"%c%s":"")),f.push(u(e.time.getHours(),2)),f.push(u(e.time.getMinutes(),2)),f.push(u(e.time.getSeconds(),2)),f.push(u(e.time.getMilliseconds(),4)),f.push(r),f.push(c),f.push(s),f.push(o),f.push(i),f.push(e.msg),e.src&&(f.push(n),f.push(e.src)),e.obj&&(f.push("\n"),f.push(e.obj)),e.err&&e.err.stack&&(f.push("\n"),f.push(e.err.stack)),t.apply(console,f);},e.getDefaultCss=function(){return A},e}();
|
|
1257
1288
|
|
|
1258
|
-
var humpsExports = {};
|
|
1259
|
-
var humps = {
|
|
1260
|
-
get exports(){ return humpsExports; },
|
|
1261
|
-
set exports(v){ humpsExports = v; },
|
|
1262
|
-
};
|
|
1263
|
-
|
|
1264
|
-
(function (module) {
|
|
1265
|
-
(function(global) {
|
|
1266
|
-
|
|
1267
|
-
var _processKeys = function(convert, obj, options) {
|
|
1268
|
-
if(!_isObject(obj) || _isDate(obj) || _isRegExp(obj) || _isBoolean(obj) || _isFunction(obj)) {
|
|
1269
|
-
return obj;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
var output,
|
|
1273
|
-
i = 0,
|
|
1274
|
-
l = 0;
|
|
1275
|
-
|
|
1276
|
-
if(_isArray(obj)) {
|
|
1277
|
-
output = [];
|
|
1278
|
-
for(l=obj.length; i<l; i++) {
|
|
1279
|
-
output.push(_processKeys(convert, obj[i], options));
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
else {
|
|
1283
|
-
output = {};
|
|
1284
|
-
for(var key in obj) {
|
|
1285
|
-
if(Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1286
|
-
output[convert(key, options)] = _processKeys(convert, obj[key], options);
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
return output;
|
|
1291
|
-
};
|
|
1292
|
-
|
|
1293
|
-
// String conversion methods
|
|
1294
|
-
|
|
1295
|
-
var separateWords = function(string, options) {
|
|
1296
|
-
options = options || {};
|
|
1297
|
-
var separator = options.separator || '_';
|
|
1298
|
-
var split = options.split || /(?=[A-Z])/;
|
|
1299
|
-
|
|
1300
|
-
return string.split(split).join(separator);
|
|
1301
|
-
};
|
|
1302
|
-
|
|
1303
|
-
var camelize = function(string) {
|
|
1304
|
-
if (_isNumerical(string)) {
|
|
1305
|
-
return string;
|
|
1306
|
-
}
|
|
1307
|
-
string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) {
|
|
1308
|
-
return chr ? chr.toUpperCase() : '';
|
|
1309
|
-
});
|
|
1310
|
-
// Ensure 1st char is always lowercase
|
|
1311
|
-
return string.substr(0, 1).toLowerCase() + string.substr(1);
|
|
1312
|
-
};
|
|
1313
|
-
|
|
1314
|
-
var pascalize = function(string) {
|
|
1315
|
-
var camelized = camelize(string);
|
|
1316
|
-
// Ensure 1st char is always uppercase
|
|
1317
|
-
return camelized.substr(0, 1).toUpperCase() + camelized.substr(1);
|
|
1318
|
-
};
|
|
1319
|
-
|
|
1320
|
-
var decamelize = function(string, options) {
|
|
1321
|
-
return separateWords(string, options).toLowerCase();
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
|
-
// Utilities
|
|
1325
|
-
// Taken from Underscore.js
|
|
1326
|
-
|
|
1327
|
-
var toString = Object.prototype.toString;
|
|
1328
|
-
|
|
1329
|
-
var _isFunction = function(obj) {
|
|
1330
|
-
return typeof(obj) === 'function';
|
|
1331
|
-
};
|
|
1332
|
-
var _isObject = function(obj) {
|
|
1333
|
-
return obj === Object(obj);
|
|
1334
|
-
};
|
|
1335
|
-
var _isArray = function(obj) {
|
|
1336
|
-
return toString.call(obj) == '[object Array]';
|
|
1337
|
-
};
|
|
1338
|
-
var _isDate = function(obj) {
|
|
1339
|
-
return toString.call(obj) == '[object Date]';
|
|
1340
|
-
};
|
|
1341
|
-
var _isRegExp = function(obj) {
|
|
1342
|
-
return toString.call(obj) == '[object RegExp]';
|
|
1343
|
-
};
|
|
1344
|
-
var _isBoolean = function(obj) {
|
|
1345
|
-
return toString.call(obj) == '[object Boolean]';
|
|
1346
|
-
};
|
|
1347
|
-
|
|
1348
|
-
// Performant way to determine if obj coerces to a number
|
|
1349
|
-
var _isNumerical = function(obj) {
|
|
1350
|
-
obj = obj - 0;
|
|
1351
|
-
return obj === obj;
|
|
1352
|
-
};
|
|
1353
|
-
|
|
1354
|
-
// Sets up function which handles processing keys
|
|
1355
|
-
// allowing the convert function to be modified by a callback
|
|
1356
|
-
var _processor = function(convert, options) {
|
|
1357
|
-
var callback = options && 'process' in options ? options.process : options;
|
|
1358
|
-
|
|
1359
|
-
if(typeof(callback) !== 'function') {
|
|
1360
|
-
return convert;
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
return function(string, options) {
|
|
1364
|
-
return callback(string, convert, options);
|
|
1365
|
-
}
|
|
1366
|
-
};
|
|
1367
|
-
|
|
1368
|
-
var humps = {
|
|
1369
|
-
camelize: camelize,
|
|
1370
|
-
decamelize: decamelize,
|
|
1371
|
-
pascalize: pascalize,
|
|
1372
|
-
depascalize: decamelize,
|
|
1373
|
-
camelizeKeys: function(object, options) {
|
|
1374
|
-
return _processKeys(_processor(camelize, options), object);
|
|
1375
|
-
},
|
|
1376
|
-
decamelizeKeys: function(object, options) {
|
|
1377
|
-
return _processKeys(_processor(decamelize, options), object, options);
|
|
1378
|
-
},
|
|
1379
|
-
pascalizeKeys: function(object, options) {
|
|
1380
|
-
return _processKeys(_processor(pascalize, options), object);
|
|
1381
|
-
},
|
|
1382
|
-
depascalizeKeys: function () {
|
|
1383
|
-
return this.decamelizeKeys.apply(this, arguments);
|
|
1384
|
-
}
|
|
1385
|
-
};
|
|
1386
|
-
|
|
1387
|
-
if (module.exports) {
|
|
1388
|
-
module.exports = humps;
|
|
1389
|
-
} else {
|
|
1390
|
-
global.humps = humps;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
})(commonjsGlobal);
|
|
1394
|
-
} (humps));
|
|
1395
|
-
|
|
1396
1289
|
class InvalidTokenError extends Error {
|
|
1397
1290
|
}
|
|
1398
1291
|
InvalidTokenError.prototype.name = "InvalidTokenError";
|
|
@@ -21607,11 +21500,11 @@ class ShipEngineAPI {
|
|
|
21607
21500
|
headers: __spreadProps(__spreadValues({}, headers), {
|
|
21608
21501
|
"Content-Type": "application/json"
|
|
21609
21502
|
}),
|
|
21610
|
-
paramsSerializer: (params) => lib.stringify(
|
|
21503
|
+
paramsSerializer: (params) => lib.stringify(decamelizeKeys(params), { arrayFormat: "brackets" }),
|
|
21611
21504
|
transformRequest: [
|
|
21612
21505
|
(data) => {
|
|
21613
21506
|
if (data && !(data instanceof FormData))
|
|
21614
|
-
return
|
|
21507
|
+
return decamelizeKeys(data);
|
|
21615
21508
|
else
|
|
21616
21509
|
return data;
|
|
21617
21510
|
},
|
|
@@ -21631,7 +21524,7 @@ class ShipEngineAPI {
|
|
|
21631
21524
|
},
|
|
21632
21525
|
(data) => {
|
|
21633
21526
|
if (data && !(data instanceof Blob))
|
|
21634
|
-
return
|
|
21527
|
+
return camelizeKeys(data);
|
|
21635
21528
|
else
|
|
21636
21529
|
return data;
|
|
21637
21530
|
}
|
|
@@ -21919,4 +21812,4 @@ class ShipEngineAPI {
|
|
|
21919
21812
|
}
|
|
21920
21813
|
}
|
|
21921
21814
|
|
|
21922
|
-
export { AccountSettingsAPI, AddressesAPI, CarriersAPI, CodedError, ConfirmationType, ConnectionsAPI, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, MetadataCapability, MetadataRequirement, MetadataSatisfyingFormTypes, MovementIndicator, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, SellersAPI, ServicePointsAPI, ShipEngineAPI, ShipmentsAPI, ShippingRulesAPI, ThemesAPI, WarehousesAPI, WebhooksAPI, getEndUserIpAddress, isCodedError, isCodedErrors, isDataCodedErrors, isInvalidTokenError, parseError };
|
|
21815
|
+
export { AccountSettingsAPI, AddressesAPI, CarriersAPI, CodedError, ConfirmationType, ConnectionsAPI, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, MetadataCapability, MetadataRequirement, MetadataSatisfyingFormTypes, MovementIndicator, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, SellersAPI, ServicePointsAPI, ShipEngineAPI, ShipmentsAPI, ShippingRulesAPI, ThemesAPI, WarehousesAPI, WebhooksAPI, camelizeKeys, decamelizeKeys, getEndUserIpAddress, isCodedError, isCodedErrors, isDataCodedErrors, isInvalidTokenError, parseError };
|
package/package.json
CHANGED
package/utilities/index.d.ts
CHANGED