@open-tender/store 0.7.10 → 0.7.12
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/.DS_Store +0 -0
- package/dist/cjs/services/api.js +10 -2
- package/dist/esm/services/api.js +10 -2
- package/package.json +1 -1
package/dist/.DS_Store
CHANGED
|
Binary file
|
package/dist/cjs/services/api.js
CHANGED
|
@@ -4,8 +4,11 @@ var tslib_1 = require("tslib");
|
|
|
4
4
|
var errors_1 = require("./errors");
|
|
5
5
|
var parseResponse = function (response, contentType) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
6
6
|
return tslib_1.__generator(this, function (_a) {
|
|
7
|
-
if (
|
|
8
|
-
return [2 /*return*/,
|
|
7
|
+
if (response.status === 204) {
|
|
8
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
9
|
+
resolve(null);
|
|
10
|
+
})];
|
|
11
|
+
}
|
|
9
12
|
switch (contentType) {
|
|
10
13
|
case 'text/csv':
|
|
11
14
|
case 'text/plain':
|
|
@@ -68,6 +71,7 @@ var PosAPI = /** @class */ (function () {
|
|
|
68
71
|
case 0:
|
|
69
72
|
_b.trys.push([0, 3, , 4]);
|
|
70
73
|
url = "".concat(this.apiUrl).concat(endpoint);
|
|
74
|
+
console.log('fetching', url);
|
|
71
75
|
return [4 /*yield*/, fetch(url, {
|
|
72
76
|
method: method,
|
|
73
77
|
headers: makeHeaders(this.terminalId),
|
|
@@ -75,6 +79,8 @@ var PosAPI = /** @class */ (function () {
|
|
|
75
79
|
})];
|
|
76
80
|
case 1:
|
|
77
81
|
res = _b.sent();
|
|
82
|
+
console.log('res', res);
|
|
83
|
+
console.log('res.ok', res.ok);
|
|
78
84
|
contentType = (_a = res.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.split(';')[0];
|
|
79
85
|
if (!contentType) {
|
|
80
86
|
return [2 /*return*/, reject(errors_1.errorsApi.internalServerError)];
|
|
@@ -82,6 +88,7 @@ var PosAPI = /** @class */ (function () {
|
|
|
82
88
|
return [4 /*yield*/, parseResponse(res, contentType)];
|
|
83
89
|
case 2:
|
|
84
90
|
parsed = _b.sent();
|
|
91
|
+
console.log('parsed', parsed);
|
|
85
92
|
if (!res.ok) {
|
|
86
93
|
error = handleError(res.status, parsed);
|
|
87
94
|
return [2 /*return*/, reject(error)];
|
|
@@ -89,6 +96,7 @@ var PosAPI = /** @class */ (function () {
|
|
|
89
96
|
return [2 /*return*/, resolve(parsed)];
|
|
90
97
|
case 3:
|
|
91
98
|
err_1 = _b.sent();
|
|
99
|
+
console.log(err_1);
|
|
92
100
|
return [2 /*return*/, reject(errors_1.errorsApi.internalServerError)];
|
|
93
101
|
case 4: return [2 /*return*/];
|
|
94
102
|
}
|
package/dist/esm/services/api.js
CHANGED
|
@@ -2,8 +2,11 @@ import { __awaiter, __generator } from "tslib";
|
|
|
2
2
|
import { errorsApi } from './errors';
|
|
3
3
|
var parseResponse = function (response, contentType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4
4
|
return __generator(this, function (_a) {
|
|
5
|
-
if (
|
|
6
|
-
return [2 /*return*/,
|
|
5
|
+
if (response.status === 204) {
|
|
6
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
7
|
+
resolve(null);
|
|
8
|
+
})];
|
|
9
|
+
}
|
|
7
10
|
switch (contentType) {
|
|
8
11
|
case 'text/csv':
|
|
9
12
|
case 'text/plain':
|
|
@@ -66,6 +69,7 @@ var PosAPI = /** @class */ (function () {
|
|
|
66
69
|
case 0:
|
|
67
70
|
_b.trys.push([0, 3, , 4]);
|
|
68
71
|
url = "".concat(this.apiUrl).concat(endpoint);
|
|
72
|
+
console.log('fetching', url);
|
|
69
73
|
return [4 /*yield*/, fetch(url, {
|
|
70
74
|
method: method,
|
|
71
75
|
headers: makeHeaders(this.terminalId),
|
|
@@ -73,6 +77,8 @@ var PosAPI = /** @class */ (function () {
|
|
|
73
77
|
})];
|
|
74
78
|
case 1:
|
|
75
79
|
res = _b.sent();
|
|
80
|
+
console.log('res', res);
|
|
81
|
+
console.log('res.ok', res.ok);
|
|
76
82
|
contentType = (_a = res.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.split(';')[0];
|
|
77
83
|
if (!contentType) {
|
|
78
84
|
return [2 /*return*/, reject(errorsApi.internalServerError)];
|
|
@@ -80,6 +86,7 @@ var PosAPI = /** @class */ (function () {
|
|
|
80
86
|
return [4 /*yield*/, parseResponse(res, contentType)];
|
|
81
87
|
case 2:
|
|
82
88
|
parsed = _b.sent();
|
|
89
|
+
console.log('parsed', parsed);
|
|
83
90
|
if (!res.ok) {
|
|
84
91
|
error = handleError(res.status, parsed);
|
|
85
92
|
return [2 /*return*/, reject(error)];
|
|
@@ -87,6 +94,7 @@ var PosAPI = /** @class */ (function () {
|
|
|
87
94
|
return [2 /*return*/, resolve(parsed)];
|
|
88
95
|
case 3:
|
|
89
96
|
err_1 = _b.sent();
|
|
97
|
+
console.log(err_1);
|
|
90
98
|
return [2 /*return*/, reject(errorsApi.internalServerError)];
|
|
91
99
|
case 4: return [2 /*return*/];
|
|
92
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/store",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|