gap-nodejs-sdk 1.0.173 → 1.0.174
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/dist/api/pos_client_api/1.0.0/types/response/customer.d.ts.map +1 -1
- package/dist/error.d.ts +5 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +12 -0
- package/dist/gap-sdk.js +1 -1
- package/dist/http_client/http_client.d.ts.map +1 -1
- package/dist/http_client/http_client.js +8 -37
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../src/http_client/http_client.ts"],"names":[],"mappings":"AACA,OAAc,EAAgB,kBAAkB,EAAgB,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAC,aAAa,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAG5D,OAAO,EACH,mBAAmB,EACnB,gBAAgB,EAEhB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAEhB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../src/http_client/http_client.ts"],"names":[],"mappings":"AACA,OAAc,EAAgB,kBAAkB,EAAgB,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAC,aAAa,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAG5D,OAAO,EACH,mBAAmB,EACnB,gBAAgB,EAEhB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAEhB,MAAM,SAAS,CAAC;AAGjB,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,WAAW,CAAgB;gBAEhB,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,KAAK,KAAA,EAAE,OAAO,GAAE,aAAgC;IAWzE,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIzD,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAI7D,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAgE9D,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI9B,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;CAsDhF"}
|
|
@@ -101,41 +101,6 @@ export class HttpClient {
|
|
|
101
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
102
|
try {
|
|
103
103
|
const response = yield this.axios(options);
|
|
104
|
-
// if ((response.data?.status !== 'OK' || response.data?.result?.status !== 'OK') || !response?.status.toString().startsWith('2')) {
|
|
105
|
-
// const errorMessage: string = JSON.stringify(response.data.message || response.data.result.message, null, 2);
|
|
106
|
-
// const headers = response.headers;
|
|
107
|
-
// const code = response.status;
|
|
108
|
-
// const statusText = response.statusText;
|
|
109
|
-
// switch (true) {
|
|
110
|
-
// case response.status === StatusCode.TooManyRequests: {
|
|
111
|
-
// const retryAfter = response.headers['Retry-After'];
|
|
112
|
-
// throw new GapErrors.HttpThrottlingError({
|
|
113
|
-
// message: `GAP is throttling requests ${errorMessage}`,
|
|
114
|
-
// code,
|
|
115
|
-
// statusText,
|
|
116
|
-
// body: response.data,
|
|
117
|
-
// headers,
|
|
118
|
-
// retryAfter: retryAfter ? parseFloat(retryAfter) : undefined,
|
|
119
|
-
// });
|
|
120
|
-
// }
|
|
121
|
-
// case response.status >= StatusCode.InternalServerError:
|
|
122
|
-
// throw new GapErrors.HttpInternalError({
|
|
123
|
-
// message: `GAP internal error ${errorMessage}`,
|
|
124
|
-
// code,
|
|
125
|
-
// statusText,
|
|
126
|
-
// body: response.data,
|
|
127
|
-
// headers,
|
|
128
|
-
// });
|
|
129
|
-
// default:
|
|
130
|
-
// throw new GapErrors.HttpResponseError({
|
|
131
|
-
// message: `Received an error response (${response.status}${response.statusText && '' + response.statusText}) from GAP ${errorMessage}`,
|
|
132
|
-
// code,
|
|
133
|
-
// statusText,
|
|
134
|
-
// body: response.data,
|
|
135
|
-
// headers,
|
|
136
|
-
// });
|
|
137
|
-
// }
|
|
138
|
-
// }
|
|
139
104
|
if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.status) === 'OK' || ((_c = (_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.status) === 'OK' || (response === null || response === void 0 ? void 0 : response.status.toString().startsWith('2'))) {
|
|
140
105
|
return response.data;
|
|
141
106
|
}
|
|
@@ -177,9 +142,15 @@ export class HttpClient {
|
|
|
177
142
|
if (error instanceof GapErrors.GapError) {
|
|
178
143
|
throw error;
|
|
179
144
|
}
|
|
180
|
-
|
|
181
|
-
throw new GapErrors.
|
|
145
|
+
if (error.response.status === 401) {
|
|
146
|
+
throw new GapErrors.HttpUnauthorizedError({
|
|
147
|
+
code: error.response.status,
|
|
148
|
+
statusText: error.response.statusText,
|
|
149
|
+
body: error.response.data,
|
|
150
|
+
headers: error.response.headers
|
|
151
|
+
});
|
|
182
152
|
}
|
|
153
|
+
throw new GapErrors.HttpRequestError(`Failed to make GAP HTTP request: ${error.message}`);
|
|
183
154
|
}
|
|
184
155
|
});
|
|
185
156
|
}
|