addio-ecomm-sdk 1.3.76 → 1.3.78
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/index.js +1066 -1647
- package/dist/index.js.map +1 -1
- package/dist/lib/constants/components/CreditCardInput.js +22 -36
- package/dist/lib/constants/components/CreditCardInput.js.map +1 -1
- package/dist/lib/constants/components/Snackbar.js +10 -20
- package/dist/lib/constants/components/Snackbar.js.map +1 -1
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.js +566 -906
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/CartContext/index.js +34 -114
- package/dist/lib/constants/contexts/CartContext/index.js.map +1 -1
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.js +103 -234
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/DataContext/index.js +22 -62
- package/dist/lib/constants/contexts/DataContext/index.js.map +1 -1
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.js +24 -87
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/LogContext/index.js +4 -42
- package/dist/lib/constants/contexts/LogContext/index.js.map +1 -1
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.js +16 -31
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/ModalContext/index.js +11 -13
- package/dist/lib/constants/contexts/ModalContext/index.js.map +1 -1
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.js +14 -70
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.js.map +1 -1
- package/dist/lib/constants/contexts/SDKContext/index.js +1 -1
- package/dist/lib/constants/contexts/SDKContext/index.js.map +1 -1
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.js +3 -3
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.js.map +1 -1
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.js +17 -31
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.d.ts +2 -0
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.js +2 -2
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.js.map +1 -1
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.js +51 -118
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/StockNotifContext/index.js +3 -3
- package/dist/lib/constants/contexts/StockNotifContext/index.js.map +1 -1
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.js +240 -397
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/UserContext/index.js +15 -69
- package/dist/lib/constants/contexts/UserContext/index.js.map +1 -1
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.js +157 -253
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.js.map +1 -1
- package/dist/lib/constants/contexts/WishlistContext/index.js +4 -4
- package/dist/lib/constants/contexts/WishlistContext/index.js.map +1 -1
- package/dist/lib/constants/hooks/useCart.js +3 -3
- package/dist/lib/constants/hooks/useCart.js.map +1 -1
- package/dist/lib/constants/hooks/useData.js +3 -3
- package/dist/lib/constants/hooks/useData.js.map +1 -1
- package/dist/lib/constants/hooks/useLogs.js +3 -3
- package/dist/lib/constants/hooks/useLogs.js.map +1 -1
- package/dist/lib/constants/hooks/useModal.js +3 -3
- package/dist/lib/constants/hooks/useModal.js.map +1 -1
- package/dist/lib/constants/hooks/useSDK.js +3 -3
- package/dist/lib/constants/hooks/useSDK.js.map +1 -1
- package/dist/lib/constants/hooks/useSnackbar.js +3 -3
- package/dist/lib/constants/hooks/useSnackbar.js.map +1 -1
- package/dist/lib/constants/hooks/useStockNotif.js +3 -3
- package/dist/lib/constants/hooks/useStockNotif.js.map +1 -1
- package/dist/lib/constants/hooks/useUser.js +3 -3
- package/dist/lib/constants/hooks/useUser.js.map +1 -1
- package/dist/lib/constants/hooks/useWishlist.js +3 -3
- package/dist/lib/constants/hooks/useWishlist.js.map +1 -1
- package/dist/lib/models/image/index.js +5 -10
- package/dist/lib/models/image/index.js.map +1 -1
- package/dist/lib/models/stockNotification/index.js +58 -118
- package/dist/lib/models/stockNotification/index.js.map +1 -1
- package/dist/lib/models/wishlist/index.js +73 -142
- package/dist/lib/models/wishlist/index.js.map +1 -1
- package/dist/utils/algolia.js +27 -73
- package/dist/utils/algolia.js.map +1 -1
- package/dist/utils/analytics.js +68 -79
- package/dist/utils/analytics.js.map +1 -1
- package/dist/utils/cart.js +10 -11
- package/dist/utils/cart.js.map +1 -1
- package/dist/utils/contentful.js +31 -104
- package/dist/utils/contentful.js.map +1 -1
- package/dist/utils/functions.js +54 -71
- package/dist/utils/functions.js.map +1 -1
- package/dist/utils/getSDK.js +12 -70
- package/dist/utils/getSDK.js.map +1 -1
- package/dist/utils/initStoreData.js +12 -57
- package/dist/utils/initStoreData.js.map +1 -1
- package/dist/utils/larivieremeunier.js +1 -1
- package/dist/utils/larivieremeunier.js.map +1 -1
- package/dist/utils/technosupply.js +1 -1
- package/dist/utils/technosupply.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,51 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
3
|
var t = {};
|
|
51
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -61,477 +14,343 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
61
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
15
|
};
|
|
63
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
org: _this._org
|
|
100
|
-
}); };
|
|
101
|
-
this.getSDKOrgInitials = function () {
|
|
102
|
-
var orgID = _this.getAPIInfos().org;
|
|
17
|
+
const isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
|
|
18
|
+
const image_1 = __importDefault(require("./lib/models/image"));
|
|
19
|
+
const wishlist_1 = __importDefault(require("./lib/models/wishlist"));
|
|
20
|
+
const stockNotification_1 = __importDefault(require("./lib/models/stockNotification"));
|
|
21
|
+
const Product_1 = __importDefault(require("addio-admin-sdk/dist/lib/Product"));
|
|
22
|
+
const js_cookie_1 = __importDefault(require("js-cookie"));
|
|
23
|
+
const g2_1 = require("addio-admin-sdk/dist/rules/GR/utils/g2");
|
|
24
|
+
const anonymisation_1 = require("addio-admin-sdk/dist/utils/anonymisation");
|
|
25
|
+
const functions_1 = require("./utils/functions");
|
|
26
|
+
const zones_1 = require("addio-admin-sdk/dist/utils/zones");
|
|
27
|
+
const lodash_1 = require("lodash");
|
|
28
|
+
const functions_2 = require("./utils/functions");
|
|
29
|
+
const data_1 = require("addio-admin-sdk/dist/utils/data");
|
|
30
|
+
const moment_1 = __importDefault(require("moment"));
|
|
31
|
+
const object_1 = require("addio-admin-sdk/dist/utils/object");
|
|
32
|
+
const services_1 = require("addio-admin-sdk/dist/utils/services");
|
|
33
|
+
const logs_1 = require("addio-admin-sdk/dist/services/logs");
|
|
34
|
+
class SDK {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.init = async (sdk_config) => {
|
|
37
|
+
this._api = sdk_config.api;
|
|
38
|
+
this._token = sdk_config.token;
|
|
39
|
+
this._url = sdk_config.url;
|
|
40
|
+
this._org = sdk_config.org;
|
|
41
|
+
this._userToken = !!sdk_config.userToken ? sdk_config.userToken : '';
|
|
42
|
+
this._storeData = null;
|
|
43
|
+
};
|
|
44
|
+
this.getAPIInfos = () => ({
|
|
45
|
+
api: this._api,
|
|
46
|
+
token: this._token,
|
|
47
|
+
userToken: this._userToken,
|
|
48
|
+
org: this._org
|
|
49
|
+
});
|
|
50
|
+
this.getSDKOrgInitials = () => {
|
|
51
|
+
const orgID = this.getAPIInfos().org;
|
|
103
52
|
if (!!!orgID)
|
|
104
53
|
return '';
|
|
105
54
|
if (orgID.length <= 3)
|
|
106
55
|
return orgID.toUpperCase();
|
|
107
56
|
return (0, services_1.getOrgInitialsByID)(orgID);
|
|
108
57
|
};
|
|
109
|
-
this.initWishlist =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
128
|
-
}); };
|
|
129
|
-
this.initStoreData = function (defaultData) { return __awaiter(_this, void 0, void 0, function () {
|
|
130
|
-
var fetchData, responseData;
|
|
131
|
-
return __generator(this, function (_a) {
|
|
132
|
-
switch (_a.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
if (!!defaultData) {
|
|
135
|
-
this._storeData = defaultData;
|
|
136
|
-
return [2];
|
|
137
|
-
}
|
|
138
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/store"), {
|
|
139
|
-
method: 'GET',
|
|
140
|
-
headers: {
|
|
141
|
-
authorization: "Bearer ".concat(this._token),
|
|
142
|
-
'Content-Type': 'application/json'
|
|
143
|
-
}
|
|
144
|
-
})];
|
|
145
|
-
case 1:
|
|
146
|
-
fetchData = _a.sent();
|
|
147
|
-
return [4, fetchData.json()];
|
|
148
|
-
case 2:
|
|
149
|
-
responseData = _a.sent();
|
|
150
|
-
if (responseData.status !== 200) {
|
|
151
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
152
|
-
}
|
|
153
|
-
this._storeData = responseData.data;
|
|
154
|
-
return [2, this._storeData];
|
|
58
|
+
this.initWishlist = async (wishlist) => {
|
|
59
|
+
this._wishlist = new wishlist_1.default(wishlist, this._api, this._token, this._userToken, this.setUserToken);
|
|
60
|
+
return await this._wishlist.getFromDatabase(wishlist);
|
|
61
|
+
};
|
|
62
|
+
this.initStockNotif = async (stockNotif) => {
|
|
63
|
+
this._stockNotif = new stockNotification_1.default(stockNotif, this._api, this._token, this._userToken, this.setUserToken);
|
|
64
|
+
return await this._stockNotif.getFromDatabase(stockNotif);
|
|
65
|
+
};
|
|
66
|
+
this.initStoreData = async (defaultData) => {
|
|
67
|
+
if (!!defaultData) {
|
|
68
|
+
this._storeData = defaultData;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/store`, {
|
|
72
|
+
method: 'GET',
|
|
73
|
+
headers: {
|
|
74
|
+
authorization: `Bearer ${this._token}`,
|
|
75
|
+
'Content-Type': 'application/json'
|
|
155
76
|
}
|
|
156
77
|
});
|
|
157
|
-
|
|
158
|
-
|
|
78
|
+
const responseData = await fetchData.json();
|
|
79
|
+
if (responseData.status !== 200) {
|
|
80
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
81
|
+
}
|
|
82
|
+
this._storeData = responseData.data;
|
|
83
|
+
return this._storeData;
|
|
84
|
+
};
|
|
85
|
+
this.shouldShowFixedPromoBanner = (fixedPromoBannerData) => {
|
|
159
86
|
if (!!!fixedPromoBannerData.is_active) {
|
|
160
87
|
return false;
|
|
161
88
|
}
|
|
162
89
|
if (!!fixedPromoBannerData.active_between_dates && !!fixedPromoBannerData.active_between_dates.length) {
|
|
163
|
-
|
|
90
|
+
const date = fixedPromoBannerData.active_between_dates.some((date) => {
|
|
164
91
|
return (0, moment_1.default)().isBetween((0, moment_1.default)((0, data_1.formatDate)(date.start)), (0, moment_1.default)((0, data_1.formatDate)(date.end)), 'days', '[]');
|
|
165
92
|
});
|
|
166
93
|
return !!date;
|
|
167
94
|
}
|
|
168
95
|
return true;
|
|
169
96
|
};
|
|
170
|
-
this.getInventoryItem =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
headers: {
|
|
177
|
-
Authorization: "Bearer ".concat(this._token),
|
|
178
|
-
'x-gng-ecomm-locale': locale
|
|
179
|
-
}
|
|
180
|
-
})];
|
|
181
|
-
case 1:
|
|
182
|
-
fetchData = _a.sent();
|
|
183
|
-
return [4, fetchData.json()];
|
|
184
|
-
case 2:
|
|
185
|
-
responseData = _a.sent();
|
|
186
|
-
if (responseData.status !== 200)
|
|
187
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
188
|
-
return [2, responseData.data];
|
|
97
|
+
this.getInventoryItem = async (sku, locale) => {
|
|
98
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/inventory/${encodeURIComponent(sku)}`, {
|
|
99
|
+
method: 'GET',
|
|
100
|
+
headers: {
|
|
101
|
+
Authorization: `Bearer ${this._token}`,
|
|
102
|
+
'x-gng-ecomm-locale': locale
|
|
189
103
|
}
|
|
190
104
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
})];
|
|
203
|
-
case 1:
|
|
204
|
-
fetchData = _a.sent();
|
|
205
|
-
return [4, fetchData.json()];
|
|
206
|
-
case 2:
|
|
207
|
-
responseData = _a.sent();
|
|
208
|
-
if (responseData.status !== 200)
|
|
209
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
210
|
-
return [2, responseData.data];
|
|
105
|
+
const responseData = await fetchData.json();
|
|
106
|
+
if (responseData.status !== 200)
|
|
107
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
108
|
+
return responseData.data;
|
|
109
|
+
};
|
|
110
|
+
this.getFullInventory = async (locale) => {
|
|
111
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/inventory`, {
|
|
112
|
+
method: 'GET',
|
|
113
|
+
headers: {
|
|
114
|
+
Authorization: `Bearer ${this._token}`,
|
|
115
|
+
'x-gng-ecomm-locale': locale
|
|
211
116
|
}
|
|
212
117
|
});
|
|
213
|
-
|
|
118
|
+
const responseData = await fetchData.json();
|
|
119
|
+
if (responseData.status !== 200)
|
|
120
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
121
|
+
return responseData.data;
|
|
122
|
+
};
|
|
214
123
|
this.inventory = {
|
|
215
124
|
getFullInventory: this.getFullInventory,
|
|
216
125
|
getInventoryItem: this.getInventoryItem
|
|
217
126
|
};
|
|
218
|
-
this.setUserToken =
|
|
219
|
-
|
|
127
|
+
this.setUserToken = (token) => {
|
|
128
|
+
this._userToken = token;
|
|
220
129
|
localStorage.setItem('userToken', token);
|
|
221
130
|
js_cookie_1.default.set('userToken', token, { sameSite: 'strict', secure: true });
|
|
222
131
|
};
|
|
223
|
-
this.loginUserWithFacebook =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
132
|
+
this.loginUserWithFacebook = async (fb) => {
|
|
133
|
+
const { email, id, name } = fb;
|
|
134
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/signinwithfacebook`, {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
headers: {
|
|
137
|
+
authorization: `Bearer ${this._token}`,
|
|
138
|
+
'Content-Type': 'application/json'
|
|
139
|
+
},
|
|
140
|
+
body: JSON.stringify({ email, userID: id, name })
|
|
141
|
+
});
|
|
142
|
+
const responseData = await fetchData.json();
|
|
143
|
+
if (responseData.status !== 200) {
|
|
144
|
+
throw { status: responseData.status, error: responseData.error };
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
if (!!!responseData.data.userData) {
|
|
148
|
+
throw {
|
|
149
|
+
status: responseData.status,
|
|
150
|
+
error: 'user_not_found'
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (!!responseData.data.cartData) {
|
|
154
|
+
localStorage.setItem(`${this._org}__cart`, responseData.data.cartData.id);
|
|
155
|
+
}
|
|
156
|
+
if (responseData.token)
|
|
157
|
+
this.setUserToken(responseData.token);
|
|
158
|
+
return { userData: responseData.data.userData, cart: responseData.data.cartData };
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
return err.toString();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
this.anonymousResetPassword = async (locale, id, oldPassword, newPassword, confirmPassword) => {
|
|
165
|
+
try {
|
|
166
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/anonymousResetPassword`, {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
headers: {
|
|
169
|
+
authorization: `Bearer ${this._token}`,
|
|
170
|
+
'Content-Type': 'application/json',
|
|
171
|
+
'x-gng-ecomm-locale': locale
|
|
172
|
+
},
|
|
173
|
+
body: JSON.stringify({
|
|
174
|
+
id,
|
|
175
|
+
oldPassword,
|
|
176
|
+
newPassword,
|
|
177
|
+
confirmPassword
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
const responseData = await fetchData.json();
|
|
181
|
+
if (responseData.status !== 200) {
|
|
182
|
+
return { status: responseData.status, error: responseData.error };
|
|
263
183
|
}
|
|
184
|
+
return { status: responseData.status, data: { done: true } };
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
console.log('error dans le catch du sdk: ', typeof error, error);
|
|
188
|
+
return {
|
|
189
|
+
status: 400,
|
|
190
|
+
error: typeof error === 'string' ? error : error.toString()
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
this.loginUser = async (locale, email, password, keepCart = false, isClerk = false) => {
|
|
195
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/signin`, {
|
|
196
|
+
method: 'POST',
|
|
197
|
+
headers: {
|
|
198
|
+
authorization: `Bearer ${this._token}`,
|
|
199
|
+
'Content-Type': 'application/json',
|
|
200
|
+
'x-gng-ecomm-locale': locale
|
|
201
|
+
},
|
|
202
|
+
body: JSON.stringify({ email, password, isClerk })
|
|
264
203
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
authorization: "Bearer ".concat(this._token),
|
|
276
|
-
'Content-Type': 'application/json',
|
|
277
|
-
'x-gng-ecomm-locale': locale
|
|
278
|
-
},
|
|
279
|
-
body: JSON.stringify({
|
|
280
|
-
id: id,
|
|
281
|
-
oldPassword: oldPassword,
|
|
282
|
-
newPassword: newPassword,
|
|
283
|
-
confirmPassword: confirmPassword
|
|
284
|
-
})
|
|
285
|
-
})];
|
|
286
|
-
case 1:
|
|
287
|
-
fetchData = _a.sent();
|
|
288
|
-
return [4, fetchData.json()];
|
|
289
|
-
case 2:
|
|
290
|
-
responseData = _a.sent();
|
|
291
|
-
if (responseData.status !== 200) {
|
|
292
|
-
return [2, { status: responseData.status, error: responseData.error }];
|
|
293
|
-
}
|
|
294
|
-
return [2, { status: responseData.status, data: { done: true } }];
|
|
295
|
-
case 3:
|
|
296
|
-
error_1 = _a.sent();
|
|
297
|
-
console.log('error dans le catch du sdk: ', typeof error_1, error_1);
|
|
298
|
-
return [2, {
|
|
299
|
-
status: 400,
|
|
300
|
-
error: typeof error_1 === 'string' ? error_1 : error_1.toString()
|
|
301
|
-
}];
|
|
302
|
-
case 4: return [2];
|
|
204
|
+
const responseData = await fetchData.json();
|
|
205
|
+
if (responseData.status !== 200) {
|
|
206
|
+
throw { status: responseData.status, error: responseData.error };
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
if (!!!responseData.data.userData) {
|
|
210
|
+
throw {
|
|
211
|
+
status: responseData.status,
|
|
212
|
+
error: 'user_not_found'
|
|
213
|
+
};
|
|
303
214
|
}
|
|
215
|
+
const cartData = responseData.data.cartData;
|
|
216
|
+
const shouldResetCartData = !!cartData && !!cartData.clerk_id && !!!isClerk;
|
|
217
|
+
const currentCartInLocalStorage = !!shouldResetCartData || !!!keepCart ? false : localStorage.getItem(`${this._org}__cart`);
|
|
218
|
+
if (!!cartData && !!!currentCartInLocalStorage) {
|
|
219
|
+
localStorage.setItem(`${this._org}__cart`, responseData.data.cartData.id);
|
|
220
|
+
}
|
|
221
|
+
if (responseData.token)
|
|
222
|
+
this.setUserToken(responseData.token);
|
|
223
|
+
return {
|
|
224
|
+
userData: responseData.data.userData,
|
|
225
|
+
cart: shouldResetCartData ? null : cartData
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
return err.toString();
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
this.loginUserWithID = async (locale, id, password, keepCart = false, isClerk = false) => {
|
|
233
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/signinwithid`, {
|
|
234
|
+
method: 'POST',
|
|
235
|
+
headers: {
|
|
236
|
+
authorization: `Bearer ${this._token}`,
|
|
237
|
+
'Content-Type': 'application/json',
|
|
238
|
+
'x-gng-ecomm-locale': locale
|
|
239
|
+
},
|
|
240
|
+
body: JSON.stringify({ id, password, isClerk })
|
|
304
241
|
});
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
try {
|
|
331
|
-
if (!!!responseData.data.userData) {
|
|
332
|
-
throw {
|
|
333
|
-
status: responseData.status,
|
|
334
|
-
error: 'user_not_found'
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
cartData = responseData.data.cartData;
|
|
338
|
-
shouldResetCartData = !!cartData && !!cartData.clerk_id && !!!isClerk;
|
|
339
|
-
currentCartInLocalStorage = !!shouldResetCartData || !!!keepCart ? false : localStorage.getItem("".concat(this._org, "__cart"));
|
|
340
|
-
if (!!cartData && !!!currentCartInLocalStorage) {
|
|
341
|
-
localStorage.setItem("".concat(this._org, "__cart"), responseData.data.cartData.id);
|
|
342
|
-
}
|
|
343
|
-
if (responseData.token)
|
|
344
|
-
this.setUserToken(responseData.token);
|
|
345
|
-
return [2, {
|
|
346
|
-
userData: responseData.data.userData,
|
|
347
|
-
cart: shouldResetCartData ? null : cartData
|
|
348
|
-
}];
|
|
349
|
-
}
|
|
350
|
-
catch (err) {
|
|
351
|
-
return [2, err.toString()];
|
|
352
|
-
}
|
|
353
|
-
return [2];
|
|
242
|
+
const responseData = await fetchData.json();
|
|
243
|
+
if (responseData.status !== 200) {
|
|
244
|
+
throw { status: responseData.status, error: responseData.error };
|
|
245
|
+
}
|
|
246
|
+
if (!!!responseData.data.userData) {
|
|
247
|
+
throw {
|
|
248
|
+
status: responseData.status,
|
|
249
|
+
error: 'user_not_found'
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const currentCartInLocalStorage = !!!keepCart ? false : localStorage.getItem(`${this._org}__cart`);
|
|
253
|
+
if (!!responseData.data.cartData && !!!currentCartInLocalStorage) {
|
|
254
|
+
localStorage.setItem(`${this._org}__cart`, responseData.data.cartData.id);
|
|
255
|
+
}
|
|
256
|
+
if (responseData.token)
|
|
257
|
+
this.setUserToken(responseData.token);
|
|
258
|
+
return { userData: responseData.data.userData, cart: responseData.data.cartData };
|
|
259
|
+
};
|
|
260
|
+
this.checkG2ForCustomer = async (id, currentCustomer, customerGroups) => {
|
|
261
|
+
try {
|
|
262
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/services/g2/customers/${id}`, {
|
|
263
|
+
method: 'GET',
|
|
264
|
+
headers: {
|
|
265
|
+
authorization: `Bearer ${this._token}`,
|
|
266
|
+
'Content-Type': 'application/json'
|
|
354
267
|
}
|
|
355
268
|
});
|
|
356
|
-
|
|
269
|
+
const G2RequestRes = await fetchData.json();
|
|
270
|
+
if (!!fetchData.status && fetchData.status !== 200)
|
|
271
|
+
throw `${fetchData.status}`;
|
|
272
|
+
if (!!!G2RequestRes || !!!G2RequestRes.length)
|
|
273
|
+
throw 'no data';
|
|
274
|
+
const allG2Customers = G2RequestRes;
|
|
275
|
+
const customerToCheck = allG2Customers[0];
|
|
276
|
+
if (!!(0, object_1.recursiveCheckObject)(customerToCheck, 'client.noClient') &&
|
|
277
|
+
customerToCheck.client.noClient.toUpperCase() !== id.toUpperCase())
|
|
278
|
+
throw 'no data';
|
|
279
|
+
const customerToCreate = (0, g2_1.transformG2CustomerToCustomer)(customerToCheck, currentCustomer, customerGroups);
|
|
280
|
+
const anonymizedCustomer = (0, anonymisation_1.hideG2CustomerInfoIfNeeded)(customerToCreate);
|
|
281
|
+
return (anonymizedCustomer !== null && anonymizedCustomer !== void 0 ? anonymizedCustomer : customerToCreate);
|
|
282
|
+
}
|
|
283
|
+
catch (e) {
|
|
284
|
+
console.log('error on fetching G2 customer: ', e.toString());
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
357
287
|
};
|
|
358
|
-
this.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
headers: {
|
|
368
|
-
authorization: "Bearer ".concat(this._token),
|
|
369
|
-
'Content-Type': 'application/json',
|
|
370
|
-
'x-gng-ecomm-locale': locale
|
|
371
|
-
},
|
|
372
|
-
body: JSON.stringify({ id: id, password: password, isClerk: isClerk })
|
|
373
|
-
})];
|
|
374
|
-
case 1:
|
|
375
|
-
fetchData = _a.sent();
|
|
376
|
-
return [4, fetchData.json()];
|
|
377
|
-
case 2:
|
|
378
|
-
responseData = _a.sent();
|
|
379
|
-
if (responseData.status !== 200) {
|
|
380
|
-
throw { status: responseData.status, error: responseData.error };
|
|
381
|
-
}
|
|
382
|
-
if (!!!responseData.data.userData) {
|
|
383
|
-
throw {
|
|
384
|
-
status: responseData.status,
|
|
385
|
-
error: 'user_not_found'
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
currentCartInLocalStorage = !!!keepCart ? false : localStorage.getItem("".concat(this._org, "__cart"));
|
|
389
|
-
if (!!responseData.data.cartData && !!!currentCartInLocalStorage) {
|
|
390
|
-
localStorage.setItem("".concat(this._org, "__cart"), responseData.data.cartData.id);
|
|
391
|
-
}
|
|
392
|
-
if (responseData.token)
|
|
393
|
-
this.setUserToken(responseData.token);
|
|
394
|
-
return [2, { userData: responseData.data.userData, cart: responseData.data.cartData }];
|
|
395
|
-
}
|
|
288
|
+
this.createProCustomer = async (customer) => {
|
|
289
|
+
try {
|
|
290
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/createProWithId`, {
|
|
291
|
+
method: 'POST',
|
|
292
|
+
headers: {
|
|
293
|
+
authorization: `Bearer ${this._token}`,
|
|
294
|
+
'Content-Type': 'application/json'
|
|
295
|
+
},
|
|
296
|
+
body: JSON.stringify({ customer })
|
|
396
297
|
});
|
|
397
|
-
|
|
298
|
+
const result = await fetchData.json();
|
|
299
|
+
if (!!fetchData.status && fetchData.status !== 200)
|
|
300
|
+
throw `${result.data}`;
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
catch (e) {
|
|
304
|
+
console.log('error on creating G2 customer: ', e.toString());
|
|
305
|
+
return e.toString();
|
|
306
|
+
}
|
|
398
307
|
};
|
|
399
|
-
this.
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
headers: {
|
|
408
|
-
authorization: "Bearer ".concat(this._token),
|
|
409
|
-
'Content-Type': 'application/json'
|
|
410
|
-
}
|
|
411
|
-
})];
|
|
412
|
-
case 1:
|
|
413
|
-
fetchData = _a.sent();
|
|
414
|
-
return [4, fetchData.json()];
|
|
415
|
-
case 2:
|
|
416
|
-
G2RequestRes = _a.sent();
|
|
417
|
-
if (!!fetchData.status && fetchData.status !== 200)
|
|
418
|
-
throw "".concat(fetchData.status);
|
|
419
|
-
if (!!!G2RequestRes || !!!G2RequestRes.length)
|
|
420
|
-
throw 'no data';
|
|
421
|
-
allG2Customers = G2RequestRes;
|
|
422
|
-
customerToCheck = allG2Customers[0];
|
|
423
|
-
if (!!(0, object_1.recursiveCheckObject)(customerToCheck, 'client.noClient') &&
|
|
424
|
-
customerToCheck.client.noClient.toUpperCase() !== id.toUpperCase())
|
|
425
|
-
throw 'no data';
|
|
426
|
-
customerToCreate = (0, g2_1.transformG2CustomerToCustomer)(customerToCheck, currentCustomer, customerGroups);
|
|
427
|
-
anonymizedCustomer = (0, anonymisation_1.hideG2CustomerInfoIfNeeded)(customerToCreate);
|
|
428
|
-
return [2, (anonymizedCustomer !== null && anonymizedCustomer !== void 0 ? anonymizedCustomer : customerToCreate)];
|
|
429
|
-
case 3:
|
|
430
|
-
e_1 = _a.sent();
|
|
431
|
-
console.log('error on fetching G2 customer: ', e_1.toString());
|
|
432
|
-
return [2];
|
|
433
|
-
case 4: return [2];
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
}); };
|
|
437
|
-
this.createProCustomer = function (customer) { return __awaiter(_this, void 0, void 0, function () {
|
|
438
|
-
var fetchData, result, e_2;
|
|
439
|
-
return __generator(this, function (_a) {
|
|
440
|
-
switch (_a.label) {
|
|
441
|
-
case 0:
|
|
442
|
-
_a.trys.push([0, 3, , 4]);
|
|
443
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/createProWithId"), {
|
|
444
|
-
method: 'POST',
|
|
445
|
-
headers: {
|
|
446
|
-
authorization: "Bearer ".concat(this._token),
|
|
447
|
-
'Content-Type': 'application/json'
|
|
448
|
-
},
|
|
449
|
-
body: JSON.stringify({ customer: customer })
|
|
450
|
-
})];
|
|
451
|
-
case 1:
|
|
452
|
-
fetchData = _a.sent();
|
|
453
|
-
return [4, fetchData.json()];
|
|
454
|
-
case 2:
|
|
455
|
-
result = _a.sent();
|
|
456
|
-
if (!!fetchData.status && fetchData.status !== 200)
|
|
457
|
-
throw "".concat(result.data);
|
|
458
|
-
return [2, true];
|
|
459
|
-
case 3:
|
|
460
|
-
e_2 = _a.sent();
|
|
461
|
-
console.log('error on creating G2 customer: ', e_2.toString());
|
|
462
|
-
return [2, e_2.toString()];
|
|
463
|
-
case 4: return [2];
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}); };
|
|
467
|
-
this.fetchCustomPriceList = function (customerID, isPA) {
|
|
468
|
-
if (isPA === void 0) { isPA = false; }
|
|
469
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
470
|
-
var id, g2PriceListQuery, prices, e_3;
|
|
471
|
-
return __generator(this, function (_a) {
|
|
472
|
-
switch (_a.label) {
|
|
473
|
-
case 0:
|
|
474
|
-
_a.trys.push([0, 3, , 4]);
|
|
475
|
-
id = !!isPA ? "".concat(customerID, "PA") : customerID;
|
|
476
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/services/g2/customers/").concat(id, "/customPrices"), {
|
|
477
|
-
method: 'POST',
|
|
478
|
-
headers: {
|
|
479
|
-
authorization: "Bearer ".concat(this._token),
|
|
480
|
-
'Content-Type': 'application/json'
|
|
481
|
-
}
|
|
482
|
-
})];
|
|
483
|
-
case 1:
|
|
484
|
-
g2PriceListQuery = _a.sent();
|
|
485
|
-
return [4, g2PriceListQuery.json()];
|
|
486
|
-
case 2:
|
|
487
|
-
prices = _a.sent();
|
|
488
|
-
if (!!g2PriceListQuery.status && g2PriceListQuery.status !== 200)
|
|
489
|
-
throw "Error - ".concat(g2PriceListQuery.status);
|
|
490
|
-
if (!!!prices || !!!prices.length)
|
|
491
|
-
throw 'Error - no data';
|
|
492
|
-
return [2, prices];
|
|
493
|
-
case 3:
|
|
494
|
-
e_3 = _a.sent();
|
|
495
|
-
console.log('error on fetching customer from G2: ', e_3);
|
|
496
|
-
return [2];
|
|
497
|
-
case 4: return [2];
|
|
308
|
+
this.fetchCustomPriceList = async (customerID, isPA = false) => {
|
|
309
|
+
try {
|
|
310
|
+
const id = !!isPA ? `${customerID}PA` : customerID;
|
|
311
|
+
const g2PriceListQuery = await (0, isomorphic_unfetch_1.default)(`${this._api}/services/g2/customers/${id}/customPrices`, {
|
|
312
|
+
method: 'POST',
|
|
313
|
+
headers: {
|
|
314
|
+
authorization: `Bearer ${this._token}`,
|
|
315
|
+
'Content-Type': 'application/json'
|
|
498
316
|
}
|
|
499
317
|
});
|
|
500
|
-
|
|
318
|
+
const prices = await g2PriceListQuery.json();
|
|
319
|
+
if (!!g2PriceListQuery.status && g2PriceListQuery.status !== 200)
|
|
320
|
+
throw `Error - ${g2PriceListQuery.status}`;
|
|
321
|
+
if (!!!prices || !!!prices.length)
|
|
322
|
+
throw 'Error - no data';
|
|
323
|
+
return prices;
|
|
324
|
+
}
|
|
325
|
+
catch (e) {
|
|
326
|
+
console.log('error on fetching customer from G2: ', e);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
501
329
|
};
|
|
502
|
-
this.validateAccount =
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
'x-gng-ecomm-token': this._userToken
|
|
512
|
-
},
|
|
513
|
-
body: JSON.stringify({ code: code })
|
|
514
|
-
})];
|
|
515
|
-
case 1:
|
|
516
|
-
fetchData = _a.sent();
|
|
517
|
-
return [4, fetchData.json()];
|
|
518
|
-
case 2:
|
|
519
|
-
responseData = _a.sent();
|
|
520
|
-
if (responseData.status !== 200) {
|
|
521
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
522
|
-
}
|
|
523
|
-
if (!!!responseData.data.userData) {
|
|
524
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: 'User not sent in request.' }));
|
|
525
|
-
}
|
|
526
|
-
if (responseData.token)
|
|
527
|
-
this.setUserToken(responseData.token);
|
|
528
|
-
return [2, responseData.data.userData];
|
|
529
|
-
}
|
|
330
|
+
this.validateAccount = async (code) => {
|
|
331
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/validateEmail`, {
|
|
332
|
+
method: 'POST',
|
|
333
|
+
headers: {
|
|
334
|
+
authorization: `Bearer ${this._token}`,
|
|
335
|
+
'Content-Type': 'application/json',
|
|
336
|
+
'x-gng-ecomm-token': this._userToken
|
|
337
|
+
},
|
|
338
|
+
body: JSON.stringify({ code: code })
|
|
530
339
|
});
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
340
|
+
const responseData = await fetchData.json();
|
|
341
|
+
if (responseData.status !== 200) {
|
|
342
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
343
|
+
}
|
|
344
|
+
if (!!!responseData.data.userData) {
|
|
345
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: 'User not sent in request.' }));
|
|
346
|
+
}
|
|
347
|
+
if (responseData.token)
|
|
348
|
+
this.setUserToken(responseData.token);
|
|
349
|
+
return responseData.data.userData;
|
|
350
|
+
};
|
|
351
|
+
this.logout = () => {
|
|
352
|
+
this.setUserToken('');
|
|
353
|
+
localStorage.removeItem(`${this._org}__cart`);
|
|
535
354
|
localStorage.removeItem('userLogged');
|
|
536
355
|
localStorage.removeItem('isPro');
|
|
537
356
|
localStorage.removeItem('foundInG2');
|
|
@@ -542,683 +361,478 @@ var SDK = (function () {
|
|
|
542
361
|
localStorage.removeItem('stockNotification');
|
|
543
362
|
js_cookie_1.default.remove('userToken', { expires: new Date(0) });
|
|
544
363
|
};
|
|
545
|
-
this.registerUser =
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
'x-gng-ecomm-locale': locale
|
|
555
|
-
},
|
|
556
|
-
body: JSON.stringify({ userData: userData, password: password })
|
|
557
|
-
})];
|
|
558
|
-
case 1:
|
|
559
|
-
fetchData = _a.sent();
|
|
560
|
-
if (fetchData.status == 200)
|
|
561
|
-
return [2, { status: 200, error: '' }];
|
|
562
|
-
return [4, fetchData.json()];
|
|
563
|
-
case 2:
|
|
564
|
-
responseData = _a.sent();
|
|
565
|
-
return [2, { status: responseData.status, error: responseData.error }];
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
}); };
|
|
569
|
-
this.getUser = function (keepTempHash) { return __awaiter(_this, void 0, void 0, function () {
|
|
570
|
-
var token, localToken, fetchData, responseData, _a, temp_hash, rest;
|
|
571
|
-
return __generator(this, function (_b) {
|
|
572
|
-
switch (_b.label) {
|
|
573
|
-
case 0:
|
|
574
|
-
token = this._userToken;
|
|
575
|
-
if (!!!token) {
|
|
576
|
-
localToken = localStorage.getItem('userToken');
|
|
577
|
-
if (!!localToken) {
|
|
578
|
-
token = localToken;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/get"), {
|
|
582
|
-
method: 'GET',
|
|
583
|
-
headers: {
|
|
584
|
-
authorization: "Bearer ".concat(this._token),
|
|
585
|
-
'Content-Type': 'application/json',
|
|
586
|
-
'x-gng-ecomm-token': token
|
|
587
|
-
}
|
|
588
|
-
})];
|
|
589
|
-
case 1:
|
|
590
|
-
fetchData = _b.sent();
|
|
591
|
-
return [4, fetchData.json()];
|
|
592
|
-
case 2:
|
|
593
|
-
responseData = _b.sent();
|
|
594
|
-
if (responseData.status !== 200) {
|
|
595
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
596
|
-
}
|
|
597
|
-
if (!!!responseData.data.userData) {
|
|
598
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: 'User not sent in request.' }));
|
|
599
|
-
}
|
|
600
|
-
if (responseData.token)
|
|
601
|
-
this.setUserToken(responseData.token);
|
|
602
|
-
_a = responseData.data.userData, temp_hash = _a.temp_hash, rest = __rest(_a, ["temp_hash"]);
|
|
603
|
-
return [2, __assign(__assign({}, rest), (!!keepTempHash ? { temp_hash: temp_hash } : {}))];
|
|
604
|
-
}
|
|
364
|
+
this.registerUser = async (locale, userData, password) => {
|
|
365
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/register`, {
|
|
366
|
+
method: 'PUT',
|
|
367
|
+
headers: {
|
|
368
|
+
Authorization: `Bearer ${this._token}`,
|
|
369
|
+
'Content-Type': 'application/json',
|
|
370
|
+
'x-gng-ecomm-locale': locale
|
|
371
|
+
},
|
|
372
|
+
body: JSON.stringify({ userData: userData, password: password })
|
|
605
373
|
});
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
return
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
},
|
|
618
|
-
body: JSON.stringify({ userData: userData })
|
|
619
|
-
})];
|
|
620
|
-
case 1:
|
|
621
|
-
fetchData = _a.sent();
|
|
622
|
-
return [4, fetchData.json()];
|
|
623
|
-
case 2:
|
|
624
|
-
responseData = _a.sent();
|
|
625
|
-
if (responseData.status !== 200) {
|
|
626
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
627
|
-
}
|
|
628
|
-
if (responseData.data !== 'done') {
|
|
629
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: 'User not sent in response.' }));
|
|
630
|
-
}
|
|
631
|
-
if (responseData.token)
|
|
632
|
-
this.setUserToken(responseData.token);
|
|
633
|
-
return [2, true];
|
|
374
|
+
if (fetchData.status == 200)
|
|
375
|
+
return { status: 200, error: '' };
|
|
376
|
+
const responseData = await fetchData.json();
|
|
377
|
+
return { status: responseData.status, error: responseData.error };
|
|
378
|
+
};
|
|
379
|
+
this.getUser = async (keepTempHash) => {
|
|
380
|
+
let token = this._userToken;
|
|
381
|
+
if (!!!token) {
|
|
382
|
+
const localToken = localStorage.getItem('userToken');
|
|
383
|
+
if (!!localToken) {
|
|
384
|
+
token = localToken;
|
|
634
385
|
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
method: 'GET',
|
|
643
|
-
headers: {
|
|
644
|
-
authorization: "Bearer ".concat(this._token),
|
|
645
|
-
'x-gng-ecomm-token': this._userToken
|
|
646
|
-
}
|
|
647
|
-
})];
|
|
648
|
-
case 1:
|
|
649
|
-
fetchData = _a.sent();
|
|
650
|
-
return [4, fetchData.json()];
|
|
651
|
-
case 2:
|
|
652
|
-
responseData = _a.sent();
|
|
653
|
-
if (responseData.status !== 200) {
|
|
654
|
-
return [2, false];
|
|
655
|
-
}
|
|
656
|
-
return [2, true];
|
|
386
|
+
}
|
|
387
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/get`, {
|
|
388
|
+
method: 'GET',
|
|
389
|
+
headers: {
|
|
390
|
+
authorization: `Bearer ${this._token}`,
|
|
391
|
+
'Content-Type': 'application/json',
|
|
392
|
+
'x-gng-ecomm-token': token
|
|
657
393
|
}
|
|
658
394
|
});
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
return [2, responseData.data];
|
|
681
|
-
}
|
|
682
|
-
return [2, responseData.data];
|
|
683
|
-
}
|
|
395
|
+
const responseData = await fetchData.json();
|
|
396
|
+
if (responseData.status !== 200) {
|
|
397
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
398
|
+
}
|
|
399
|
+
if (!!!responseData.data.userData) {
|
|
400
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: 'User not sent in request.' }));
|
|
401
|
+
}
|
|
402
|
+
if (responseData.token)
|
|
403
|
+
this.setUserToken(responseData.token);
|
|
404
|
+
const _a = responseData.data.userData, { temp_hash } = _a, rest = __rest(_a, ["temp_hash"]);
|
|
405
|
+
return Object.assign(Object.assign({}, rest), (!!keepTempHash ? { temp_hash: temp_hash } : {}));
|
|
406
|
+
};
|
|
407
|
+
this.saveUser = async (userData) => {
|
|
408
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/save`, {
|
|
409
|
+
method: 'POST',
|
|
410
|
+
headers: {
|
|
411
|
+
authorization: `Bearer ${this._token}`,
|
|
412
|
+
'Content-Type': 'application/json',
|
|
413
|
+
'x-gng-ecomm-token': this._userToken
|
|
414
|
+
},
|
|
415
|
+
body: JSON.stringify({ userData: userData })
|
|
684
416
|
});
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
return [4, fetchData.json()];
|
|
703
|
-
case 2:
|
|
704
|
-
responseData = (_a.sent());
|
|
705
|
-
if (responseData.status !== 200) {
|
|
706
|
-
return [2, responseData.data];
|
|
707
|
-
}
|
|
708
|
-
return [2, responseData.data];
|
|
709
|
-
case 3:
|
|
710
|
-
error_2 = _a.sent();
|
|
711
|
-
console.log(error_2);
|
|
712
|
-
return [2, ''];
|
|
713
|
-
case 4: return [2];
|
|
417
|
+
const responseData = await fetchData.json();
|
|
418
|
+
if (responseData.status !== 200) {
|
|
419
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
420
|
+
}
|
|
421
|
+
if (responseData.data !== 'done') {
|
|
422
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: 'User not sent in response.' }));
|
|
423
|
+
}
|
|
424
|
+
if (responseData.token)
|
|
425
|
+
this.setUserToken(responseData.token);
|
|
426
|
+
return true;
|
|
427
|
+
};
|
|
428
|
+
this.deleteUser = async () => {
|
|
429
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/delete`, {
|
|
430
|
+
method: 'GET',
|
|
431
|
+
headers: {
|
|
432
|
+
authorization: `Bearer ${this._token}`,
|
|
433
|
+
'x-gng-ecomm-token': this._userToken
|
|
714
434
|
}
|
|
715
435
|
});
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
body: JSON.stringify({ orderToken: token })
|
|
731
|
-
})];
|
|
732
|
-
case 1:
|
|
733
|
-
fetchData = _a.sent();
|
|
734
|
-
return [4, fetchData.json()];
|
|
735
|
-
case 2:
|
|
736
|
-
responseData = (_a.sent());
|
|
737
|
-
if (responseData.status !== 200) {
|
|
738
|
-
return [2, responseData.data];
|
|
739
|
-
}
|
|
740
|
-
return [2, responseData.data];
|
|
741
|
-
case 3:
|
|
742
|
-
error_3 = _a.sent();
|
|
743
|
-
console.log(error_3);
|
|
744
|
-
return [2, ''];
|
|
745
|
-
case 4: return [2];
|
|
436
|
+
const responseData = await fetchData.json();
|
|
437
|
+
if (responseData.status !== 200) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
return true;
|
|
441
|
+
};
|
|
442
|
+
this.getOrders = async (lastID, iteration) => {
|
|
443
|
+
let queryString = `?fromLastID=${lastID !== null && lastID !== void 0 ? lastID : ''}&skip=${iteration !== null && iteration !== void 0 ? iteration : ''}`;
|
|
444
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/orders${queryString}`, {
|
|
445
|
+
method: 'GET',
|
|
446
|
+
headers: {
|
|
447
|
+
authorization: `Bearer ${this._token}`,
|
|
448
|
+
'Content-Type': 'application/json',
|
|
449
|
+
'x-gng-ecomm-token': this._userToken
|
|
746
450
|
}
|
|
747
451
|
});
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
case 2:
|
|
768
|
-
responseData = (_a.sent());
|
|
769
|
-
return [2, responseData.data];
|
|
452
|
+
const responseData = (await fetchData.json());
|
|
453
|
+
if (responseData.status !== 200) {
|
|
454
|
+
return responseData.data;
|
|
455
|
+
}
|
|
456
|
+
return responseData.data;
|
|
457
|
+
};
|
|
458
|
+
this.killRepCart = async (hashed_cart_id) => {
|
|
459
|
+
try {
|
|
460
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/killRepCart/${encodeURIComponent(hashed_cart_id)}`, {
|
|
461
|
+
method: 'GET',
|
|
462
|
+
headers: {
|
|
463
|
+
authorization: `Bearer ${this._token}`,
|
|
464
|
+
'Content-Type': 'application/json',
|
|
465
|
+
'x-gng-ecomm-token': this._userToken
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
const responseData = (await fetchData.json());
|
|
469
|
+
if (responseData.status !== 200) {
|
|
470
|
+
return responseData.data;
|
|
770
471
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return [2, responseData.data];
|
|
793
|
-
return [2, responseData.error];
|
|
472
|
+
return responseData.data;
|
|
473
|
+
}
|
|
474
|
+
catch (error) {
|
|
475
|
+
console.log(error);
|
|
476
|
+
return '';
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
this.getOrder = async (orderID, token) => {
|
|
480
|
+
try {
|
|
481
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/order/${orderID}`, {
|
|
482
|
+
method: 'POST',
|
|
483
|
+
headers: {
|
|
484
|
+
authorization: `Bearer ${this._token}`,
|
|
485
|
+
'Content-Type': 'application/json',
|
|
486
|
+
'x-gng-ecomm-token': this._userToken
|
|
487
|
+
},
|
|
488
|
+
body: JSON.stringify({ orderToken: token })
|
|
489
|
+
});
|
|
490
|
+
const responseData = (await fetchData.json());
|
|
491
|
+
if (responseData.status !== 200) {
|
|
492
|
+
return responseData.data;
|
|
794
493
|
}
|
|
494
|
+
return responseData.data;
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
console.log(error);
|
|
498
|
+
return '';
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
this.changeProfilePicture = async (file) => {
|
|
502
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/changeProfilePicture`, {
|
|
503
|
+
method: 'POST',
|
|
504
|
+
headers: {
|
|
505
|
+
authorization: `Bearer ${this._token}`,
|
|
506
|
+
'Content-Type': 'application/json',
|
|
507
|
+
'x-gng-ecomm-token': this._userToken
|
|
508
|
+
},
|
|
509
|
+
body: JSON.stringify({
|
|
510
|
+
file: file
|
|
511
|
+
})
|
|
795
512
|
});
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
},
|
|
809
|
-
body: JSON.stringify({ userEmail: userEmail, forPro: forPro, withEmail: withEmail, isTest: isTest })
|
|
810
|
-
})];
|
|
811
|
-
case 1:
|
|
812
|
-
fetchData = _a.sent();
|
|
813
|
-
return [4, fetchData.json()];
|
|
814
|
-
case 2:
|
|
815
|
-
responseData = (_a.sent());
|
|
816
|
-
if (responseData.status === 200)
|
|
817
|
-
return [2, responseData.data];
|
|
818
|
-
if (responseData.status === 403)
|
|
819
|
-
return [2, {
|
|
820
|
-
fr: "Plus d'un compte a \u00E9t\u00E9 trouv\u00E9 avec ".concat(withEmail ? 'ce courriel' : 'ce ID client', ". Veuillez contacter un administrateur pour proc\u00E9der."),
|
|
821
|
-
en: "More than one account was found with ".concat(withEmail ? 'this email' : 'this client ID', ". Please contact an administrator to proceed.")
|
|
822
|
-
}];
|
|
823
|
-
return [2, responseData.error];
|
|
824
|
-
}
|
|
513
|
+
const responseData = (await fetchData.json());
|
|
514
|
+
return responseData.data;
|
|
515
|
+
};
|
|
516
|
+
this.changePassword = async (currentPassword, newPassword) => {
|
|
517
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/changePassword`, {
|
|
518
|
+
method: 'POST',
|
|
519
|
+
headers: {
|
|
520
|
+
authorization: `Bearer ${this._token}`,
|
|
521
|
+
'Content-Type': 'application/json',
|
|
522
|
+
'x-gng-ecomm-token': this._userToken
|
|
523
|
+
},
|
|
524
|
+
body: JSON.stringify({ currentPassword, newPassword })
|
|
825
525
|
});
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
return
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
return [2, {
|
|
842
|
-
error: "Couldn't convert file to base64"
|
|
843
|
-
}];
|
|
844
|
-
}
|
|
845
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendApplicationEmail"), {
|
|
846
|
-
method: 'POST',
|
|
847
|
-
headers: {
|
|
848
|
-
authorization: "Bearer ".concat(this._token),
|
|
849
|
-
'Content-Type': 'application/json',
|
|
850
|
-
'x-gng-ecomm-token': this._userToken,
|
|
851
|
-
'x-gng-ecomm-locale': locale
|
|
852
|
-
},
|
|
853
|
-
body: JSON.stringify(__assign(__assign({}, form), { cv: cvBase64 }))
|
|
854
|
-
})];
|
|
855
|
-
case 2:
|
|
856
|
-
fetchData = _a.sent();
|
|
857
|
-
return [4, fetchData.json()];
|
|
858
|
-
case 3:
|
|
859
|
-
responseData = (_a.sent());
|
|
860
|
-
if (responseData.status === 200)
|
|
861
|
-
return [2, responseData.data];
|
|
862
|
-
return [2, responseData.error];
|
|
863
|
-
case 4:
|
|
864
|
-
error_4 = _a.sent();
|
|
865
|
-
return [2, 'error'];
|
|
866
|
-
case 5: return [2];
|
|
867
|
-
}
|
|
526
|
+
const responseData = (await fetchData.json());
|
|
527
|
+
if (responseData.status === 200)
|
|
528
|
+
return responseData.data;
|
|
529
|
+
return responseData.error;
|
|
530
|
+
};
|
|
531
|
+
this.sendResetPasswordEmail = async (locale, userEmail, forPro, withEmail, isTest) => {
|
|
532
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/sentForgotPasswordEmail`, {
|
|
533
|
+
method: 'POST',
|
|
534
|
+
headers: {
|
|
535
|
+
authorization: `Bearer ${this._token}`,
|
|
536
|
+
'Content-Type': 'application/json',
|
|
537
|
+
'x-gng-ecomm-token': this._userToken,
|
|
538
|
+
'x-gng-ecomm-locale': locale
|
|
539
|
+
},
|
|
540
|
+
body: JSON.stringify({ userEmail, forPro, withEmail, isTest })
|
|
868
541
|
});
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
return [2, responseData.data];
|
|
891
|
-
return [2, responseData.error];
|
|
542
|
+
const responseData = (await fetchData.json());
|
|
543
|
+
if (responseData.status === 200)
|
|
544
|
+
return responseData.data;
|
|
545
|
+
if (responseData.status === 403)
|
|
546
|
+
return {
|
|
547
|
+
fr: `Plus d\'un compte a été trouvé avec ${withEmail ? 'ce courriel' : 'ce ID client'}. Veuillez contacter un administrateur pour procéder.`,
|
|
548
|
+
en: `More than one account was found with ${withEmail ? 'this email' : 'this client ID'}. Please contact an administrator to proceed.`
|
|
549
|
+
};
|
|
550
|
+
return responseData.error;
|
|
551
|
+
};
|
|
552
|
+
this.sendApplicationEmail = async (locale, form) => {
|
|
553
|
+
try {
|
|
554
|
+
if (!!!form.cv)
|
|
555
|
+
return {
|
|
556
|
+
error: "Couldn't find cv"
|
|
557
|
+
};
|
|
558
|
+
const cvBase64 = await (0, functions_2.toBase64)(form.cv);
|
|
559
|
+
if (typeof cvBase64 !== 'string') {
|
|
560
|
+
return {
|
|
561
|
+
error: "Couldn't convert file to base64"
|
|
562
|
+
};
|
|
892
563
|
}
|
|
564
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/email/sendApplicationEmail`, {
|
|
565
|
+
method: 'POST',
|
|
566
|
+
headers: {
|
|
567
|
+
authorization: `Bearer ${this._token}`,
|
|
568
|
+
'Content-Type': 'application/json',
|
|
569
|
+
'x-gng-ecomm-token': this._userToken,
|
|
570
|
+
'x-gng-ecomm-locale': locale
|
|
571
|
+
},
|
|
572
|
+
body: JSON.stringify(Object.assign(Object.assign({}, form), { cv: cvBase64 }))
|
|
573
|
+
});
|
|
574
|
+
const responseData = (await fetchData.json());
|
|
575
|
+
if (responseData.status === 200)
|
|
576
|
+
return responseData.data;
|
|
577
|
+
return responseData.error;
|
|
578
|
+
}
|
|
579
|
+
catch (error) {
|
|
580
|
+
return 'error';
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
this.sendContactEmail = async (locale, form) => {
|
|
584
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/email/sendContactEmail`, {
|
|
585
|
+
method: 'POST',
|
|
586
|
+
headers: {
|
|
587
|
+
authorization: `Bearer ${this._token}`,
|
|
588
|
+
'Content-Type': 'application/json',
|
|
589
|
+
'x-gng-ecomm-token': this._userToken,
|
|
590
|
+
'x-gng-ecomm-locale': locale
|
|
591
|
+
},
|
|
592
|
+
body: JSON.stringify(form)
|
|
893
593
|
});
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
return
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
_a.label = 1;
|
|
909
|
-
case 1:
|
|
910
|
-
_a.trys.push([1, 4, , 5]);
|
|
911
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendGenericOtherEmail"), {
|
|
912
|
-
method: 'POST',
|
|
913
|
-
headers: {
|
|
914
|
-
authorization: "Bearer ".concat(this._token),
|
|
915
|
-
'Content-Type': 'application/json',
|
|
916
|
-
'x-gng-ecomm-token': this._userToken,
|
|
917
|
-
'x-gng-ecomm-locale': locale
|
|
918
|
-
},
|
|
919
|
-
body: JSON.stringify(__assign(__assign({}, (!!form ? { content: form } : {})), { subject: getSubjectByType(templateId), templateId: templateId, to: to, replyTo: replyTo }))
|
|
920
|
-
})];
|
|
921
|
-
case 2:
|
|
922
|
-
fetchData = _a.sent();
|
|
923
|
-
return [4, fetchData.json()];
|
|
924
|
-
case 3:
|
|
925
|
-
responseData = (_a.sent());
|
|
926
|
-
if (responseData.status === 200)
|
|
927
|
-
return [2, responseData.data];
|
|
928
|
-
return [2, responseData.error];
|
|
929
|
-
case 4:
|
|
930
|
-
error_5 = _a.sent();
|
|
931
|
-
console.log('error on sendGenericOtherEmail: ', error_5);
|
|
932
|
-
return [3, 5];
|
|
933
|
-
case 5: return [2];
|
|
594
|
+
const responseData = (await fetchData.json());
|
|
595
|
+
if (responseData.status === 200)
|
|
596
|
+
return responseData.data;
|
|
597
|
+
return responseData.error;
|
|
598
|
+
};
|
|
599
|
+
this.sendGenericOtherEmail = async (locale, form, templateId, to, replyTo) => {
|
|
600
|
+
const getSubjectByType = (type) => {
|
|
601
|
+
switch (type) {
|
|
602
|
+
case 'confirmation_lawn_submission':
|
|
603
|
+
return { fr: 'Soumission gazon - Confirmation de réception', en: 'Lawn submission - Confirmation' };
|
|
604
|
+
default:
|
|
605
|
+
return undefined;
|
|
934
606
|
}
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
607
|
+
};
|
|
608
|
+
try {
|
|
609
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/email/sendGenericOtherEmail`, {
|
|
610
|
+
method: 'POST',
|
|
611
|
+
headers: {
|
|
612
|
+
authorization: `Bearer ${this._token}`,
|
|
613
|
+
'Content-Type': 'application/json',
|
|
614
|
+
'x-gng-ecomm-token': this._userToken,
|
|
615
|
+
'x-gng-ecomm-locale': locale
|
|
616
|
+
},
|
|
617
|
+
body: JSON.stringify(Object.assign(Object.assign({}, (!!form ? { content: form } : {})), { subject: getSubjectByType(templateId), templateId,
|
|
618
|
+
to,
|
|
619
|
+
replyTo }))
|
|
620
|
+
});
|
|
621
|
+
const responseData = (await fetchData.json());
|
|
622
|
+
if (responseData.status === 200)
|
|
623
|
+
return responseData.data;
|
|
624
|
+
return responseData.error;
|
|
625
|
+
}
|
|
626
|
+
catch (error) {
|
|
627
|
+
console.log('error on sendGenericOtherEmail: ', error);
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
this.sendServicePageEmail = async (locale, form, type, testEmail) => {
|
|
631
|
+
const { attachments } = form, rest = __rest(form, ["attachments"]);
|
|
632
|
+
const updatedAttachments = [];
|
|
633
|
+
if (!!attachments) {
|
|
634
|
+
for (let att of attachments) {
|
|
635
|
+
try {
|
|
636
|
+
const cvBase64 = await (0, functions_2.toBase64)(att);
|
|
956
637
|
updatedAttachments.push({ name: att.name, content: cvBase64 });
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
case
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
return {
|
|
983
|
-
fr: 'Produits en solde - Information demandée',
|
|
984
|
-
en: 'On sale products - Information request'
|
|
985
|
-
};
|
|
986
|
-
case 'admin_credit_info':
|
|
987
|
-
return {
|
|
988
|
-
fr: 'Département de crédit - Information demandée',
|
|
989
|
-
en: 'Credit department - Information request'
|
|
990
|
-
};
|
|
991
|
-
case 'admin_transport_quote':
|
|
992
|
-
return {
|
|
993
|
-
fr: 'Location de camion - nouvelle soumission',
|
|
994
|
-
en: 'Transport truck rental - new quotation'
|
|
995
|
-
};
|
|
996
|
-
case 'admin_special_order':
|
|
997
|
-
return { fr: 'Commande spéciale - nouvelle demande', en: 'Special order - new request' };
|
|
998
|
-
case 'admin_installation':
|
|
999
|
-
return { fr: 'Installation - nouvelle soumission', en: 'Installation - new quotation' };
|
|
1000
|
-
case 'admin_find_landscaper':
|
|
1001
|
-
return { fr: 'Trouver un paysagiste - nouvelle demande', en: 'Find a landscaper - new request' };
|
|
1002
|
-
case 'admin_lawn_submission':
|
|
1003
|
-
return { fr: 'Soumission gazon - nouvelle demande', en: 'Lawn submission - new request' };
|
|
1004
|
-
case 'confirmation_find_landsacper':
|
|
1005
|
-
return { fr: 'Trouver un paysagiste - Confirmation', en: 'Find a landscaper - Confirmation' };
|
|
1006
|
-
default:
|
|
1007
|
-
return { fr: 'Demande de service - nouvelle soumission', en: 'Service request - new quotation' };
|
|
1008
|
-
}
|
|
638
|
+
}
|
|
639
|
+
catch (e) {
|
|
640
|
+
console.log('error on converting to base64: ', e);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
const getSubjectByType = () => {
|
|
645
|
+
switch (type) {
|
|
646
|
+
case 'admin_3D_plans':
|
|
647
|
+
if (!!form.project_type && form.project_type === 'conception') {
|
|
648
|
+
return { fr: 'Conception de plans - Nouvelle demande', en: 'Project design - new request' };
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
return { fr: 'Images 3D - Nouvelle demande', en: '3D plans - new request' };
|
|
652
|
+
}
|
|
653
|
+
case 'admin_vegetals':
|
|
654
|
+
return { fr: 'Commande de végétaux - nouvelle soumission', en: 'Vegetals - new quotation' };
|
|
655
|
+
case 'admin_pickup_on_site':
|
|
656
|
+
return { fr: 'Ramassage sur chantier - nouvelle demande', en: 'Pickup on site - new request' };
|
|
657
|
+
case 'admin_borrow_tools':
|
|
658
|
+
return { fr: "Location d'outils - nouvelle demande", en: 'Rent tools - new request' };
|
|
659
|
+
case 'admin_sales_info':
|
|
660
|
+
return {
|
|
661
|
+
fr: 'Produits en solde - Information demandée',
|
|
662
|
+
en: 'On sale products - Information request'
|
|
1009
663
|
};
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
return
|
|
1026
|
-
case
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
664
|
+
case 'admin_credit_info':
|
|
665
|
+
return {
|
|
666
|
+
fr: 'Département de crédit - Information demandée',
|
|
667
|
+
en: 'Credit department - Information request'
|
|
668
|
+
};
|
|
669
|
+
case 'admin_transport_quote':
|
|
670
|
+
return {
|
|
671
|
+
fr: 'Location de camion - nouvelle soumission',
|
|
672
|
+
en: 'Transport truck rental - new quotation'
|
|
673
|
+
};
|
|
674
|
+
case 'admin_special_order':
|
|
675
|
+
return { fr: 'Commande spéciale - nouvelle demande', en: 'Special order - new request' };
|
|
676
|
+
case 'admin_installation':
|
|
677
|
+
return { fr: 'Installation - nouvelle soumission', en: 'Installation - new quotation' };
|
|
678
|
+
case 'admin_find_landscaper':
|
|
679
|
+
return { fr: 'Trouver un paysagiste - nouvelle demande', en: 'Find a landscaper - new request' };
|
|
680
|
+
case 'admin_lawn_submission':
|
|
681
|
+
return { fr: 'Soumission gazon - nouvelle demande', en: 'Lawn submission - new request' };
|
|
682
|
+
case 'confirmation_find_landsacper':
|
|
683
|
+
return { fr: 'Trouver un paysagiste - Confirmation', en: 'Find a landscaper - Confirmation' };
|
|
684
|
+
default:
|
|
685
|
+
return { fr: 'Demande de service - nouvelle soumission', en: 'Service request - new quotation' };
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
try {
|
|
689
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/email/sendServiceStaticPageEmail`, {
|
|
690
|
+
method: 'POST',
|
|
691
|
+
headers: {
|
|
692
|
+
authorization: `Bearer ${this._token}`,
|
|
693
|
+
'Content-Type': 'application/json',
|
|
694
|
+
'x-gng-ecomm-token': this._userToken,
|
|
695
|
+
'x-gng-ecomm-locale': locale
|
|
696
|
+
},
|
|
697
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (!!updatedAttachments && !!updatedAttachments.length ? { attachments: updatedAttachments } : {})), { subject: getSubjectByType(), title: getSubjectByType(), type: type }), (!!testEmail ? { test_email: testEmail } : {})))
|
|
698
|
+
});
|
|
699
|
+
const responseData = (await fetchData.json());
|
|
700
|
+
if (responseData.status === 200)
|
|
701
|
+
return true;
|
|
702
|
+
return responseData.error;
|
|
703
|
+
}
|
|
704
|
+
catch (e) {
|
|
705
|
+
console.log('error on calling api: ', e);
|
|
706
|
+
if (!!updatedAttachments) {
|
|
707
|
+
return {
|
|
708
|
+
status: 413,
|
|
709
|
+
error: {
|
|
710
|
+
fr: "Vos pièces jointes n'ont pas pu être envoyées. Veuillez réessayer.",
|
|
711
|
+
en: 'Your attachments could not be sent. Please try again.'
|
|
1042
712
|
}
|
|
1043
|
-
|
|
1044
|
-
case 11: return [2];
|
|
713
|
+
};
|
|
1045
714
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
splitString = planBase64.split(';base64,');
|
|
1063
|
-
if (!!splitString.length && !!splitString[1]) {
|
|
1064
|
-
updatedPlan = {
|
|
1065
|
-
name: plan.name,
|
|
1066
|
-
content: splitString[1]
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
715
|
+
return '';
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
this.sendSponsorRequestEmail = async (locale, form, template_name) => {
|
|
719
|
+
const { plan } = form, rest = __rest(form, ["plan"]);
|
|
720
|
+
let updatedPlan;
|
|
721
|
+
if (!!plan) {
|
|
722
|
+
try {
|
|
723
|
+
const planBase64 = await (0, functions_2.toBase64)(plan);
|
|
724
|
+
if (typeof planBase64 === 'string') {
|
|
725
|
+
const splitString = planBase64.split(';base64,');
|
|
726
|
+
if (!!splitString.length && !!splitString[1]) {
|
|
727
|
+
updatedPlan = {
|
|
728
|
+
name: plan.name,
|
|
729
|
+
content: splitString[1]
|
|
730
|
+
};
|
|
1069
731
|
}
|
|
1070
|
-
|
|
1071
|
-
case 3:
|
|
1072
|
-
e_6 = _a.sent();
|
|
1073
|
-
console.log('error on converting to base64: ', e_6);
|
|
1074
|
-
return [3, 4];
|
|
1075
|
-
case 4: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendSponsorRequestEmail"), {
|
|
1076
|
-
method: 'POST',
|
|
1077
|
-
headers: {
|
|
1078
|
-
authorization: "Bearer ".concat(this._token),
|
|
1079
|
-
'Content-Type': 'application/json',
|
|
1080
|
-
'x-gng-ecomm-token': this._userToken,
|
|
1081
|
-
'x-gng-ecomm-locale': locale
|
|
1082
|
-
},
|
|
1083
|
-
body: JSON.stringify({
|
|
1084
|
-
contenu: __assign(__assign(__assign({}, rest), { admin: true, has_plan: !!updatedPlan }), (!!updatedPlan
|
|
1085
|
-
? {
|
|
1086
|
-
plan: updatedPlan
|
|
1087
|
-
}
|
|
1088
|
-
: {})),
|
|
1089
|
-
template_name: template_name
|
|
1090
|
-
})
|
|
1091
|
-
})];
|
|
1092
|
-
case 5:
|
|
1093
|
-
fetchData = _a.sent();
|
|
1094
|
-
return [4, fetchData.json()];
|
|
1095
|
-
case 6:
|
|
1096
|
-
responseData = (_a.sent());
|
|
1097
|
-
if (responseData.status === 200)
|
|
1098
|
-
return [2, true];
|
|
1099
|
-
return [2, responseData.error];
|
|
732
|
+
}
|
|
1100
733
|
}
|
|
734
|
+
catch (e) {
|
|
735
|
+
console.log('error on converting to base64: ', e);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/email/sendSponsorRequestEmail`, {
|
|
739
|
+
method: 'POST',
|
|
740
|
+
headers: {
|
|
741
|
+
authorization: `Bearer ${this._token}`,
|
|
742
|
+
'Content-Type': 'application/json',
|
|
743
|
+
'x-gng-ecomm-token': this._userToken,
|
|
744
|
+
'x-gng-ecomm-locale': locale
|
|
745
|
+
},
|
|
746
|
+
body: JSON.stringify({
|
|
747
|
+
contenu: Object.assign(Object.assign(Object.assign({}, rest), { admin: true, has_plan: !!updatedPlan }), (!!updatedPlan
|
|
748
|
+
? {
|
|
749
|
+
plan: updatedPlan
|
|
750
|
+
}
|
|
751
|
+
: {})),
|
|
752
|
+
template_name: template_name
|
|
753
|
+
})
|
|
1101
754
|
});
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
return
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
if (!(_i < _b.length)) return [3, 6];
|
|
1117
|
-
att = _b[_i];
|
|
1118
|
-
_c.label = 2;
|
|
1119
|
-
case 2:
|
|
1120
|
-
_c.trys.push([2, 4, , 5]);
|
|
1121
|
-
return [4, (0, functions_2.toBase64)(att)];
|
|
1122
|
-
case 3:
|
|
1123
|
-
cvBase64 = _c.sent();
|
|
755
|
+
const responseData = (await fetchData.json());
|
|
756
|
+
if (responseData.status === 200)
|
|
757
|
+
return true;
|
|
758
|
+
return responseData.error;
|
|
759
|
+
};
|
|
760
|
+
this.sendPreMeetingFormEmail = async (locale, form, proId) => {
|
|
761
|
+
const { attachments } = form, rest = __rest(form, ["attachments"]);
|
|
762
|
+
const _a = rest.pro_infos, { pro_logo } = _a, restProInfos = __rest(_a, ["pro_logo"]);
|
|
763
|
+
const updatedAttachments = [];
|
|
764
|
+
let updatedLogo = '';
|
|
765
|
+
if (!!attachments) {
|
|
766
|
+
for (let att of attachments) {
|
|
767
|
+
try {
|
|
768
|
+
const cvBase64 = await (0, functions_2.toBase64)(att);
|
|
1124
769
|
updatedAttachments.push({ name: att.name, content: cvBase64 });
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
return [3, 5];
|
|
1130
|
-
case 5:
|
|
1131
|
-
_i++;
|
|
1132
|
-
return [3, 1];
|
|
1133
|
-
case 6:
|
|
1134
|
-
if (!!!pro_logo) return [3, 10];
|
|
1135
|
-
_c.label = 7;
|
|
1136
|
-
case 7:
|
|
1137
|
-
_c.trys.push([7, 9, , 10]);
|
|
1138
|
-
return [4, (0, functions_2.toBase64)(pro_logo)];
|
|
1139
|
-
case 8:
|
|
1140
|
-
logoBase64 = _c.sent();
|
|
1141
|
-
updatedLogo = { name: pro_logo.name, content: logoBase64 };
|
|
1142
|
-
return [3, 10];
|
|
1143
|
-
case 9:
|
|
1144
|
-
e_8 = _c.sent();
|
|
1145
|
-
console.log('error on converting logo to base64: ', e_8);
|
|
1146
|
-
return [3, 10];
|
|
1147
|
-
case 10: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendPreMeetingFormEmail"), {
|
|
1148
|
-
method: 'POST',
|
|
1149
|
-
headers: {
|
|
1150
|
-
authorization: "Bearer ".concat(this._token),
|
|
1151
|
-
'Content-Type': 'application/json',
|
|
1152
|
-
'x-gng-ecomm-token': this._userToken,
|
|
1153
|
-
'x-gng-ecomm-locale': locale
|
|
1154
|
-
},
|
|
1155
|
-
body: JSON.stringify(__assign(__assign(__assign(__assign({}, rest), { pro_infos: __assign(__assign({}, restProInfos), (!!updatedLogo ? { pro_logo: updatedLogo } : {})) }), (!!updatedAttachments && !!updatedAttachments.length ? { attachments: updatedAttachments } : {})), (!!proId ? { pro_id: proId } : {})))
|
|
1156
|
-
})];
|
|
1157
|
-
case 11:
|
|
1158
|
-
fetchData = _c.sent();
|
|
1159
|
-
return [4, fetchData.json()];
|
|
1160
|
-
case 12:
|
|
1161
|
-
responseData = (_c.sent());
|
|
1162
|
-
if (responseData.status === 200)
|
|
1163
|
-
return [2, true];
|
|
1164
|
-
return [2, responseData.error];
|
|
770
|
+
}
|
|
771
|
+
catch (e) {
|
|
772
|
+
console.log('error on converting to base64: ', e);
|
|
773
|
+
}
|
|
1165
774
|
}
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
switch (_a.label) {
|
|
1172
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendWishlistEmail"), {
|
|
1173
|
-
method: 'POST',
|
|
1174
|
-
headers: {
|
|
1175
|
-
authorization: "Bearer ".concat(this._token),
|
|
1176
|
-
'Content-Type': 'application/json',
|
|
1177
|
-
'x-gng-ecomm-token': this._userToken,
|
|
1178
|
-
'x-gng-ecomm-locale': locale
|
|
1179
|
-
},
|
|
1180
|
-
body: JSON.stringify({ contenu: contenu, template_name: template_name })
|
|
1181
|
-
})];
|
|
1182
|
-
case 1:
|
|
1183
|
-
fetchData = _a.sent();
|
|
1184
|
-
return [4, fetchData.json()];
|
|
1185
|
-
case 2:
|
|
1186
|
-
responseData = (_a.sent());
|
|
1187
|
-
if (responseData.status === 200)
|
|
1188
|
-
return [2, true];
|
|
1189
|
-
return [2, responseData.error];
|
|
775
|
+
}
|
|
776
|
+
if (!!pro_logo) {
|
|
777
|
+
try {
|
|
778
|
+
const logoBase64 = await (0, functions_2.toBase64)(pro_logo);
|
|
779
|
+
updatedLogo = { name: pro_logo.name, content: logoBase64 };
|
|
1190
780
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
this.resetPassword = function (token, newPassword, withEmail) { return __awaiter(_this, void 0, void 0, function () {
|
|
1194
|
-
var fetchData, responseData;
|
|
1195
|
-
return __generator(this, function (_a) {
|
|
1196
|
-
switch (_a.label) {
|
|
1197
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/resetPassword"), {
|
|
1198
|
-
method: 'POST',
|
|
1199
|
-
headers: {
|
|
1200
|
-
authorization: "Bearer ".concat(this._token),
|
|
1201
|
-
'Content-Type': 'application/json',
|
|
1202
|
-
'x-gng-ecomm-token': this._userToken
|
|
1203
|
-
},
|
|
1204
|
-
body: JSON.stringify({ validationCode: token, newPassword: newPassword, withEmail: withEmail })
|
|
1205
|
-
})];
|
|
1206
|
-
case 1:
|
|
1207
|
-
fetchData = _a.sent();
|
|
1208
|
-
return [4, fetchData.json()];
|
|
1209
|
-
case 2:
|
|
1210
|
-
responseData = (_a.sent());
|
|
1211
|
-
if (responseData.status === 200)
|
|
1212
|
-
return [2, responseData.data];
|
|
1213
|
-
if (responseData.status === 403)
|
|
1214
|
-
return [2, {
|
|
1215
|
-
fr: "Plus d'un compte a \u00E9t\u00E9 trouv\u00E9 avec ".concat(withEmail ? 'ce courriel' : 'ce ID client', ". Veuillez contacter un administrateur pour proc\u00E9der."),
|
|
1216
|
-
en: "More than one account was found with ".concat(withEmail ? 'this email' : 'this client ID', ". Please contact an administrator to proceed.")
|
|
1217
|
-
}];
|
|
1218
|
-
return [2, responseData.error];
|
|
781
|
+
catch (e) {
|
|
782
|
+
console.log('error on converting logo to base64: ', e);
|
|
1219
783
|
}
|
|
784
|
+
}
|
|
785
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/email/sendPreMeetingFormEmail`, {
|
|
786
|
+
method: 'POST',
|
|
787
|
+
headers: {
|
|
788
|
+
authorization: `Bearer ${this._token}`,
|
|
789
|
+
'Content-Type': 'application/json',
|
|
790
|
+
'x-gng-ecomm-token': this._userToken,
|
|
791
|
+
'x-gng-ecomm-locale': locale
|
|
792
|
+
},
|
|
793
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { pro_infos: Object.assign(Object.assign({}, restProInfos), (!!updatedLogo ? { pro_logo: updatedLogo } : {})) }), (!!updatedAttachments && !!updatedAttachments.length ? { attachments: updatedAttachments } : {})), (!!proId ? { pro_id: proId } : {})))
|
|
794
|
+
});
|
|
795
|
+
const responseData = (await fetchData.json());
|
|
796
|
+
if (responseData.status === 200)
|
|
797
|
+
return true;
|
|
798
|
+
return responseData.error;
|
|
799
|
+
};
|
|
800
|
+
this.sendWishlistByEmail = async (locale, contenu, template_name) => {
|
|
801
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/email/sendWishlistEmail`, {
|
|
802
|
+
method: 'POST',
|
|
803
|
+
headers: {
|
|
804
|
+
authorization: `Bearer ${this._token}`,
|
|
805
|
+
'Content-Type': 'application/json',
|
|
806
|
+
'x-gng-ecomm-token': this._userToken,
|
|
807
|
+
'x-gng-ecomm-locale': locale
|
|
808
|
+
},
|
|
809
|
+
body: JSON.stringify({ contenu: contenu, template_name: template_name })
|
|
810
|
+
});
|
|
811
|
+
const responseData = (await fetchData.json());
|
|
812
|
+
if (responseData.status === 200)
|
|
813
|
+
return true;
|
|
814
|
+
return responseData.error;
|
|
815
|
+
};
|
|
816
|
+
this.resetPassword = async (token, newPassword, withEmail) => {
|
|
817
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/user/resetPassword`, {
|
|
818
|
+
method: 'POST',
|
|
819
|
+
headers: {
|
|
820
|
+
authorization: `Bearer ${this._token}`,
|
|
821
|
+
'Content-Type': 'application/json',
|
|
822
|
+
'x-gng-ecomm-token': this._userToken
|
|
823
|
+
},
|
|
824
|
+
body: JSON.stringify({ validationCode: token, newPassword, withEmail })
|
|
1220
825
|
});
|
|
1221
|
-
|
|
826
|
+
const responseData = (await fetchData.json());
|
|
827
|
+
if (responseData.status === 200)
|
|
828
|
+
return responseData.data;
|
|
829
|
+
if (responseData.status === 403)
|
|
830
|
+
return {
|
|
831
|
+
fr: `Plus d\'un compte a été trouvé avec ${withEmail ? 'ce courriel' : 'ce ID client'}. Veuillez contacter un administrateur pour procéder.`,
|
|
832
|
+
en: `More than one account was found with ${withEmail ? 'this email' : 'this client ID'}. Please contact an administrator to proceed.`
|
|
833
|
+
};
|
|
834
|
+
return responseData.error;
|
|
835
|
+
};
|
|
1222
836
|
this.user = {
|
|
1223
837
|
getUser: this.getUser,
|
|
1224
838
|
saveUser: this.saveUser,
|
|
@@ -1244,296 +858,183 @@ var SDK = (function () {
|
|
|
1244
858
|
createPro: this.createProCustomer,
|
|
1245
859
|
fetchCustomPriceList: this.fetchCustomPriceList
|
|
1246
860
|
};
|
|
1247
|
-
this.getImage =
|
|
1248
|
-
|
|
1249
|
-
var img = new image_1.default("".concat(addImgPath ? _this._imgPath : '').concat(_this._imgPath, "/").concat(imgName));
|
|
861
|
+
this.getImage = (imgName, formatQuery, addImgPath = false) => {
|
|
862
|
+
const img = new image_1.default(`${addImgPath ? this._imgPath : ''}${this._imgPath}/${imgName}`);
|
|
1250
863
|
return img.getFileDownloadUrl(formatQuery);
|
|
1251
864
|
};
|
|
1252
|
-
this.getProducts =
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
865
|
+
this.getProducts = async (page = 0, hpp = 10, query = '', filters = '', indice = 'products', f = '', useProspr = false) => {
|
|
866
|
+
try {
|
|
867
|
+
return await Product_1.default.fetch({
|
|
868
|
+
app: process.env.NEXT_PUBLIC_ALGOLIA_APP,
|
|
869
|
+
api: process.env.NEXT_PUBLIC_ALGOLIA_TOKEN,
|
|
870
|
+
page: page,
|
|
871
|
+
hpp: hpp,
|
|
872
|
+
query: query,
|
|
873
|
+
filters,
|
|
874
|
+
indice: indice || 'products',
|
|
875
|
+
f,
|
|
876
|
+
useProspr,
|
|
877
|
+
space: undefined
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
catch (error) {
|
|
881
|
+
throw error;
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
this.getProduct = async (parentSlug, locale, useProdArray, noDrafts) => {
|
|
885
|
+
let prod = undefined;
|
|
886
|
+
if (!!useProdArray && !!useProdArray.length) {
|
|
887
|
+
prod = useProdArray.find((fee) => fee.slug === parentSlug);
|
|
888
|
+
}
|
|
889
|
+
if (!!!prod) {
|
|
890
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/products/${encodeURIComponent(parentSlug)}`, {
|
|
891
|
+
method: 'GET',
|
|
892
|
+
headers: {
|
|
893
|
+
Authorization: `Bearer ${this._token}`,
|
|
894
|
+
'x-gng-ecomm-locale': locale,
|
|
895
|
+
'x-gng-ecomm-token': this._userToken
|
|
1283
896
|
}
|
|
1284
897
|
});
|
|
1285
|
-
|
|
898
|
+
const responseData = await fetchData.json();
|
|
899
|
+
if (responseData.status !== 200)
|
|
900
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
901
|
+
prod = responseData.data;
|
|
902
|
+
}
|
|
903
|
+
if (!!noDrafts && prod.draft)
|
|
904
|
+
return undefined;
|
|
905
|
+
return prod;
|
|
1286
906
|
};
|
|
1287
|
-
this.
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
}
|
|
1296
|
-
if (!!!!prod) return [3, 3];
|
|
1297
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/products/").concat(encodeURIComponent(parentSlug)), {
|
|
1298
|
-
method: 'GET',
|
|
1299
|
-
headers: {
|
|
1300
|
-
Authorization: "Bearer ".concat(this._token),
|
|
1301
|
-
'x-gng-ecomm-locale': locale,
|
|
1302
|
-
'x-gng-ecomm-token': this._userToken
|
|
1303
|
-
}
|
|
1304
|
-
})];
|
|
1305
|
-
case 1:
|
|
1306
|
-
fetchData = _a.sent();
|
|
1307
|
-
return [4, fetchData.json()];
|
|
1308
|
-
case 2:
|
|
1309
|
-
responseData = _a.sent();
|
|
1310
|
-
if (responseData.status !== 200)
|
|
1311
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1312
|
-
prod = responseData.data;
|
|
1313
|
-
_a.label = 3;
|
|
1314
|
-
case 3:
|
|
1315
|
-
if (!!noDrafts && prod.draft)
|
|
1316
|
-
return [2, undefined];
|
|
1317
|
-
return [2, prod];
|
|
1318
|
-
}
|
|
1319
|
-
});
|
|
1320
|
-
}); };
|
|
1321
|
-
this.getUpsellOfProducts = function (slugs, customPriceList) { return __awaiter(_this, void 0, void 0, function () {
|
|
1322
|
-
var fetchData, responseData;
|
|
1323
|
-
return __generator(this, function (_a) {
|
|
1324
|
-
switch (_a.label) {
|
|
1325
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/products/getUpsellOfProductsWithProducts"), {
|
|
1326
|
-
method: 'POST',
|
|
1327
|
-
headers: {
|
|
1328
|
-
Authorization: "Bearer ".concat(this._token),
|
|
1329
|
-
'Content-Type': 'application/json'
|
|
1330
|
-
},
|
|
1331
|
-
body: JSON.stringify(__assign({ slugs: slugs }, (!!customPriceList ? { customPriceList: customPriceList } : {})))
|
|
1332
|
-
})];
|
|
1333
|
-
case 1:
|
|
1334
|
-
fetchData = _a.sent();
|
|
1335
|
-
return [4, fetchData.json()];
|
|
1336
|
-
case 2:
|
|
1337
|
-
responseData = _a.sent();
|
|
1338
|
-
if (responseData.status !== 200)
|
|
1339
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1340
|
-
return [2, responseData.data];
|
|
1341
|
-
}
|
|
1342
|
-
});
|
|
1343
|
-
}); };
|
|
1344
|
-
this.getAttributes = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1345
|
-
var fetchData, resJson, error_7;
|
|
1346
|
-
return __generator(this, function (_a) {
|
|
1347
|
-
switch (_a.label) {
|
|
1348
|
-
case 0:
|
|
1349
|
-
_a.trys.push([0, 3, , 4]);
|
|
1350
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/attributes"), {
|
|
1351
|
-
method: 'GET',
|
|
1352
|
-
headers: {
|
|
1353
|
-
authorization: "Bearer ".concat(this._token),
|
|
1354
|
-
'Content-Type': 'application/json'
|
|
1355
|
-
}
|
|
1356
|
-
})];
|
|
1357
|
-
case 1:
|
|
1358
|
-
fetchData = _a.sent();
|
|
1359
|
-
return [4, fetchData.json()];
|
|
1360
|
-
case 2:
|
|
1361
|
-
resJson = _a.sent();
|
|
1362
|
-
return [2, resJson.data.map(function (a) { return (__assign(__assign({}, a), { slug: !!a.slug ? a.slug : (0, functions_1.string_to_slug)((0, functions_1.translate)('fr', a.name)) })); })];
|
|
1363
|
-
case 3:
|
|
1364
|
-
error_7 = _a.sent();
|
|
1365
|
-
console.log('error fetch attributes: ', error_7);
|
|
1366
|
-
return [3, 4];
|
|
1367
|
-
case 4: return [2];
|
|
1368
|
-
}
|
|
1369
|
-
});
|
|
1370
|
-
}); };
|
|
1371
|
-
this.getCategories = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1372
|
-
var fetchData, resJson, error_8;
|
|
1373
|
-
return __generator(this, function (_a) {
|
|
1374
|
-
switch (_a.label) {
|
|
1375
|
-
case 0:
|
|
1376
|
-
_a.trys.push([0, 3, , 4]);
|
|
1377
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/categories"), {
|
|
1378
|
-
method: 'GET',
|
|
1379
|
-
headers: {
|
|
1380
|
-
authorization: "Bearer ".concat(this._token),
|
|
1381
|
-
'Content-Type': 'application/json'
|
|
1382
|
-
}
|
|
1383
|
-
})];
|
|
1384
|
-
case 1:
|
|
1385
|
-
fetchData = _a.sent();
|
|
1386
|
-
return [4, fetchData.json()];
|
|
1387
|
-
case 2:
|
|
1388
|
-
resJson = (_a.sent());
|
|
1389
|
-
return [2, resJson.data];
|
|
1390
|
-
case 3:
|
|
1391
|
-
error_8 = _a.sent();
|
|
1392
|
-
console.log('error fetch categories: ', error_8);
|
|
1393
|
-
return [3, 4];
|
|
1394
|
-
case 4: return [2];
|
|
1395
|
-
}
|
|
1396
|
-
});
|
|
1397
|
-
}); };
|
|
1398
|
-
this.getBrands = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1399
|
-
var fetchData, resJson, error_9;
|
|
1400
|
-
return __generator(this, function (_a) {
|
|
1401
|
-
switch (_a.label) {
|
|
1402
|
-
case 0:
|
|
1403
|
-
_a.trys.push([0, 3, , 4]);
|
|
1404
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/brands"), {
|
|
1405
|
-
method: 'GET',
|
|
1406
|
-
headers: {
|
|
1407
|
-
authorization: "Bearer ".concat(this._token),
|
|
1408
|
-
'Content-Type': 'application/json'
|
|
1409
|
-
}
|
|
1410
|
-
})];
|
|
1411
|
-
case 1:
|
|
1412
|
-
fetchData = _a.sent();
|
|
1413
|
-
return [4, fetchData.json()];
|
|
1414
|
-
case 2:
|
|
1415
|
-
resJson = (_a.sent());
|
|
1416
|
-
return [2, resJson.data];
|
|
1417
|
-
case 3:
|
|
1418
|
-
error_9 = _a.sent();
|
|
1419
|
-
console.log('error fetch brands: ', error_9);
|
|
1420
|
-
return [3, 4];
|
|
1421
|
-
case 4: return [2];
|
|
1422
|
-
}
|
|
1423
|
-
});
|
|
1424
|
-
}); };
|
|
1425
|
-
this.getInventoryItems = function (parentSlug) { return __awaiter(_this, void 0, void 0, function () {
|
|
1426
|
-
var fetchData, resJson, error_10;
|
|
1427
|
-
return __generator(this, function (_a) {
|
|
1428
|
-
switch (_a.label) {
|
|
1429
|
-
case 0:
|
|
1430
|
-
_a.trys.push([0, 3, , 4]);
|
|
1431
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/inventories").concat(!!parentSlug ? "/".concat(encodeURIComponent(parentSlug)) : ''), {
|
|
1432
|
-
method: 'GET',
|
|
1433
|
-
headers: {
|
|
1434
|
-
authorization: "Bearer ".concat(this._token),
|
|
1435
|
-
'Content-Type': 'application/json'
|
|
1436
|
-
}
|
|
1437
|
-
})];
|
|
1438
|
-
case 1:
|
|
1439
|
-
fetchData = _a.sent();
|
|
1440
|
-
return [4, fetchData.json()];
|
|
1441
|
-
case 2:
|
|
1442
|
-
resJson = (_a.sent());
|
|
1443
|
-
return [2, resJson.data];
|
|
1444
|
-
case 3:
|
|
1445
|
-
error_10 = _a.sent();
|
|
1446
|
-
console.log("error fetch inventory items".concat(!!parentSlug ? 'for parentSlug ' + parentSlug : '', ": "), error_10);
|
|
1447
|
-
return [3, 4];
|
|
1448
|
-
case 4: return [2];
|
|
1449
|
-
}
|
|
1450
|
-
});
|
|
1451
|
-
}); };
|
|
1452
|
-
this.getOneInventoryItem = function (sku) { return __awaiter(_this, void 0, void 0, function () {
|
|
1453
|
-
var fetchData, resJson, error_11;
|
|
1454
|
-
return __generator(this, function (_a) {
|
|
1455
|
-
switch (_a.label) {
|
|
1456
|
-
case 0:
|
|
1457
|
-
_a.trys.push([0, 3, , 4]);
|
|
1458
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/inventory/").concat(encodeURIComponent(sku)), {
|
|
1459
|
-
method: 'GET',
|
|
1460
|
-
headers: {
|
|
1461
|
-
authorization: "Bearer ".concat(this._token),
|
|
1462
|
-
'Content-Type': 'application/json'
|
|
1463
|
-
}
|
|
1464
|
-
})];
|
|
1465
|
-
case 1:
|
|
1466
|
-
fetchData = _a.sent();
|
|
1467
|
-
return [4, fetchData.json()];
|
|
1468
|
-
case 2:
|
|
1469
|
-
resJson = (_a.sent());
|
|
1470
|
-
return [2, resJson.data];
|
|
1471
|
-
case 3:
|
|
1472
|
-
error_11 = _a.sent();
|
|
1473
|
-
console.log("error fetch inventory item for sku: ".concat(sku), error_11);
|
|
1474
|
-
return [2, undefined];
|
|
1475
|
-
case 4: return [2];
|
|
1476
|
-
}
|
|
1477
|
-
});
|
|
1478
|
-
}); };
|
|
1479
|
-
this.getLatestProducts = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1480
|
-
var fetchData, resJson, error_12;
|
|
1481
|
-
return __generator(this, function (_a) {
|
|
1482
|
-
switch (_a.label) {
|
|
1483
|
-
case 0:
|
|
1484
|
-
_a.trys.push([0, 3, , 4]);
|
|
1485
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/latest_products"), {
|
|
1486
|
-
method: 'GET',
|
|
1487
|
-
headers: {
|
|
1488
|
-
authorization: "Bearer ".concat(this._token),
|
|
1489
|
-
'Content-Type': 'application/json'
|
|
1490
|
-
}
|
|
1491
|
-
})];
|
|
1492
|
-
case 1:
|
|
1493
|
-
fetchData = _a.sent();
|
|
1494
|
-
return [4, fetchData.json()];
|
|
1495
|
-
case 2:
|
|
1496
|
-
resJson = (_a.sent());
|
|
1497
|
-
return [2, resJson.data];
|
|
1498
|
-
case 3:
|
|
1499
|
-
error_12 = _a.sent();
|
|
1500
|
-
console.log("error fetching latest products", error_12);
|
|
1501
|
-
return [3, 4];
|
|
1502
|
-
case 4: return [2];
|
|
1503
|
-
}
|
|
907
|
+
this.getUpsellOfProducts = async (slugs, customPriceList) => {
|
|
908
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/products/getUpsellOfProductsWithProducts`, {
|
|
909
|
+
method: 'POST',
|
|
910
|
+
headers: {
|
|
911
|
+
Authorization: `Bearer ${this._token}`,
|
|
912
|
+
'Content-Type': 'application/json'
|
|
913
|
+
},
|
|
914
|
+
body: JSON.stringify(Object.assign({ slugs: slugs }, (!!customPriceList ? { customPriceList: customPriceList } : {})))
|
|
1504
915
|
});
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
return
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
916
|
+
const responseData = await fetchData.json();
|
|
917
|
+
if (responseData.status !== 200)
|
|
918
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
919
|
+
return responseData.data;
|
|
920
|
+
};
|
|
921
|
+
this.getAttributes = async () => {
|
|
922
|
+
try {
|
|
923
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/attributes`, {
|
|
924
|
+
method: 'GET',
|
|
925
|
+
headers: {
|
|
926
|
+
authorization: `Bearer ${this._token}`,
|
|
927
|
+
'Content-Type': 'application/json'
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
const resJson = await fetchData.json();
|
|
931
|
+
return resJson.data.map((a) => (Object.assign(Object.assign({}, a), { slug: !!a.slug ? a.slug : (0, functions_1.string_to_slug)((0, functions_1.translate)('fr', a.name)) })));
|
|
932
|
+
}
|
|
933
|
+
catch (error) {
|
|
934
|
+
console.log('error fetch attributes: ', error);
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
this.getCategories = async () => {
|
|
938
|
+
try {
|
|
939
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/categories`, {
|
|
940
|
+
method: 'GET',
|
|
941
|
+
headers: {
|
|
942
|
+
authorization: `Bearer ${this._token}`,
|
|
943
|
+
'Content-Type': 'application/json'
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
const resJson = (await fetchData.json());
|
|
947
|
+
return resJson.data;
|
|
948
|
+
}
|
|
949
|
+
catch (error) {
|
|
950
|
+
console.log('error fetch categories: ', error);
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
this.getBrands = async () => {
|
|
954
|
+
try {
|
|
955
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/brands`, {
|
|
956
|
+
method: 'GET',
|
|
957
|
+
headers: {
|
|
958
|
+
authorization: `Bearer ${this._token}`,
|
|
959
|
+
'Content-Type': 'application/json'
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
const resJson = (await fetchData.json());
|
|
963
|
+
return resJson.data;
|
|
964
|
+
}
|
|
965
|
+
catch (error) {
|
|
966
|
+
console.log('error fetch brands: ', error);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
this.getInventoryItems = async (parentSlug) => {
|
|
970
|
+
try {
|
|
971
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/inventories${!!parentSlug ? `/${encodeURIComponent(parentSlug)}` : ''}`, {
|
|
972
|
+
method: 'GET',
|
|
973
|
+
headers: {
|
|
974
|
+
authorization: `Bearer ${this._token}`,
|
|
975
|
+
'Content-Type': 'application/json'
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
const resJson = (await fetchData.json());
|
|
979
|
+
return resJson.data;
|
|
980
|
+
}
|
|
981
|
+
catch (error) {
|
|
982
|
+
console.log(`error fetch inventory items${!!parentSlug ? 'for parentSlug ' + parentSlug : ''}: `, error);
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
this.getOneInventoryItem = async (sku) => {
|
|
986
|
+
try {
|
|
987
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/inventory/${encodeURIComponent(sku)}`, {
|
|
988
|
+
method: 'GET',
|
|
989
|
+
headers: {
|
|
990
|
+
authorization: `Bearer ${this._token}`,
|
|
991
|
+
'Content-Type': 'application/json'
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
const resJson = (await fetchData.json());
|
|
995
|
+
return resJson.data;
|
|
996
|
+
}
|
|
997
|
+
catch (error) {
|
|
998
|
+
console.log(`error fetch inventory item for sku: ${sku}`, error);
|
|
999
|
+
return undefined;
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
this.getLatestProducts = async () => {
|
|
1003
|
+
try {
|
|
1004
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/latest_products`, {
|
|
1005
|
+
method: 'GET',
|
|
1006
|
+
headers: {
|
|
1007
|
+
authorization: `Bearer ${this._token}`,
|
|
1008
|
+
'Content-Type': 'application/json'
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
const resJson = (await fetchData.json());
|
|
1012
|
+
return resJson.data;
|
|
1013
|
+
}
|
|
1014
|
+
catch (error) {
|
|
1015
|
+
console.log(`error fetching latest products`, error);
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
this._getFees = async () => {
|
|
1019
|
+
try {
|
|
1020
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/products/getFees`, {
|
|
1021
|
+
method: 'GET',
|
|
1022
|
+
headers: {
|
|
1023
|
+
authorization: `Bearer ${this._token}`,
|
|
1024
|
+
'x-gng-ecomm-token': this._userToken
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
const resJson = (await fetchData.json());
|
|
1028
|
+
if (resJson.status !== 200) {
|
|
1029
|
+
console.log('error on fetching fees: ', !!resJson.error ? resJson.error.toString() : '');
|
|
1030
|
+
return [];
|
|
1534
1031
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1032
|
+
return resJson.data;
|
|
1033
|
+
}
|
|
1034
|
+
catch (error) {
|
|
1035
|
+
console.log(`error fetching fees`, error);
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1537
1038
|
this.products = {
|
|
1538
1039
|
getProducts: this.getProducts,
|
|
1539
1040
|
getProduct: this.getProduct,
|
|
@@ -1546,149 +1047,106 @@ var SDK = (function () {
|
|
|
1546
1047
|
getLatestProducts: this.getLatestProducts,
|
|
1547
1048
|
getFees: this._getFees
|
|
1548
1049
|
};
|
|
1549
|
-
this.getIfAddressIsInsideZones =
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
zone
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
for (_i = 0, zones_2 = zones; _i < zones_2.length; _i++) {
|
|
1579
|
-
zone_1 = zones_2[_i];
|
|
1580
|
-
polygon = new google_1.maps.Polygon({
|
|
1581
|
-
paths: zone_1.polygon.split(';').map(function (coords) { return ({
|
|
1582
|
-
lat: (0, lodash_1.toNumber)(coords.split(',')[1]),
|
|
1583
|
-
lng: (0, lodash_1.toNumber)(coords.split(',')[0])
|
|
1584
|
-
}); })
|
|
1585
|
-
});
|
|
1586
|
-
if (google_1.maps.geometry.poly.containsLocation({ lat: Number(lat), lng: Number(lng) }, polygon)) {
|
|
1587
|
-
insideZones.push(zone_1.slug);
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
return [2, insideZones];
|
|
1591
|
-
case 4:
|
|
1592
|
-
error_14 = _a.sent();
|
|
1593
|
-
if (!!window && !!window.RemoteLog) {
|
|
1594
|
-
;
|
|
1595
|
-
window.RemoteLog("error while fetching zones - ".concat(error_14.toString()), logs_1.LogType.ERROR);
|
|
1596
|
-
}
|
|
1597
|
-
console.log('error while fetching zones', error_14.toString());
|
|
1598
|
-
return [2, []];
|
|
1599
|
-
case 5: return [2];
|
|
1050
|
+
this.getIfAddressIsInsideZones = async (address) => {
|
|
1051
|
+
try {
|
|
1052
|
+
const userPos = await (0, zones_1.getPositionFromAddress)(address);
|
|
1053
|
+
if (!!!userPos)
|
|
1054
|
+
return [];
|
|
1055
|
+
const { lat, lng } = userPos;
|
|
1056
|
+
const zone = await (0, isomorphic_unfetch_1.default)(`${this._api}/shipping/zones`, {
|
|
1057
|
+
method: 'POST',
|
|
1058
|
+
headers: {
|
|
1059
|
+
authorization: `Bearer ${this._token}`,
|
|
1060
|
+
'Content-Type': 'application/json'
|
|
1061
|
+
},
|
|
1062
|
+
body: JSON.stringify({ address })
|
|
1063
|
+
});
|
|
1064
|
+
if (zone.status !== 200)
|
|
1065
|
+
return [];
|
|
1066
|
+
const { zones } = (await zone.json()).data;
|
|
1067
|
+
const google = window.google;
|
|
1068
|
+
const insideZones = [];
|
|
1069
|
+
for (const zone of zones) {
|
|
1070
|
+
const polygon = new google.maps.Polygon({
|
|
1071
|
+
paths: zone.polygon.split(';').map((coords) => ({
|
|
1072
|
+
lat: (0, lodash_1.toNumber)(coords.split(',')[1]),
|
|
1073
|
+
lng: (0, lodash_1.toNumber)(coords.split(',')[0])
|
|
1074
|
+
}))
|
|
1075
|
+
});
|
|
1076
|
+
if (google.maps.geometry.poly.containsLocation({ lat: Number(lat), lng: Number(lng) }, polygon)) {
|
|
1077
|
+
insideZones.push(zone.slug);
|
|
1078
|
+
}
|
|
1600
1079
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
case 0:
|
|
1608
|
-
_a.trys.push([0, 3, , 4]);
|
|
1609
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/services/pricing/byQuery"), {
|
|
1610
|
-
method: 'POST',
|
|
1611
|
-
headers: {
|
|
1612
|
-
authorization: "Bearer ".concat(this._token),
|
|
1613
|
-
'Content-Type': 'application/json'
|
|
1614
|
-
},
|
|
1615
|
-
body: JSON.stringify({ query: query })
|
|
1616
|
-
})];
|
|
1617
|
-
case 1:
|
|
1618
|
-
fetchData = _a.sent();
|
|
1619
|
-
return [4, fetchData.json()];
|
|
1620
|
-
case 2:
|
|
1621
|
-
resJson = _a.sent();
|
|
1622
|
-
return [2, resJson.data];
|
|
1623
|
-
case 3:
|
|
1624
|
-
error_15 = _a.sent();
|
|
1625
|
-
throw error_15;
|
|
1626
|
-
case 4: return [2];
|
|
1080
|
+
return insideZones;
|
|
1081
|
+
}
|
|
1082
|
+
catch (error) {
|
|
1083
|
+
if (!!window && !!window.RemoteLog) {
|
|
1084
|
+
;
|
|
1085
|
+
window.RemoteLog(`error while fetching zones - ${error.toString()}`, logs_1.LogType.ERROR);
|
|
1627
1086
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1087
|
+
console.log('error while fetching zones', error.toString());
|
|
1088
|
+
return [];
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
this._pricingByQuery = async (query) => {
|
|
1092
|
+
try {
|
|
1093
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/services/pricing/byQuery`, {
|
|
1094
|
+
method: 'POST',
|
|
1095
|
+
headers: {
|
|
1096
|
+
authorization: `Bearer ${this._token}`,
|
|
1097
|
+
'Content-Type': 'application/json'
|
|
1098
|
+
},
|
|
1099
|
+
body: JSON.stringify({ query })
|
|
1100
|
+
});
|
|
1101
|
+
const resJson = await fetchData.json();
|
|
1102
|
+
return resJson.data;
|
|
1103
|
+
}
|
|
1104
|
+
catch (error) {
|
|
1105
|
+
throw error;
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
this._buyFromForm = async (form) => {
|
|
1109
|
+
try {
|
|
1110
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/services/buy/fromForm`, {
|
|
1111
|
+
method: 'POST',
|
|
1112
|
+
headers: {
|
|
1113
|
+
authorization: `Bearer ${this._token}`,
|
|
1114
|
+
'Content-Type': 'application/json'
|
|
1115
|
+
},
|
|
1116
|
+
body: JSON.stringify(form)
|
|
1117
|
+
});
|
|
1118
|
+
const resJson = await fetchData.json();
|
|
1119
|
+
if (!!resJson.error) {
|
|
1120
|
+
return false;
|
|
1657
1121
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
case 2:
|
|
1677
|
-
resJson = _a.sent();
|
|
1678
|
-
if (!!resJson.error) {
|
|
1679
|
-
return [2, []];
|
|
1680
|
-
}
|
|
1681
|
-
space = resJson.data;
|
|
1682
|
-
if (!!!space || !!!space._space)
|
|
1683
|
-
return [2, []];
|
|
1684
|
-
return [2, space._space.external_services.filter(function (s) { return s.type === 'index'; })];
|
|
1685
|
-
case 3:
|
|
1686
|
-
error_17 = _a.sent();
|
|
1687
|
-
throw error_17;
|
|
1688
|
-
case 4: return [2];
|
|
1122
|
+
return true;
|
|
1123
|
+
}
|
|
1124
|
+
catch (error) {
|
|
1125
|
+
throw error;
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
this._getSearchServices = async () => {
|
|
1129
|
+
try {
|
|
1130
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/space`, {
|
|
1131
|
+
method: 'GET',
|
|
1132
|
+
headers: {
|
|
1133
|
+
authorization: `Bearer ${this._token}`,
|
|
1134
|
+
'Content-Type': 'application/json'
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
const resJson = await fetchData.json();
|
|
1138
|
+
if (!!resJson.error) {
|
|
1139
|
+
return [];
|
|
1689
1140
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1141
|
+
const space = resJson.data;
|
|
1142
|
+
if (!!!space || !!!space._space)
|
|
1143
|
+
return [];
|
|
1144
|
+
return space._space.external_services.filter((s) => s.type === 'index');
|
|
1145
|
+
}
|
|
1146
|
+
catch (error) {
|
|
1147
|
+
throw error;
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1692
1150
|
this.services = {
|
|
1693
1151
|
pricingByQuery: this._pricingByQuery,
|
|
1694
1152
|
buy: {
|
|
@@ -1696,113 +1154,75 @@ var SDK = (function () {
|
|
|
1696
1154
|
},
|
|
1697
1155
|
searchServices: this._getSearchServices
|
|
1698
1156
|
};
|
|
1699
|
-
this._getAllCatalogues =
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
headers: {
|
|
1706
|
-
Authorization: "Bearer ".concat(this._token),
|
|
1707
|
-
'x-gng-ecomm-locale': locale
|
|
1708
|
-
}
|
|
1709
|
-
})];
|
|
1710
|
-
case 1:
|
|
1711
|
-
fetchData = _a.sent();
|
|
1712
|
-
return [4, fetchData.json()];
|
|
1713
|
-
case 2:
|
|
1714
|
-
responseData = _a.sent();
|
|
1715
|
-
if (responseData.status !== 200)
|
|
1716
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1717
|
-
return [2, responseData.data.filter(function (catalogue) { return !!!catalogue.draft; })];
|
|
1157
|
+
this._getAllCatalogues = async (locale) => {
|
|
1158
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/catalogues`, {
|
|
1159
|
+
method: 'GET',
|
|
1160
|
+
headers: {
|
|
1161
|
+
Authorization: `Bearer ${this._token}`,
|
|
1162
|
+
'x-gng-ecomm-locale': locale
|
|
1718
1163
|
}
|
|
1719
1164
|
});
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
return
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
})];
|
|
1732
|
-
case 1:
|
|
1733
|
-
fetchData = _a.sent();
|
|
1734
|
-
return [4, fetchData.json()];
|
|
1735
|
-
case 2:
|
|
1736
|
-
responseData = _a.sent();
|
|
1737
|
-
if (responseData.status !== 200)
|
|
1738
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1739
|
-
return [2, responseData.data];
|
|
1165
|
+
const responseData = await fetchData.json();
|
|
1166
|
+
if (responseData.status !== 200)
|
|
1167
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1168
|
+
return responseData.data.filter((catalogue) => !!!catalogue.draft);
|
|
1169
|
+
};
|
|
1170
|
+
this._getCatalogueBySlug = async (slug, locale) => {
|
|
1171
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/catalogues/${slug}`, {
|
|
1172
|
+
method: 'GET',
|
|
1173
|
+
headers: {
|
|
1174
|
+
Authorization: `Bearer ${this._token}`,
|
|
1175
|
+
'x-gng-ecomm-locale': locale
|
|
1740
1176
|
}
|
|
1741
1177
|
});
|
|
1742
|
-
|
|
1178
|
+
const responseData = await fetchData.json();
|
|
1179
|
+
if (responseData.status !== 200)
|
|
1180
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1181
|
+
return responseData.data;
|
|
1182
|
+
};
|
|
1743
1183
|
this.catalogues = {
|
|
1744
1184
|
getAll: this._getAllCatalogues,
|
|
1745
1185
|
getOne: this._getCatalogueBySlug
|
|
1746
1186
|
};
|
|
1747
|
-
this.saveCustomerToMailchimpList =
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
authorization: "Bearer ".concat(this._token),
|
|
1787
|
-
'Content-Type': 'application/json'
|
|
1788
|
-
}
|
|
1789
|
-
})];
|
|
1790
|
-
case 1:
|
|
1791
|
-
fetchData = _a.sent();
|
|
1792
|
-
return [4, fetchData.json()];
|
|
1793
|
-
case 2:
|
|
1794
|
-
result = _a.sent();
|
|
1795
|
-
if (!!fetchData.status && fetchData.status !== 200)
|
|
1796
|
-
throw "".concat(result.data);
|
|
1797
|
-
return [2, result.data];
|
|
1798
|
-
case 3:
|
|
1799
|
-
e_10 = _a.sent();
|
|
1800
|
-
console.log('error fetching sitemap data: ', e_10.toString());
|
|
1801
|
-
return [2, e_10.toString()];
|
|
1802
|
-
case 4: return [2];
|
|
1803
|
-
}
|
|
1804
|
-
});
|
|
1805
|
-
}); };
|
|
1187
|
+
this.saveCustomerToMailchimpList = async (customerEmail, listID, mergeFields, tags) => {
|
|
1188
|
+
try {
|
|
1189
|
+
const saved = await (0, isomorphic_unfetch_1.default)(`${this._api}/marketing/mailchimp/updateOrCreateCustomer`, {
|
|
1190
|
+
method: 'POST',
|
|
1191
|
+
headers: {
|
|
1192
|
+
Authorization: `Bearer ${this._token}`,
|
|
1193
|
+
'Content-Type': 'application/json'
|
|
1194
|
+
},
|
|
1195
|
+
body: JSON.stringify(Object.assign(Object.assign({ email: customerEmail, listID: listID }, (!!mergeFields ? { mergeFields: mergeFields } : {})), (!!tags ? { tags: tags } : {})))
|
|
1196
|
+
});
|
|
1197
|
+
const responseData = await saved.json();
|
|
1198
|
+
if (responseData.status !== 200)
|
|
1199
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1200
|
+
return true;
|
|
1201
|
+
}
|
|
1202
|
+
catch (e) {
|
|
1203
|
+
console.log('error on saving customer to mailchimp list: ', e.toString());
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
this.getProductListForSitemap = async () => {
|
|
1208
|
+
try {
|
|
1209
|
+
const fetchData = await (0, isomorphic_unfetch_1.default)(`${this._api}/analytics/sitmap_data`, {
|
|
1210
|
+
method: 'GET',
|
|
1211
|
+
headers: {
|
|
1212
|
+
authorization: `Bearer ${this._token}`,
|
|
1213
|
+
'Content-Type': 'application/json'
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
const result = await fetchData.json();
|
|
1217
|
+
if (!!fetchData.status && fetchData.status !== 200)
|
|
1218
|
+
throw `${result.data}`;
|
|
1219
|
+
return result.data;
|
|
1220
|
+
}
|
|
1221
|
+
catch (e) {
|
|
1222
|
+
console.log('error fetching sitemap data: ', e.toString());
|
|
1223
|
+
return e.toString();
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1806
1226
|
this._api = '';
|
|
1807
1227
|
this._imgPath = '';
|
|
1808
1228
|
this._token = '';
|
|
@@ -1813,7 +1233,6 @@ var SDK = (function () {
|
|
|
1813
1233
|
this._wishlist = null;
|
|
1814
1234
|
this._stockNotif = null;
|
|
1815
1235
|
}
|
|
1816
|
-
|
|
1817
|
-
}());
|
|
1236
|
+
}
|
|
1818
1237
|
exports.default = SDK;
|
|
1819
1238
|
//# sourceMappingURL=index.js.map
|