addio-ecomm-sdk 1.3.74 → 1.3.75
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/.vscode/settings.json +34 -34
- package/README.md +79 -79
- package/dist/index.d.ts +202 -202
- package/dist/index.js +1818 -1818
- package/dist/index.js.map +1 -1
- package/dist/lib/constants/components/CreditCardInput.d.ts +11 -11
- package/dist/lib/constants/components/CreditCardInput.js +79 -79
- package/dist/lib/constants/components/Snackbar.d.ts +11 -11
- package/dist/lib/constants/components/Snackbar.js +39 -39
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.js +980 -980
- package/dist/lib/constants/contexts/CartContext/index.d.ts +79 -79
- package/dist/lib/constants/contexts/CartContext/index.js +127 -127
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.d.ts +15 -15
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.js +304 -304
- package/dist/lib/constants/contexts/DataContext/index.d.ts +47 -47
- package/dist/lib/constants/contexts/DataContext/index.js +67 -67
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.d.ts +6 -6
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.js +103 -103
- package/dist/lib/constants/contexts/LogContext/index.d.ts +7 -7
- package/dist/lib/constants/contexts/LogContext/index.js +45 -45
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.js +76 -76
- package/dist/lib/constants/contexts/ModalContext/index.d.ts +14 -14
- package/dist/lib/constants/contexts/ModalContext/index.js +18 -18
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.d.ts +8 -8
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.js +79 -79
- package/dist/lib/constants/contexts/SDKContext/index.d.ts +4 -4
- package/dist/lib/constants/contexts/SDKContext/index.js +4 -4
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.d.ts +4 -4
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.js +6 -6
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.d.ts +12 -12
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.js +52 -52
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.d.ts +17 -17
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.js +21 -21
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.js +179 -179
- package/dist/lib/constants/contexts/StockNotifContext/index.d.ts +10 -10
- package/dist/lib/constants/contexts/StockNotifContext/index.js +10 -10
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.d.ts +5 -5
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.js +470 -470
- package/dist/lib/constants/contexts/UserContext/index.d.ts +54 -54
- package/dist/lib/constants/contexts/UserContext/index.js +82 -82
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.d.ts +6 -6
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.js +327 -327
- package/dist/lib/constants/contexts/WishlistContext/index.d.ts +12 -12
- package/dist/lib/constants/contexts/WishlistContext/index.js +12 -12
- package/dist/lib/constants/hooks/useCart.d.ts +2 -2
- package/dist/lib/constants/hooks/useCart.js +11 -11
- package/dist/lib/constants/hooks/useData.d.ts +2 -2
- package/dist/lib/constants/hooks/useData.js +11 -11
- package/dist/lib/constants/hooks/useLogs.d.ts +2 -2
- package/dist/lib/constants/hooks/useLogs.js +11 -11
- package/dist/lib/constants/hooks/useModal.d.ts +2 -2
- package/dist/lib/constants/hooks/useModal.js +11 -11
- package/dist/lib/constants/hooks/useSDK.d.ts +2 -2
- package/dist/lib/constants/hooks/useSDK.js +11 -11
- package/dist/lib/constants/hooks/useSnackbar.d.ts +2 -2
- package/dist/lib/constants/hooks/useSnackbar.js +11 -11
- package/dist/lib/constants/hooks/useStockNotif.d.ts +2 -2
- package/dist/lib/constants/hooks/useStockNotif.js +11 -11
- package/dist/lib/constants/hooks/useUser.d.ts +2 -2
- package/dist/lib/constants/hooks/useUser.js +11 -11
- package/dist/lib/constants/hooks/useWishlist.d.ts +2 -2
- package/dist/lib/constants/hooks/useWishlist.js +11 -11
- package/dist/lib/models/image/index.d.ts +6 -6
- package/dist/lib/models/image/index.js +15 -15
- package/dist/lib/models/stockNotification/index.d.ts +13 -13
- package/dist/lib/models/stockNotification/index.js +130 -130
- package/dist/lib/models/wishlist/index.d.ts +14 -14
- package/dist/lib/models/wishlist/index.js +155 -155
- package/dist/utils/StripeErrors.d.ts +24 -24
- package/dist/utils/StripeErrors.js +55 -55
- package/dist/utils/algolia.d.ts +3 -3
- package/dist/utils/algolia.js +81 -81
- package/dist/utils/analytics.d.ts +71 -71
- package/dist/utils/analytics.js +257 -257
- package/dist/utils/cart.d.ts +3 -3
- package/dist/utils/cart.js +66 -66
- package/dist/utils/contentful.d.ts +10 -10
- package/dist/utils/contentful.js +136 -136
- package/dist/utils/functions.d.ts +21 -21
- package/dist/utils/functions.js +200 -200
- package/dist/utils/getSDK.d.ts +4 -4
- package/dist/utils/getSDK.js +77 -77
- package/dist/utils/initStoreData.d.ts +3 -3
- package/dist/utils/initStoreData.js +62 -62
- package/dist/utils/interfaces/IClientCMSData.d.ts +132 -132
- package/dist/utils/interfaces/IClientCMSData.js +2 -2
- package/dist/utils/interfaces/IEndpointResult.d.ts +10 -10
- package/dist/utils/interfaces/IEndpointResult.js +2 -2
- package/dist/utils/interfaces/IFacebookUserProfile.d.ts +10 -10
- package/dist/utils/interfaces/IFacebookUserProfile.js +2 -2
- package/dist/utils/interfaces/IFilter.d.ts +23 -23
- package/dist/utils/interfaces/IFilter.js +2 -2
- package/dist/utils/interfaces/IGoogleUserProfile.d.ts +7 -7
- package/dist/utils/interfaces/IGoogleUserProfile.js +2 -2
- package/dist/utils/interfaces/ISDKConfig.d.ts +7 -7
- package/dist/utils/interfaces/ISDKConfig.js +2 -2
- package/dist/utils/interfaces/ISpaceData.d.ts +18 -18
- package/dist/utils/interfaces/ISpaceData.js +2 -2
- package/dist/utils/larivieremeunier.d.ts +3 -3
- package/dist/utils/larivieremeunier.js +156 -156
- package/dist/utils/technosupply.d.ts +3 -3
- package/dist/utils/technosupply.js +155 -155
- package/package.json +61 -61
- package/publish.sh +132 -132
package/dist/index.js
CHANGED
|
@@ -1,1819 +1,1819 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
-
var t = {};
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
-
t[p] = s[p];
|
|
53
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
-
t[p[i]] = s[p[i]];
|
|
57
|
-
}
|
|
58
|
-
return t;
|
|
59
|
-
};
|
|
60
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
-
};
|
|
63
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
-
var isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
|
|
65
|
-
var image_1 = __importDefault(require("./lib/models/image"));
|
|
66
|
-
var wishlist_1 = __importDefault(require("./lib/models/wishlist"));
|
|
67
|
-
var stockNotification_1 = __importDefault(require("./lib/models/stockNotification"));
|
|
68
|
-
var Product_1 = __importDefault(require("addio-admin-sdk/dist/lib/Product"));
|
|
69
|
-
var js_cookie_1 = __importDefault(require("js-cookie"));
|
|
70
|
-
var g2_1 = require("addio-admin-sdk/dist/rules/GR/utils/g2");
|
|
71
|
-
var anonymisation_1 = require("addio-admin-sdk/dist/utils/anonymisation");
|
|
72
|
-
var functions_1 = require("./utils/functions");
|
|
73
|
-
var zones_1 = require("addio-admin-sdk/dist/utils/zones");
|
|
74
|
-
var lodash_1 = require("lodash");
|
|
75
|
-
var functions_2 = require("./utils/functions");
|
|
76
|
-
var data_1 = require("addio-admin-sdk/dist/utils/data");
|
|
77
|
-
var moment_1 = __importDefault(require("moment"));
|
|
78
|
-
var object_1 = require("addio-admin-sdk/dist/utils/object");
|
|
79
|
-
var services_1 = require("addio-admin-sdk/dist/utils/services");
|
|
80
|
-
var logs_1 = require("addio-admin-sdk/dist/services/logs");
|
|
81
|
-
var SDK = (function () {
|
|
82
|
-
function SDK() {
|
|
83
|
-
var _this = this;
|
|
84
|
-
this.init = function (sdk_config) { return __awaiter(_this, void 0, void 0, function () {
|
|
85
|
-
return __generator(this, function (_a) {
|
|
86
|
-
this._api = sdk_config.api;
|
|
87
|
-
this._token = sdk_config.token;
|
|
88
|
-
this._url = sdk_config.url;
|
|
89
|
-
this._org = sdk_config.org;
|
|
90
|
-
this._userToken = !!sdk_config.userToken ? sdk_config.userToken : '';
|
|
91
|
-
this._storeData = null;
|
|
92
|
-
return [2];
|
|
93
|
-
});
|
|
94
|
-
}); };
|
|
95
|
-
this.getAPIInfos = function () { return ({
|
|
96
|
-
api: _this._api,
|
|
97
|
-
token: _this._token,
|
|
98
|
-
userToken: _this._userToken,
|
|
99
|
-
org: _this._org
|
|
100
|
-
}); };
|
|
101
|
-
this.getSDKOrgInitials = function () {
|
|
102
|
-
var orgID = _this.getAPIInfos().org;
|
|
103
|
-
if (!!!orgID)
|
|
104
|
-
return '';
|
|
105
|
-
if (orgID.length <= 3)
|
|
106
|
-
return orgID.toUpperCase();
|
|
107
|
-
return (0, services_1.getOrgInitialsByID)(orgID);
|
|
108
|
-
};
|
|
109
|
-
this.initWishlist = function (wishlist) { return __awaiter(_this, void 0, void 0, function () {
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
this._wishlist = new wishlist_1.default(wishlist, this._api, this._token, this._userToken, this.setUserToken);
|
|
114
|
-
return [4, this._wishlist.getFromDatabase(wishlist)];
|
|
115
|
-
case 1: return [2, _a.sent()];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}); };
|
|
119
|
-
this.initStockNotif = function (stockNotif) { return __awaiter(_this, void 0, void 0, function () {
|
|
120
|
-
return __generator(this, function (_a) {
|
|
121
|
-
switch (_a.label) {
|
|
122
|
-
case 0:
|
|
123
|
-
this._stockNotif = new stockNotification_1.default(stockNotif, this._api, this._token, this._userToken, this.setUserToken);
|
|
124
|
-
return [4, this._stockNotif.getFromDatabase(stockNotif)];
|
|
125
|
-
case 1: return [2, _a.sent()];
|
|
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];
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}); };
|
|
158
|
-
this.shouldShowFixedPromoBanner = function (fixedPromoBannerData) {
|
|
159
|
-
if (!!!fixedPromoBannerData.is_active) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
if (!!fixedPromoBannerData.active_between_dates && !!fixedPromoBannerData.active_between_dates.length) {
|
|
163
|
-
var date = fixedPromoBannerData.active_between_dates.some(function (date) {
|
|
164
|
-
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
|
-
});
|
|
166
|
-
return !!date;
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
169
|
-
};
|
|
170
|
-
this.getInventoryItem = function (sku, locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
171
|
-
var fetchData, responseData;
|
|
172
|
-
return __generator(this, function (_a) {
|
|
173
|
-
switch (_a.label) {
|
|
174
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/inventory/").concat(encodeURIComponent(sku)), {
|
|
175
|
-
method: 'GET',
|
|
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];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}); };
|
|
192
|
-
this.getFullInventory = function (locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
193
|
-
var fetchData, responseData;
|
|
194
|
-
return __generator(this, function (_a) {
|
|
195
|
-
switch (_a.label) {
|
|
196
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/inventory"), {
|
|
197
|
-
method: 'GET',
|
|
198
|
-
headers: {
|
|
199
|
-
Authorization: "Bearer ".concat(this._token),
|
|
200
|
-
'x-gng-ecomm-locale': locale
|
|
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];
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}); };
|
|
214
|
-
this.inventory = {
|
|
215
|
-
getFullInventory: this.getFullInventory,
|
|
216
|
-
getInventoryItem: this.getInventoryItem
|
|
217
|
-
};
|
|
218
|
-
this.setUserToken = function (token) {
|
|
219
|
-
_this._userToken = token;
|
|
220
|
-
localStorage.setItem('userToken', token);
|
|
221
|
-
js_cookie_1.default.set('userToken', token, { sameSite: 'strict', secure: true });
|
|
222
|
-
};
|
|
223
|
-
this.loginUserWithFacebook = function (fb) { return __awaiter(_this, void 0, void 0, function () {
|
|
224
|
-
var email, id, name, fetchData, responseData;
|
|
225
|
-
return __generator(this, function (_a) {
|
|
226
|
-
switch (_a.label) {
|
|
227
|
-
case 0:
|
|
228
|
-
email = fb.email, id = fb.id, name = fb.name;
|
|
229
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/signinwithfacebook"), {
|
|
230
|
-
method: 'POST',
|
|
231
|
-
headers: {
|
|
232
|
-
authorization: "Bearer ".concat(this._token),
|
|
233
|
-
'Content-Type': 'application/json'
|
|
234
|
-
},
|
|
235
|
-
body: JSON.stringify({ email: email, userID: id, name: name })
|
|
236
|
-
})];
|
|
237
|
-
case 1:
|
|
238
|
-
fetchData = _a.sent();
|
|
239
|
-
return [4, fetchData.json()];
|
|
240
|
-
case 2:
|
|
241
|
-
responseData = _a.sent();
|
|
242
|
-
if (responseData.status !== 200) {
|
|
243
|
-
throw { status: responseData.status, error: responseData.error };
|
|
244
|
-
}
|
|
245
|
-
try {
|
|
246
|
-
if (!!!responseData.data.userData) {
|
|
247
|
-
throw {
|
|
248
|
-
status: responseData.status,
|
|
249
|
-
error: 'user_not_found'
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
if (!!responseData.data.cartData) {
|
|
253
|
-
localStorage.setItem("".concat(this._org, "__cart"), responseData.data.cartData.id);
|
|
254
|
-
}
|
|
255
|
-
if (responseData.token)
|
|
256
|
-
this.setUserToken(responseData.token);
|
|
257
|
-
return [2, { userData: responseData.data.userData, cart: responseData.data.cartData }];
|
|
258
|
-
}
|
|
259
|
-
catch (err) {
|
|
260
|
-
return [2, err.toString()];
|
|
261
|
-
}
|
|
262
|
-
return [2];
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}); };
|
|
266
|
-
this.anonymousResetPassword = function (locale, id, oldPassword, newPassword, confirmPassword) { return __awaiter(_this, void 0, void 0, function () {
|
|
267
|
-
var fetchData, responseData, error_1;
|
|
268
|
-
return __generator(this, function (_a) {
|
|
269
|
-
switch (_a.label) {
|
|
270
|
-
case 0:
|
|
271
|
-
_a.trys.push([0, 3, , 4]);
|
|
272
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/anonymousResetPassword"), {
|
|
273
|
-
method: 'POST',
|
|
274
|
-
headers: {
|
|
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];
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
}); };
|
|
306
|
-
this.loginUser = function (locale, email, password, keepCart, isClerk) {
|
|
307
|
-
if (keepCart === void 0) { keepCart = false; }
|
|
308
|
-
if (isClerk === void 0) { isClerk = false; }
|
|
309
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
310
|
-
var fetchData, responseData, cartData, shouldResetCartData, currentCartInLocalStorage;
|
|
311
|
-
return __generator(this, function (_a) {
|
|
312
|
-
switch (_a.label) {
|
|
313
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/signin"), {
|
|
314
|
-
method: 'POST',
|
|
315
|
-
headers: {
|
|
316
|
-
authorization: "Bearer ".concat(this._token),
|
|
317
|
-
'Content-Type': 'application/json',
|
|
318
|
-
'x-gng-ecomm-locale': locale
|
|
319
|
-
},
|
|
320
|
-
body: JSON.stringify({ email: email, password: password, isClerk: isClerk })
|
|
321
|
-
})];
|
|
322
|
-
case 1:
|
|
323
|
-
fetchData = _a.sent();
|
|
324
|
-
return [4, fetchData.json()];
|
|
325
|
-
case 2:
|
|
326
|
-
responseData = _a.sent();
|
|
327
|
-
if (responseData.status !== 200) {
|
|
328
|
-
throw { status: responseData.status, error: responseData.error };
|
|
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];
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
};
|
|
358
|
-
this.loginUserWithID = function (locale, id, password, keepCart, isClerk) {
|
|
359
|
-
if (keepCart === void 0) { keepCart = false; }
|
|
360
|
-
if (isClerk === void 0) { isClerk = false; }
|
|
361
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
362
|
-
var fetchData, responseData, currentCartInLocalStorage;
|
|
363
|
-
return __generator(this, function (_a) {
|
|
364
|
-
switch (_a.label) {
|
|
365
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/signinwithid"), {
|
|
366
|
-
method: 'POST',
|
|
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
|
-
}
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
this.checkG2ForCustomer = function (id, currentCustomer, customerGroups) { return __awaiter(_this, void 0, void 0, function () {
|
|
400
|
-
var fetchData, G2RequestRes, allG2Customers, customerToCheck, customerToCreate, anonymizedCustomer, e_1;
|
|
401
|
-
return __generator(this, function (_a) {
|
|
402
|
-
switch (_a.label) {
|
|
403
|
-
case 0:
|
|
404
|
-
_a.trys.push([0, 3, , 4]);
|
|
405
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/services/g2/customers/").concat(id), {
|
|
406
|
-
method: 'GET',
|
|
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];
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
this.validateAccount = function (code) { return __awaiter(_this, void 0, void 0, function () {
|
|
503
|
-
var fetchData, responseData;
|
|
504
|
-
return __generator(this, function (_a) {
|
|
505
|
-
switch (_a.label) {
|
|
506
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/validateEmail"), {
|
|
507
|
-
method: 'POST',
|
|
508
|
-
headers: {
|
|
509
|
-
authorization: "Bearer ".concat(this._token),
|
|
510
|
-
'Content-Type': 'application/json',
|
|
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
|
-
}
|
|
530
|
-
});
|
|
531
|
-
}); };
|
|
532
|
-
this.logout = function () {
|
|
533
|
-
_this.setUserToken('');
|
|
534
|
-
localStorage.removeItem("".concat(_this._org, "__cart"));
|
|
535
|
-
localStorage.removeItem('userLogged');
|
|
536
|
-
localStorage.removeItem('isPro');
|
|
537
|
-
localStorage.removeItem('foundInG2');
|
|
538
|
-
localStorage.removeItem('customPriceList');
|
|
539
|
-
localStorage.removeItem('lastCustomPriceFetch');
|
|
540
|
-
localStorage.removeItem('userToken');
|
|
541
|
-
localStorage.removeItem('wishlist');
|
|
542
|
-
localStorage.removeItem('stockNotification');
|
|
543
|
-
js_cookie_1.default.remove('userToken', { expires: new Date(0) });
|
|
544
|
-
};
|
|
545
|
-
this.registerUser = function (locale, userData, password) { return __awaiter(_this, void 0, void 0, function () {
|
|
546
|
-
var fetchData, responseData;
|
|
547
|
-
return __generator(this, function (_a) {
|
|
548
|
-
switch (_a.label) {
|
|
549
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/register"), {
|
|
550
|
-
method: 'PUT',
|
|
551
|
-
headers: {
|
|
552
|
-
Authorization: "Bearer ".concat(this._token),
|
|
553
|
-
'Content-Type': 'application/json',
|
|
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
|
-
}
|
|
605
|
-
});
|
|
606
|
-
}); };
|
|
607
|
-
this.saveUser = function (userData) { return __awaiter(_this, void 0, void 0, function () {
|
|
608
|
-
var fetchData, responseData;
|
|
609
|
-
return __generator(this, function (_a) {
|
|
610
|
-
switch (_a.label) {
|
|
611
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/save"), {
|
|
612
|
-
method: 'POST',
|
|
613
|
-
headers: {
|
|
614
|
-
authorization: "Bearer ".concat(this._token),
|
|
615
|
-
'Content-Type': 'application/json',
|
|
616
|
-
'x-gng-ecomm-token': this._userToken
|
|
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];
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
}); };
|
|
637
|
-
this.deleteUser = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
638
|
-
var fetchData, responseData;
|
|
639
|
-
return __generator(this, function (_a) {
|
|
640
|
-
switch (_a.label) {
|
|
641
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/delete"), {
|
|
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];
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
}); };
|
|
660
|
-
this.getOrders = function (lastID, iteration) { return __awaiter(_this, void 0, void 0, function () {
|
|
661
|
-
var queryString, fetchData, responseData;
|
|
662
|
-
return __generator(this, function (_a) {
|
|
663
|
-
switch (_a.label) {
|
|
664
|
-
case 0:
|
|
665
|
-
queryString = "?fromLastID=".concat(lastID !== null && lastID !== void 0 ? lastID : '', "&skip=").concat(iteration !== null && iteration !== void 0 ? iteration : '');
|
|
666
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/orders").concat(queryString), {
|
|
667
|
-
method: 'GET',
|
|
668
|
-
headers: {
|
|
669
|
-
authorization: "Bearer ".concat(this._token),
|
|
670
|
-
'Content-Type': 'application/json',
|
|
671
|
-
'x-gng-ecomm-token': this._userToken
|
|
672
|
-
}
|
|
673
|
-
})];
|
|
674
|
-
case 1:
|
|
675
|
-
fetchData = _a.sent();
|
|
676
|
-
return [4, fetchData.json()];
|
|
677
|
-
case 2:
|
|
678
|
-
responseData = (_a.sent());
|
|
679
|
-
if (responseData.status !== 200) {
|
|
680
|
-
return [2, responseData.data];
|
|
681
|
-
}
|
|
682
|
-
return [2, responseData.data];
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
}); };
|
|
686
|
-
this.killRepCart = function (hashed_cart_id) { return __awaiter(_this, void 0, void 0, function () {
|
|
687
|
-
var fetchData, responseData, error_2;
|
|
688
|
-
return __generator(this, function (_a) {
|
|
689
|
-
switch (_a.label) {
|
|
690
|
-
case 0:
|
|
691
|
-
_a.trys.push([0, 3, , 4]);
|
|
692
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/killRepCart/").concat(encodeURIComponent(hashed_cart_id)), {
|
|
693
|
-
method: 'GET',
|
|
694
|
-
headers: {
|
|
695
|
-
authorization: "Bearer ".concat(this._token),
|
|
696
|
-
'Content-Type': 'application/json',
|
|
697
|
-
'x-gng-ecomm-token': this._userToken
|
|
698
|
-
}
|
|
699
|
-
})];
|
|
700
|
-
case 1:
|
|
701
|
-
fetchData = _a.sent();
|
|
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];
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
}); };
|
|
717
|
-
this.getOrder = function (orderID, token) { return __awaiter(_this, void 0, void 0, function () {
|
|
718
|
-
var fetchData, responseData, error_3;
|
|
719
|
-
return __generator(this, function (_a) {
|
|
720
|
-
switch (_a.label) {
|
|
721
|
-
case 0:
|
|
722
|
-
_a.trys.push([0, 3, , 4]);
|
|
723
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/order/").concat(orderID), {
|
|
724
|
-
method: 'POST',
|
|
725
|
-
headers: {
|
|
726
|
-
authorization: "Bearer ".concat(this._token),
|
|
727
|
-
'Content-Type': 'application/json',
|
|
728
|
-
'x-gng-ecomm-token': this._userToken
|
|
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];
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
}); };
|
|
749
|
-
this.changeProfilePicture = function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
750
|
-
var fetchData, responseData;
|
|
751
|
-
return __generator(this, function (_a) {
|
|
752
|
-
switch (_a.label) {
|
|
753
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/changeProfilePicture"), {
|
|
754
|
-
method: 'POST',
|
|
755
|
-
headers: {
|
|
756
|
-
authorization: "Bearer ".concat(this._token),
|
|
757
|
-
'Content-Type': 'application/json',
|
|
758
|
-
'x-gng-ecomm-token': this._userToken
|
|
759
|
-
},
|
|
760
|
-
body: JSON.stringify({
|
|
761
|
-
file: file
|
|
762
|
-
})
|
|
763
|
-
})];
|
|
764
|
-
case 1:
|
|
765
|
-
fetchData = _a.sent();
|
|
766
|
-
return [4, fetchData.json()];
|
|
767
|
-
case 2:
|
|
768
|
-
responseData = (_a.sent());
|
|
769
|
-
return [2, responseData.data];
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
}); };
|
|
773
|
-
this.changePassword = function (currentPassword, newPassword) { return __awaiter(_this, void 0, void 0, function () {
|
|
774
|
-
var fetchData, responseData;
|
|
775
|
-
return __generator(this, function (_a) {
|
|
776
|
-
switch (_a.label) {
|
|
777
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/changePassword"), {
|
|
778
|
-
method: 'POST',
|
|
779
|
-
headers: {
|
|
780
|
-
authorization: "Bearer ".concat(this._token),
|
|
781
|
-
'Content-Type': 'application/json',
|
|
782
|
-
'x-gng-ecomm-token': this._userToken
|
|
783
|
-
},
|
|
784
|
-
body: JSON.stringify({ currentPassword: currentPassword, newPassword: newPassword })
|
|
785
|
-
})];
|
|
786
|
-
case 1:
|
|
787
|
-
fetchData = _a.sent();
|
|
788
|
-
return [4, fetchData.json()];
|
|
789
|
-
case 2:
|
|
790
|
-
responseData = (_a.sent());
|
|
791
|
-
if (responseData.status === 200)
|
|
792
|
-
return [2, responseData.data];
|
|
793
|
-
return [2, responseData.error];
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
}); };
|
|
797
|
-
this.sendResetPasswordEmail = function (locale, userEmail, forPro, withEmail, isTest) { return __awaiter(_this, void 0, void 0, function () {
|
|
798
|
-
var fetchData, responseData;
|
|
799
|
-
return __generator(this, function (_a) {
|
|
800
|
-
switch (_a.label) {
|
|
801
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/sentForgotPasswordEmail"), {
|
|
802
|
-
method: 'POST',
|
|
803
|
-
headers: {
|
|
804
|
-
authorization: "Bearer ".concat(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({ 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
|
-
}
|
|
825
|
-
});
|
|
826
|
-
}); };
|
|
827
|
-
this.sendApplicationEmail = function (locale, form) { return __awaiter(_this, void 0, void 0, function () {
|
|
828
|
-
var cvBase64, fetchData, responseData, error_4;
|
|
829
|
-
return __generator(this, function (_a) {
|
|
830
|
-
switch (_a.label) {
|
|
831
|
-
case 0:
|
|
832
|
-
_a.trys.push([0, 4, , 5]);
|
|
833
|
-
if (!!!form.cv)
|
|
834
|
-
return [2, {
|
|
835
|
-
error: "Couldn't find cv"
|
|
836
|
-
}];
|
|
837
|
-
return [4, (0, functions_2.toBase64)(form.cv)];
|
|
838
|
-
case 1:
|
|
839
|
-
cvBase64 = _a.sent();
|
|
840
|
-
if (typeof cvBase64 !== 'string') {
|
|
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
|
-
}
|
|
868
|
-
});
|
|
869
|
-
}); };
|
|
870
|
-
this.sendContactEmail = function (locale, form) { return __awaiter(_this, void 0, void 0, function () {
|
|
871
|
-
var fetchData, responseData;
|
|
872
|
-
return __generator(this, function (_a) {
|
|
873
|
-
switch (_a.label) {
|
|
874
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendContactEmail"), {
|
|
875
|
-
method: 'POST',
|
|
876
|
-
headers: {
|
|
877
|
-
authorization: "Bearer ".concat(this._token),
|
|
878
|
-
'Content-Type': 'application/json',
|
|
879
|
-
'x-gng-ecomm-token': this._userToken,
|
|
880
|
-
'x-gng-ecomm-locale': locale
|
|
881
|
-
},
|
|
882
|
-
body: JSON.stringify(form)
|
|
883
|
-
})];
|
|
884
|
-
case 1:
|
|
885
|
-
fetchData = _a.sent();
|
|
886
|
-
return [4, fetchData.json()];
|
|
887
|
-
case 2:
|
|
888
|
-
responseData = (_a.sent());
|
|
889
|
-
if (responseData.status === 200)
|
|
890
|
-
return [2, responseData.data];
|
|
891
|
-
return [2, responseData.error];
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
}); };
|
|
895
|
-
this.sendGenericOtherEmail = function (locale, form, templateId, to, replyTo) { return __awaiter(_this, void 0, void 0, function () {
|
|
896
|
-
var getSubjectByType, fetchData, responseData, error_5;
|
|
897
|
-
return __generator(this, function (_a) {
|
|
898
|
-
switch (_a.label) {
|
|
899
|
-
case 0:
|
|
900
|
-
getSubjectByType = function (type) {
|
|
901
|
-
switch (type) {
|
|
902
|
-
case 'confirmation_lawn_submission':
|
|
903
|
-
return { fr: 'Soumission gazon - Confirmation de réception', en: 'Lawn submission - Confirmation' };
|
|
904
|
-
default:
|
|
905
|
-
return undefined;
|
|
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];
|
|
934
|
-
}
|
|
935
|
-
});
|
|
936
|
-
}); };
|
|
937
|
-
this.sendServicePageEmail = function (locale, form, type, testEmail) { return __awaiter(_this, void 0, void 0, function () {
|
|
938
|
-
var attachments, rest, updatedAttachments, _i, _a, att, cvBase64, e_4, getSubjectByType, fetchData, responseData, e_5;
|
|
939
|
-
return __generator(this, function (_b) {
|
|
940
|
-
switch (_b.label) {
|
|
941
|
-
case 0:
|
|
942
|
-
attachments = form.attachments, rest = __rest(form, ["attachments"]);
|
|
943
|
-
updatedAttachments = [];
|
|
944
|
-
if (!!!attachments) return [3, 6];
|
|
945
|
-
_i = 0, _a = attachments;
|
|
946
|
-
_b.label = 1;
|
|
947
|
-
case 1:
|
|
948
|
-
if (!(_i < _a.length)) return [3, 6];
|
|
949
|
-
att = _a[_i];
|
|
950
|
-
_b.label = 2;
|
|
951
|
-
case 2:
|
|
952
|
-
_b.trys.push([2, 4, , 5]);
|
|
953
|
-
return [4, (0, functions_2.toBase64)(att)];
|
|
954
|
-
case 3:
|
|
955
|
-
cvBase64 = _b.sent();
|
|
956
|
-
updatedAttachments.push({ name: att.name, content: cvBase64 });
|
|
957
|
-
return [3, 5];
|
|
958
|
-
case 4:
|
|
959
|
-
e_4 = _b.sent();
|
|
960
|
-
console.log('error on converting to base64: ', e_4);
|
|
961
|
-
return [3, 5];
|
|
962
|
-
case 5:
|
|
963
|
-
_i++;
|
|
964
|
-
return [3, 1];
|
|
965
|
-
case 6:
|
|
966
|
-
getSubjectByType = function () {
|
|
967
|
-
switch (type) {
|
|
968
|
-
case 'admin_3D_plans':
|
|
969
|
-
if (!!form.project_type && form.project_type === 'conception') {
|
|
970
|
-
return { fr: 'Conception de plans - Nouvelle demande', en: 'Project design - new request' };
|
|
971
|
-
}
|
|
972
|
-
else {
|
|
973
|
-
return { fr: 'Images 3D - Nouvelle demande', en: '3D plans - new request' };
|
|
974
|
-
}
|
|
975
|
-
case 'admin_vegetals':
|
|
976
|
-
return { fr: 'Commande de végétaux - nouvelle soumission', en: 'Vegetals - new quotation' };
|
|
977
|
-
case 'admin_pickup_on_site':
|
|
978
|
-
return { fr: 'Ramassage sur chantier - nouvelle demande', en: 'Pickup on site - new request' };
|
|
979
|
-
case 'admin_borrow_tools':
|
|
980
|
-
return { fr: "Location d'outils - nouvelle demande", en: 'Rent tools - new request' };
|
|
981
|
-
case 'admin_sales_info':
|
|
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
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
_b.label = 7;
|
|
1011
|
-
case 7:
|
|
1012
|
-
_b.trys.push([7, 10, , 11]);
|
|
1013
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendServiceStaticPageEmail"), {
|
|
1014
|
-
method: 'POST',
|
|
1015
|
-
headers: {
|
|
1016
|
-
authorization: "Bearer ".concat(this._token),
|
|
1017
|
-
'Content-Type': 'application/json',
|
|
1018
|
-
'x-gng-ecomm-token': this._userToken,
|
|
1019
|
-
'x-gng-ecomm-locale': locale
|
|
1020
|
-
},
|
|
1021
|
-
body: JSON.stringify(__assign(__assign(__assign(__assign({}, rest), (!!updatedAttachments && !!updatedAttachments.length ? { attachments: updatedAttachments } : {})), { subject: getSubjectByType(), title: getSubjectByType(), type: type }), (!!testEmail ? { test_email: testEmail } : {})))
|
|
1022
|
-
})];
|
|
1023
|
-
case 8:
|
|
1024
|
-
fetchData = _b.sent();
|
|
1025
|
-
return [4, fetchData.json()];
|
|
1026
|
-
case 9:
|
|
1027
|
-
responseData = (_b.sent());
|
|
1028
|
-
if (responseData.status === 200)
|
|
1029
|
-
return [2, true];
|
|
1030
|
-
return [2, responseData.error];
|
|
1031
|
-
case 10:
|
|
1032
|
-
e_5 = _b.sent();
|
|
1033
|
-
console.log('error on calling api: ', e_5);
|
|
1034
|
-
if (!!updatedAttachments) {
|
|
1035
|
-
return [2, {
|
|
1036
|
-
status: 413,
|
|
1037
|
-
error: {
|
|
1038
|
-
fr: "Vos pièces jointes n'ont pas pu être envoyées. Veuillez réessayer.",
|
|
1039
|
-
en: 'Your attachments could not be sent. Please try again.'
|
|
1040
|
-
}
|
|
1041
|
-
}];
|
|
1042
|
-
}
|
|
1043
|
-
return [2, ''];
|
|
1044
|
-
case 11: return [2];
|
|
1045
|
-
}
|
|
1046
|
-
});
|
|
1047
|
-
}); };
|
|
1048
|
-
this.sendSponsorRequestEmail = function (locale, form, template_name) { return __awaiter(_this, void 0, void 0, function () {
|
|
1049
|
-
var plan, rest, updatedPlan, planBase64, splitString, e_6, fetchData, responseData;
|
|
1050
|
-
return __generator(this, function (_a) {
|
|
1051
|
-
switch (_a.label) {
|
|
1052
|
-
case 0:
|
|
1053
|
-
plan = form.plan, rest = __rest(form, ["plan"]);
|
|
1054
|
-
if (!!!plan) return [3, 4];
|
|
1055
|
-
_a.label = 1;
|
|
1056
|
-
case 1:
|
|
1057
|
-
_a.trys.push([1, 3, , 4]);
|
|
1058
|
-
return [4, (0, functions_2.toBase64)(plan)];
|
|
1059
|
-
case 2:
|
|
1060
|
-
planBase64 = _a.sent();
|
|
1061
|
-
if (typeof planBase64 === 'string') {
|
|
1062
|
-
splitString = planBase64.split(';base64,');
|
|
1063
|
-
if (!!splitString.length && !!splitString[1]) {
|
|
1064
|
-
updatedPlan = {
|
|
1065
|
-
name: plan.name,
|
|
1066
|
-
content: splitString[1]
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
return [3, 4];
|
|
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];
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
|
-
}); };
|
|
1103
|
-
this.sendPreMeetingFormEmail = function (locale, form, proId) { return __awaiter(_this, void 0, void 0, function () {
|
|
1104
|
-
var attachments, rest, _a, pro_logo, restProInfos, updatedAttachments, updatedLogo, _i, _b, att, cvBase64, e_7, logoBase64, e_8, fetchData, responseData;
|
|
1105
|
-
return __generator(this, function (_c) {
|
|
1106
|
-
switch (_c.label) {
|
|
1107
|
-
case 0:
|
|
1108
|
-
attachments = form.attachments, rest = __rest(form, ["attachments"]);
|
|
1109
|
-
_a = rest.pro_infos, pro_logo = _a.pro_logo, restProInfos = __rest(_a, ["pro_logo"]);
|
|
1110
|
-
updatedAttachments = [];
|
|
1111
|
-
updatedLogo = '';
|
|
1112
|
-
if (!!!attachments) return [3, 6];
|
|
1113
|
-
_i = 0, _b = attachments;
|
|
1114
|
-
_c.label = 1;
|
|
1115
|
-
case 1:
|
|
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();
|
|
1124
|
-
updatedAttachments.push({ name: att.name, content: cvBase64 });
|
|
1125
|
-
return [3, 5];
|
|
1126
|
-
case 4:
|
|
1127
|
-
e_7 = _c.sent();
|
|
1128
|
-
console.log('error on converting to base64: ', e_7);
|
|
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];
|
|
1165
|
-
}
|
|
1166
|
-
});
|
|
1167
|
-
}); };
|
|
1168
|
-
this.sendWishlistByEmail = function (locale, contenu, template_name) { return __awaiter(_this, void 0, void 0, function () {
|
|
1169
|
-
var fetchData, responseData;
|
|
1170
|
-
return __generator(this, function (_a) {
|
|
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];
|
|
1190
|
-
}
|
|
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];
|
|
1219
|
-
}
|
|
1220
|
-
});
|
|
1221
|
-
}); };
|
|
1222
|
-
this.user = {
|
|
1223
|
-
getUser: this.getUser,
|
|
1224
|
-
saveUser: this.saveUser,
|
|
1225
|
-
deleteUser: this.deleteUser,
|
|
1226
|
-
loginUser: this.loginUser,
|
|
1227
|
-
loginUserWithID: this.loginUserWithID,
|
|
1228
|
-
loginUserWithFacebook: this.loginUserWithFacebook,
|
|
1229
|
-
logout: this.logout,
|
|
1230
|
-
registerUser: this.registerUser,
|
|
1231
|
-
killRepCart: this.killRepCart,
|
|
1232
|
-
getOrder: this.getOrder,
|
|
1233
|
-
getOrders: this.getOrders,
|
|
1234
|
-
changePassword: this.changePassword,
|
|
1235
|
-
changeProfilePicture: this.changeProfilePicture,
|
|
1236
|
-
validateAccount: this.validateAccount,
|
|
1237
|
-
sendResetPasswordEmail: this.sendResetPasswordEmail,
|
|
1238
|
-
resetPassword: this.resetPassword,
|
|
1239
|
-
sendApplicationEmail: this.sendApplicationEmail,
|
|
1240
|
-
sendContactEmail: this.sendContactEmail,
|
|
1241
|
-
sendServiceEmail: this.sendServicePageEmail,
|
|
1242
|
-
anonymousResetPassword: this.anonymousResetPassword,
|
|
1243
|
-
checkG2: this.checkG2ForCustomer,
|
|
1244
|
-
createPro: this.createProCustomer,
|
|
1245
|
-
fetchCustomPriceList: this.fetchCustomPriceList
|
|
1246
|
-
};
|
|
1247
|
-
this.getImage = function (imgName, formatQuery, addImgPath) {
|
|
1248
|
-
if (addImgPath === void 0) { addImgPath = false; }
|
|
1249
|
-
var img = new image_1.default("".concat(addImgPath ? _this._imgPath : '').concat(_this._imgPath, "/").concat(imgName));
|
|
1250
|
-
return img.getFileDownloadUrl(formatQuery);
|
|
1251
|
-
};
|
|
1252
|
-
this.getProducts = function (page, hpp, query, filters, indice, f, useProspr) {
|
|
1253
|
-
if (page === void 0) { page = 0; }
|
|
1254
|
-
if (hpp === void 0) { hpp = 10; }
|
|
1255
|
-
if (query === void 0) { query = ''; }
|
|
1256
|
-
if (filters === void 0) { filters = ''; }
|
|
1257
|
-
if (indice === void 0) { indice = 'products'; }
|
|
1258
|
-
if (f === void 0) { f = ''; }
|
|
1259
|
-
if (useProspr === void 0) { useProspr = false; }
|
|
1260
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
1261
|
-
var error_6;
|
|
1262
|
-
return __generator(this, function (_a) {
|
|
1263
|
-
switch (_a.label) {
|
|
1264
|
-
case 0:
|
|
1265
|
-
_a.trys.push([0, 2, , 3]);
|
|
1266
|
-
return [4, Product_1.default.fetch({
|
|
1267
|
-
app: process.env.NEXT_PUBLIC_ALGOLIA_APP,
|
|
1268
|
-
api: process.env.NEXT_PUBLIC_ALGOLIA_TOKEN,
|
|
1269
|
-
page: page,
|
|
1270
|
-
hpp: hpp,
|
|
1271
|
-
query: query,
|
|
1272
|
-
filters: filters,
|
|
1273
|
-
indice: indice || 'products',
|
|
1274
|
-
f: f,
|
|
1275
|
-
useProspr: useProspr,
|
|
1276
|
-
space: undefined
|
|
1277
|
-
})];
|
|
1278
|
-
case 1: return [2, _a.sent()];
|
|
1279
|
-
case 2:
|
|
1280
|
-
error_6 = _a.sent();
|
|
1281
|
-
throw error_6;
|
|
1282
|
-
case 3: return [2];
|
|
1283
|
-
}
|
|
1284
|
-
});
|
|
1285
|
-
});
|
|
1286
|
-
};
|
|
1287
|
-
this.getProduct = function (
|
|
1288
|
-
var prod, fetchData, responseData;
|
|
1289
|
-
return __generator(this, function (_a) {
|
|
1290
|
-
switch (_a.label) {
|
|
1291
|
-
case 0:
|
|
1292
|
-
prod = undefined;
|
|
1293
|
-
if (!!useProdArray && !!useProdArray.length) {
|
|
1294
|
-
prod = useProdArray.find(function (fee) { return fee.slug ===
|
|
1295
|
-
}
|
|
1296
|
-
if (!!!!prod) return [3, 3];
|
|
1297
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/products/").concat(encodeURIComponent(
|
|
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
|
-
}
|
|
1504
|
-
});
|
|
1505
|
-
}); };
|
|
1506
|
-
this._getFees = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1507
|
-
var fetchData, resJson, error_13;
|
|
1508
|
-
return __generator(this, function (_a) {
|
|
1509
|
-
switch (_a.label) {
|
|
1510
|
-
case 0:
|
|
1511
|
-
_a.trys.push([0, 3, , 4]);
|
|
1512
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/products/getFees"), {
|
|
1513
|
-
method: 'GET',
|
|
1514
|
-
headers: {
|
|
1515
|
-
authorization: "Bearer ".concat(this._token),
|
|
1516
|
-
'x-gng-ecomm-token': this._userToken
|
|
1517
|
-
}
|
|
1518
|
-
})];
|
|
1519
|
-
case 1:
|
|
1520
|
-
fetchData = _a.sent();
|
|
1521
|
-
return [4, fetchData.json()];
|
|
1522
|
-
case 2:
|
|
1523
|
-
resJson = (_a.sent());
|
|
1524
|
-
if (resJson.status !== 200) {
|
|
1525
|
-
console.log('error on fetching fees: ', !!resJson.error ? resJson.error.toString() : '');
|
|
1526
|
-
return [2, []];
|
|
1527
|
-
}
|
|
1528
|
-
return [2, resJson.data];
|
|
1529
|
-
case 3:
|
|
1530
|
-
error_13 = _a.sent();
|
|
1531
|
-
console.log("error fetching fees", error_13);
|
|
1532
|
-
return [3, 4];
|
|
1533
|
-
case 4: return [2];
|
|
1534
|
-
}
|
|
1535
|
-
});
|
|
1536
|
-
}); };
|
|
1537
|
-
this.products = {
|
|
1538
|
-
getProducts: this.getProducts,
|
|
1539
|
-
getProduct: this.getProduct,
|
|
1540
|
-
getUpsellOfProducts: this.getUpsellOfProducts,
|
|
1541
|
-
getAttributes: this.getAttributes,
|
|
1542
|
-
getCategories: this.getCategories,
|
|
1543
|
-
getBrands: this.getBrands,
|
|
1544
|
-
getInventoryItems: this.getInventoryItems,
|
|
1545
|
-
getOneInventoryItem: this.getOneInventoryItem,
|
|
1546
|
-
getLatestProducts: this.getLatestProducts,
|
|
1547
|
-
getFees: this._getFees
|
|
1548
|
-
};
|
|
1549
|
-
this.getIfAddressIsInsideZones = function (address) { return __awaiter(_this, void 0, void 0, function () {
|
|
1550
|
-
var userPos, lat, lng, zone, zones, google_1, insideZones, _i, zones_2, zone_1, polygon, error_14;
|
|
1551
|
-
return __generator(this, function (_a) {
|
|
1552
|
-
switch (_a.label) {
|
|
1553
|
-
case 0:
|
|
1554
|
-
_a.trys.push([0, 4, , 5]);
|
|
1555
|
-
return [4, (0, zones_1.getPositionFromAddress)(address)];
|
|
1556
|
-
case 1:
|
|
1557
|
-
userPos = _a.sent();
|
|
1558
|
-
if (!!!userPos)
|
|
1559
|
-
return [2, []];
|
|
1560
|
-
lat = userPos.lat, lng = userPos.lng;
|
|
1561
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/shipping/zones"), {
|
|
1562
|
-
method: 'POST',
|
|
1563
|
-
headers: {
|
|
1564
|
-
authorization: "Bearer ".concat(this._token),
|
|
1565
|
-
'Content-Type': 'application/json'
|
|
1566
|
-
},
|
|
1567
|
-
body: JSON.stringify({ address: address })
|
|
1568
|
-
})];
|
|
1569
|
-
case 2:
|
|
1570
|
-
zone = _a.sent();
|
|
1571
|
-
if (zone.status !== 200)
|
|
1572
|
-
return [2, []];
|
|
1573
|
-
return [4, zone.json()];
|
|
1574
|
-
case 3:
|
|
1575
|
-
zones = (_a.sent()).data.zones;
|
|
1576
|
-
google_1 = window.google;
|
|
1577
|
-
insideZones = [];
|
|
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];
|
|
1600
|
-
}
|
|
1601
|
-
});
|
|
1602
|
-
}); };
|
|
1603
|
-
this._pricingByQuery = function (query) { return __awaiter(_this, void 0, void 0, function () {
|
|
1604
|
-
var fetchData, resJson, error_15;
|
|
1605
|
-
return __generator(this, function (_a) {
|
|
1606
|
-
switch (_a.label) {
|
|
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];
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
}); };
|
|
1630
|
-
this._buyFromForm = function (form) { return __awaiter(_this, void 0, void 0, function () {
|
|
1631
|
-
var fetchData, resJson, error_16;
|
|
1632
|
-
return __generator(this, function (_a) {
|
|
1633
|
-
switch (_a.label) {
|
|
1634
|
-
case 0:
|
|
1635
|
-
_a.trys.push([0, 3, , 4]);
|
|
1636
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/services/buy/fromForm"), {
|
|
1637
|
-
method: 'POST',
|
|
1638
|
-
headers: {
|
|
1639
|
-
authorization: "Bearer ".concat(this._token),
|
|
1640
|
-
'Content-Type': 'application/json'
|
|
1641
|
-
},
|
|
1642
|
-
body: JSON.stringify(form)
|
|
1643
|
-
})];
|
|
1644
|
-
case 1:
|
|
1645
|
-
fetchData = _a.sent();
|
|
1646
|
-
return [4, fetchData.json()];
|
|
1647
|
-
case 2:
|
|
1648
|
-
resJson = _a.sent();
|
|
1649
|
-
if (!!resJson.error) {
|
|
1650
|
-
return [2, false];
|
|
1651
|
-
}
|
|
1652
|
-
return [2, true];
|
|
1653
|
-
case 3:
|
|
1654
|
-
error_16 = _a.sent();
|
|
1655
|
-
throw error_16;
|
|
1656
|
-
case 4: return [2];
|
|
1657
|
-
}
|
|
1658
|
-
});
|
|
1659
|
-
}); };
|
|
1660
|
-
this._getSearchServices = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1661
|
-
var fetchData, resJson, space, error_17;
|
|
1662
|
-
return __generator(this, function (_a) {
|
|
1663
|
-
switch (_a.label) {
|
|
1664
|
-
case 0:
|
|
1665
|
-
_a.trys.push([0, 3, , 4]);
|
|
1666
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/space"), {
|
|
1667
|
-
method: 'GET',
|
|
1668
|
-
headers: {
|
|
1669
|
-
authorization: "Bearer ".concat(this._token),
|
|
1670
|
-
'Content-Type': 'application/json'
|
|
1671
|
-
}
|
|
1672
|
-
})];
|
|
1673
|
-
case 1:
|
|
1674
|
-
fetchData = _a.sent();
|
|
1675
|
-
return [4, fetchData.json()];
|
|
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];
|
|
1689
|
-
}
|
|
1690
|
-
});
|
|
1691
|
-
}); };
|
|
1692
|
-
this.services = {
|
|
1693
|
-
pricingByQuery: this._pricingByQuery,
|
|
1694
|
-
buy: {
|
|
1695
|
-
fromForm: this._buyFromForm
|
|
1696
|
-
},
|
|
1697
|
-
searchServices: this._getSearchServices
|
|
1698
|
-
};
|
|
1699
|
-
this._getAllCatalogues = function (locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
1700
|
-
var fetchData, responseData;
|
|
1701
|
-
return __generator(this, function (_a) {
|
|
1702
|
-
switch (_a.label) {
|
|
1703
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/catalogues"), {
|
|
1704
|
-
method: 'GET',
|
|
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; })];
|
|
1718
|
-
}
|
|
1719
|
-
});
|
|
1720
|
-
}); };
|
|
1721
|
-
this._getCatalogueBySlug = function (slug, locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
1722
|
-
var fetchData, responseData;
|
|
1723
|
-
return __generator(this, function (_a) {
|
|
1724
|
-
switch (_a.label) {
|
|
1725
|
-
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/catalogues/").concat(slug), {
|
|
1726
|
-
method: 'GET',
|
|
1727
|
-
headers: {
|
|
1728
|
-
Authorization: "Bearer ".concat(this._token),
|
|
1729
|
-
'x-gng-ecomm-locale': locale
|
|
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];
|
|
1740
|
-
}
|
|
1741
|
-
});
|
|
1742
|
-
}); };
|
|
1743
|
-
this.catalogues = {
|
|
1744
|
-
getAll: this._getAllCatalogues,
|
|
1745
|
-
getOne: this._getCatalogueBySlug
|
|
1746
|
-
};
|
|
1747
|
-
this.saveCustomerToMailchimpList = function (customerEmail, listID, mergeFields, tags) { return __awaiter(_this, void 0, void 0, function () {
|
|
1748
|
-
var saved, responseData, e_9;
|
|
1749
|
-
return __generator(this, function (_a) {
|
|
1750
|
-
switch (_a.label) {
|
|
1751
|
-
case 0:
|
|
1752
|
-
_a.trys.push([0, 3, , 4]);
|
|
1753
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/marketing/mailchimp/updateOrCreateCustomer"), {
|
|
1754
|
-
method: 'POST',
|
|
1755
|
-
headers: {
|
|
1756
|
-
Authorization: "Bearer ".concat(this._token),
|
|
1757
|
-
'Content-Type': 'application/json'
|
|
1758
|
-
},
|
|
1759
|
-
body: JSON.stringify(__assign(__assign({ email: customerEmail, listID: listID }, (!!mergeFields ? { mergeFields: mergeFields } : {})), (!!tags ? { tags: tags } : {})))
|
|
1760
|
-
})];
|
|
1761
|
-
case 1:
|
|
1762
|
-
saved = _a.sent();
|
|
1763
|
-
return [4, saved.json()];
|
|
1764
|
-
case 2:
|
|
1765
|
-
responseData = _a.sent();
|
|
1766
|
-
if (responseData.status !== 200)
|
|
1767
|
-
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1768
|
-
return [2, true];
|
|
1769
|
-
case 3:
|
|
1770
|
-
e_9 = _a.sent();
|
|
1771
|
-
console.log('error on saving customer to mailchimp list: ', e_9.toString());
|
|
1772
|
-
return [2, false];
|
|
1773
|
-
case 4: return [2];
|
|
1774
|
-
}
|
|
1775
|
-
});
|
|
1776
|
-
}); };
|
|
1777
|
-
this.getProductListForSitemap = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1778
|
-
var fetchData, result, e_10;
|
|
1779
|
-
return __generator(this, function (_a) {
|
|
1780
|
-
switch (_a.label) {
|
|
1781
|
-
case 0:
|
|
1782
|
-
_a.trys.push([0, 3, , 4]);
|
|
1783
|
-
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/analytics/sitmap_data"), {
|
|
1784
|
-
method: 'GET',
|
|
1785
|
-
headers: {
|
|
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
|
-
}); };
|
|
1806
|
-
this._api = '';
|
|
1807
|
-
this._imgPath = '';
|
|
1808
|
-
this._token = '';
|
|
1809
|
-
this._userToken = '';
|
|
1810
|
-
this._url = '';
|
|
1811
|
-
this._org = '';
|
|
1812
|
-
this._storeData = null;
|
|
1813
|
-
this._wishlist = null;
|
|
1814
|
-
this._stockNotif = null;
|
|
1815
|
-
}
|
|
1816
|
-
return SDK;
|
|
1817
|
-
}());
|
|
1818
|
-
exports.default = SDK;
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
+
};
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
var isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
|
|
65
|
+
var image_1 = __importDefault(require("./lib/models/image"));
|
|
66
|
+
var wishlist_1 = __importDefault(require("./lib/models/wishlist"));
|
|
67
|
+
var stockNotification_1 = __importDefault(require("./lib/models/stockNotification"));
|
|
68
|
+
var Product_1 = __importDefault(require("addio-admin-sdk/dist/lib/Product"));
|
|
69
|
+
var js_cookie_1 = __importDefault(require("js-cookie"));
|
|
70
|
+
var g2_1 = require("addio-admin-sdk/dist/rules/GR/utils/g2");
|
|
71
|
+
var anonymisation_1 = require("addio-admin-sdk/dist/utils/anonymisation");
|
|
72
|
+
var functions_1 = require("./utils/functions");
|
|
73
|
+
var zones_1 = require("addio-admin-sdk/dist/utils/zones");
|
|
74
|
+
var lodash_1 = require("lodash");
|
|
75
|
+
var functions_2 = require("./utils/functions");
|
|
76
|
+
var data_1 = require("addio-admin-sdk/dist/utils/data");
|
|
77
|
+
var moment_1 = __importDefault(require("moment"));
|
|
78
|
+
var object_1 = require("addio-admin-sdk/dist/utils/object");
|
|
79
|
+
var services_1 = require("addio-admin-sdk/dist/utils/services");
|
|
80
|
+
var logs_1 = require("addio-admin-sdk/dist/services/logs");
|
|
81
|
+
var SDK = (function () {
|
|
82
|
+
function SDK() {
|
|
83
|
+
var _this = this;
|
|
84
|
+
this.init = function (sdk_config) { return __awaiter(_this, void 0, void 0, function () {
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
this._api = sdk_config.api;
|
|
87
|
+
this._token = sdk_config.token;
|
|
88
|
+
this._url = sdk_config.url;
|
|
89
|
+
this._org = sdk_config.org;
|
|
90
|
+
this._userToken = !!sdk_config.userToken ? sdk_config.userToken : '';
|
|
91
|
+
this._storeData = null;
|
|
92
|
+
return [2];
|
|
93
|
+
});
|
|
94
|
+
}); };
|
|
95
|
+
this.getAPIInfos = function () { return ({
|
|
96
|
+
api: _this._api,
|
|
97
|
+
token: _this._token,
|
|
98
|
+
userToken: _this._userToken,
|
|
99
|
+
org: _this._org
|
|
100
|
+
}); };
|
|
101
|
+
this.getSDKOrgInitials = function () {
|
|
102
|
+
var orgID = _this.getAPIInfos().org;
|
|
103
|
+
if (!!!orgID)
|
|
104
|
+
return '';
|
|
105
|
+
if (orgID.length <= 3)
|
|
106
|
+
return orgID.toUpperCase();
|
|
107
|
+
return (0, services_1.getOrgInitialsByID)(orgID);
|
|
108
|
+
};
|
|
109
|
+
this.initWishlist = function (wishlist) { return __awaiter(_this, void 0, void 0, function () {
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
this._wishlist = new wishlist_1.default(wishlist, this._api, this._token, this._userToken, this.setUserToken);
|
|
114
|
+
return [4, this._wishlist.getFromDatabase(wishlist)];
|
|
115
|
+
case 1: return [2, _a.sent()];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}); };
|
|
119
|
+
this.initStockNotif = function (stockNotif) { return __awaiter(_this, void 0, void 0, function () {
|
|
120
|
+
return __generator(this, function (_a) {
|
|
121
|
+
switch (_a.label) {
|
|
122
|
+
case 0:
|
|
123
|
+
this._stockNotif = new stockNotification_1.default(stockNotif, this._api, this._token, this._userToken, this.setUserToken);
|
|
124
|
+
return [4, this._stockNotif.getFromDatabase(stockNotif)];
|
|
125
|
+
case 1: return [2, _a.sent()];
|
|
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];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); };
|
|
158
|
+
this.shouldShowFixedPromoBanner = function (fixedPromoBannerData) {
|
|
159
|
+
if (!!!fixedPromoBannerData.is_active) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
if (!!fixedPromoBannerData.active_between_dates && !!fixedPromoBannerData.active_between_dates.length) {
|
|
163
|
+
var date = fixedPromoBannerData.active_between_dates.some(function (date) {
|
|
164
|
+
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
|
+
});
|
|
166
|
+
return !!date;
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
};
|
|
170
|
+
this.getInventoryItem = function (sku, locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
171
|
+
var fetchData, responseData;
|
|
172
|
+
return __generator(this, function (_a) {
|
|
173
|
+
switch (_a.label) {
|
|
174
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/inventory/").concat(encodeURIComponent(sku)), {
|
|
175
|
+
method: 'GET',
|
|
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];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}); };
|
|
192
|
+
this.getFullInventory = function (locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
193
|
+
var fetchData, responseData;
|
|
194
|
+
return __generator(this, function (_a) {
|
|
195
|
+
switch (_a.label) {
|
|
196
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/inventory"), {
|
|
197
|
+
method: 'GET',
|
|
198
|
+
headers: {
|
|
199
|
+
Authorization: "Bearer ".concat(this._token),
|
|
200
|
+
'x-gng-ecomm-locale': locale
|
|
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];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}); };
|
|
214
|
+
this.inventory = {
|
|
215
|
+
getFullInventory: this.getFullInventory,
|
|
216
|
+
getInventoryItem: this.getInventoryItem
|
|
217
|
+
};
|
|
218
|
+
this.setUserToken = function (token) {
|
|
219
|
+
_this._userToken = token;
|
|
220
|
+
localStorage.setItem('userToken', token);
|
|
221
|
+
js_cookie_1.default.set('userToken', token, { sameSite: 'strict', secure: true });
|
|
222
|
+
};
|
|
223
|
+
this.loginUserWithFacebook = function (fb) { return __awaiter(_this, void 0, void 0, function () {
|
|
224
|
+
var email, id, name, fetchData, responseData;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0:
|
|
228
|
+
email = fb.email, id = fb.id, name = fb.name;
|
|
229
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/signinwithfacebook"), {
|
|
230
|
+
method: 'POST',
|
|
231
|
+
headers: {
|
|
232
|
+
authorization: "Bearer ".concat(this._token),
|
|
233
|
+
'Content-Type': 'application/json'
|
|
234
|
+
},
|
|
235
|
+
body: JSON.stringify({ email: email, userID: id, name: name })
|
|
236
|
+
})];
|
|
237
|
+
case 1:
|
|
238
|
+
fetchData = _a.sent();
|
|
239
|
+
return [4, fetchData.json()];
|
|
240
|
+
case 2:
|
|
241
|
+
responseData = _a.sent();
|
|
242
|
+
if (responseData.status !== 200) {
|
|
243
|
+
throw { status: responseData.status, error: responseData.error };
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
if (!!!responseData.data.userData) {
|
|
247
|
+
throw {
|
|
248
|
+
status: responseData.status,
|
|
249
|
+
error: 'user_not_found'
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
if (!!responseData.data.cartData) {
|
|
253
|
+
localStorage.setItem("".concat(this._org, "__cart"), responseData.data.cartData.id);
|
|
254
|
+
}
|
|
255
|
+
if (responseData.token)
|
|
256
|
+
this.setUserToken(responseData.token);
|
|
257
|
+
return [2, { userData: responseData.data.userData, cart: responseData.data.cartData }];
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
return [2, err.toString()];
|
|
261
|
+
}
|
|
262
|
+
return [2];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}); };
|
|
266
|
+
this.anonymousResetPassword = function (locale, id, oldPassword, newPassword, confirmPassword) { return __awaiter(_this, void 0, void 0, function () {
|
|
267
|
+
var fetchData, responseData, error_1;
|
|
268
|
+
return __generator(this, function (_a) {
|
|
269
|
+
switch (_a.label) {
|
|
270
|
+
case 0:
|
|
271
|
+
_a.trys.push([0, 3, , 4]);
|
|
272
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/anonymousResetPassword"), {
|
|
273
|
+
method: 'POST',
|
|
274
|
+
headers: {
|
|
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];
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}); };
|
|
306
|
+
this.loginUser = function (locale, email, password, keepCart, isClerk) {
|
|
307
|
+
if (keepCart === void 0) { keepCart = false; }
|
|
308
|
+
if (isClerk === void 0) { isClerk = false; }
|
|
309
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
310
|
+
var fetchData, responseData, cartData, shouldResetCartData, currentCartInLocalStorage;
|
|
311
|
+
return __generator(this, function (_a) {
|
|
312
|
+
switch (_a.label) {
|
|
313
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/signin"), {
|
|
314
|
+
method: 'POST',
|
|
315
|
+
headers: {
|
|
316
|
+
authorization: "Bearer ".concat(this._token),
|
|
317
|
+
'Content-Type': 'application/json',
|
|
318
|
+
'x-gng-ecomm-locale': locale
|
|
319
|
+
},
|
|
320
|
+
body: JSON.stringify({ email: email, password: password, isClerk: isClerk })
|
|
321
|
+
})];
|
|
322
|
+
case 1:
|
|
323
|
+
fetchData = _a.sent();
|
|
324
|
+
return [4, fetchData.json()];
|
|
325
|
+
case 2:
|
|
326
|
+
responseData = _a.sent();
|
|
327
|
+
if (responseData.status !== 200) {
|
|
328
|
+
throw { status: responseData.status, error: responseData.error };
|
|
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];
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
this.loginUserWithID = function (locale, id, password, keepCart, isClerk) {
|
|
359
|
+
if (keepCart === void 0) { keepCart = false; }
|
|
360
|
+
if (isClerk === void 0) { isClerk = false; }
|
|
361
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
362
|
+
var fetchData, responseData, currentCartInLocalStorage;
|
|
363
|
+
return __generator(this, function (_a) {
|
|
364
|
+
switch (_a.label) {
|
|
365
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/signinwithid"), {
|
|
366
|
+
method: 'POST',
|
|
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
|
+
}
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
this.checkG2ForCustomer = function (id, currentCustomer, customerGroups) { return __awaiter(_this, void 0, void 0, function () {
|
|
400
|
+
var fetchData, G2RequestRes, allG2Customers, customerToCheck, customerToCreate, anonymizedCustomer, e_1;
|
|
401
|
+
return __generator(this, function (_a) {
|
|
402
|
+
switch (_a.label) {
|
|
403
|
+
case 0:
|
|
404
|
+
_a.trys.push([0, 3, , 4]);
|
|
405
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/services/g2/customers/").concat(id), {
|
|
406
|
+
method: 'GET',
|
|
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];
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
this.validateAccount = function (code) { return __awaiter(_this, void 0, void 0, function () {
|
|
503
|
+
var fetchData, responseData;
|
|
504
|
+
return __generator(this, function (_a) {
|
|
505
|
+
switch (_a.label) {
|
|
506
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/validateEmail"), {
|
|
507
|
+
method: 'POST',
|
|
508
|
+
headers: {
|
|
509
|
+
authorization: "Bearer ".concat(this._token),
|
|
510
|
+
'Content-Type': 'application/json',
|
|
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
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}); };
|
|
532
|
+
this.logout = function () {
|
|
533
|
+
_this.setUserToken('');
|
|
534
|
+
localStorage.removeItem("".concat(_this._org, "__cart"));
|
|
535
|
+
localStorage.removeItem('userLogged');
|
|
536
|
+
localStorage.removeItem('isPro');
|
|
537
|
+
localStorage.removeItem('foundInG2');
|
|
538
|
+
localStorage.removeItem('customPriceList');
|
|
539
|
+
localStorage.removeItem('lastCustomPriceFetch');
|
|
540
|
+
localStorage.removeItem('userToken');
|
|
541
|
+
localStorage.removeItem('wishlist');
|
|
542
|
+
localStorage.removeItem('stockNotification');
|
|
543
|
+
js_cookie_1.default.remove('userToken', { expires: new Date(0) });
|
|
544
|
+
};
|
|
545
|
+
this.registerUser = function (locale, userData, password) { return __awaiter(_this, void 0, void 0, function () {
|
|
546
|
+
var fetchData, responseData;
|
|
547
|
+
return __generator(this, function (_a) {
|
|
548
|
+
switch (_a.label) {
|
|
549
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/register"), {
|
|
550
|
+
method: 'PUT',
|
|
551
|
+
headers: {
|
|
552
|
+
Authorization: "Bearer ".concat(this._token),
|
|
553
|
+
'Content-Type': 'application/json',
|
|
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
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}); };
|
|
607
|
+
this.saveUser = function (userData) { return __awaiter(_this, void 0, void 0, function () {
|
|
608
|
+
var fetchData, responseData;
|
|
609
|
+
return __generator(this, function (_a) {
|
|
610
|
+
switch (_a.label) {
|
|
611
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/save"), {
|
|
612
|
+
method: 'POST',
|
|
613
|
+
headers: {
|
|
614
|
+
authorization: "Bearer ".concat(this._token),
|
|
615
|
+
'Content-Type': 'application/json',
|
|
616
|
+
'x-gng-ecomm-token': this._userToken
|
|
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];
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
}); };
|
|
637
|
+
this.deleteUser = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
638
|
+
var fetchData, responseData;
|
|
639
|
+
return __generator(this, function (_a) {
|
|
640
|
+
switch (_a.label) {
|
|
641
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/delete"), {
|
|
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];
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}); };
|
|
660
|
+
this.getOrders = function (lastID, iteration) { return __awaiter(_this, void 0, void 0, function () {
|
|
661
|
+
var queryString, fetchData, responseData;
|
|
662
|
+
return __generator(this, function (_a) {
|
|
663
|
+
switch (_a.label) {
|
|
664
|
+
case 0:
|
|
665
|
+
queryString = "?fromLastID=".concat(lastID !== null && lastID !== void 0 ? lastID : '', "&skip=").concat(iteration !== null && iteration !== void 0 ? iteration : '');
|
|
666
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/orders").concat(queryString), {
|
|
667
|
+
method: 'GET',
|
|
668
|
+
headers: {
|
|
669
|
+
authorization: "Bearer ".concat(this._token),
|
|
670
|
+
'Content-Type': 'application/json',
|
|
671
|
+
'x-gng-ecomm-token': this._userToken
|
|
672
|
+
}
|
|
673
|
+
})];
|
|
674
|
+
case 1:
|
|
675
|
+
fetchData = _a.sent();
|
|
676
|
+
return [4, fetchData.json()];
|
|
677
|
+
case 2:
|
|
678
|
+
responseData = (_a.sent());
|
|
679
|
+
if (responseData.status !== 200) {
|
|
680
|
+
return [2, responseData.data];
|
|
681
|
+
}
|
|
682
|
+
return [2, responseData.data];
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
}); };
|
|
686
|
+
this.killRepCart = function (hashed_cart_id) { return __awaiter(_this, void 0, void 0, function () {
|
|
687
|
+
var fetchData, responseData, error_2;
|
|
688
|
+
return __generator(this, function (_a) {
|
|
689
|
+
switch (_a.label) {
|
|
690
|
+
case 0:
|
|
691
|
+
_a.trys.push([0, 3, , 4]);
|
|
692
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/killRepCart/").concat(encodeURIComponent(hashed_cart_id)), {
|
|
693
|
+
method: 'GET',
|
|
694
|
+
headers: {
|
|
695
|
+
authorization: "Bearer ".concat(this._token),
|
|
696
|
+
'Content-Type': 'application/json',
|
|
697
|
+
'x-gng-ecomm-token': this._userToken
|
|
698
|
+
}
|
|
699
|
+
})];
|
|
700
|
+
case 1:
|
|
701
|
+
fetchData = _a.sent();
|
|
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];
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}); };
|
|
717
|
+
this.getOrder = function (orderID, token) { return __awaiter(_this, void 0, void 0, function () {
|
|
718
|
+
var fetchData, responseData, error_3;
|
|
719
|
+
return __generator(this, function (_a) {
|
|
720
|
+
switch (_a.label) {
|
|
721
|
+
case 0:
|
|
722
|
+
_a.trys.push([0, 3, , 4]);
|
|
723
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/order/").concat(orderID), {
|
|
724
|
+
method: 'POST',
|
|
725
|
+
headers: {
|
|
726
|
+
authorization: "Bearer ".concat(this._token),
|
|
727
|
+
'Content-Type': 'application/json',
|
|
728
|
+
'x-gng-ecomm-token': this._userToken
|
|
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];
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
}); };
|
|
749
|
+
this.changeProfilePicture = function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
750
|
+
var fetchData, responseData;
|
|
751
|
+
return __generator(this, function (_a) {
|
|
752
|
+
switch (_a.label) {
|
|
753
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/changeProfilePicture"), {
|
|
754
|
+
method: 'POST',
|
|
755
|
+
headers: {
|
|
756
|
+
authorization: "Bearer ".concat(this._token),
|
|
757
|
+
'Content-Type': 'application/json',
|
|
758
|
+
'x-gng-ecomm-token': this._userToken
|
|
759
|
+
},
|
|
760
|
+
body: JSON.stringify({
|
|
761
|
+
file: file
|
|
762
|
+
})
|
|
763
|
+
})];
|
|
764
|
+
case 1:
|
|
765
|
+
fetchData = _a.sent();
|
|
766
|
+
return [4, fetchData.json()];
|
|
767
|
+
case 2:
|
|
768
|
+
responseData = (_a.sent());
|
|
769
|
+
return [2, responseData.data];
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
}); };
|
|
773
|
+
this.changePassword = function (currentPassword, newPassword) { return __awaiter(_this, void 0, void 0, function () {
|
|
774
|
+
var fetchData, responseData;
|
|
775
|
+
return __generator(this, function (_a) {
|
|
776
|
+
switch (_a.label) {
|
|
777
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/changePassword"), {
|
|
778
|
+
method: 'POST',
|
|
779
|
+
headers: {
|
|
780
|
+
authorization: "Bearer ".concat(this._token),
|
|
781
|
+
'Content-Type': 'application/json',
|
|
782
|
+
'x-gng-ecomm-token': this._userToken
|
|
783
|
+
},
|
|
784
|
+
body: JSON.stringify({ currentPassword: currentPassword, newPassword: newPassword })
|
|
785
|
+
})];
|
|
786
|
+
case 1:
|
|
787
|
+
fetchData = _a.sent();
|
|
788
|
+
return [4, fetchData.json()];
|
|
789
|
+
case 2:
|
|
790
|
+
responseData = (_a.sent());
|
|
791
|
+
if (responseData.status === 200)
|
|
792
|
+
return [2, responseData.data];
|
|
793
|
+
return [2, responseData.error];
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}); };
|
|
797
|
+
this.sendResetPasswordEmail = function (locale, userEmail, forPro, withEmail, isTest) { return __awaiter(_this, void 0, void 0, function () {
|
|
798
|
+
var fetchData, responseData;
|
|
799
|
+
return __generator(this, function (_a) {
|
|
800
|
+
switch (_a.label) {
|
|
801
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/user/sentForgotPasswordEmail"), {
|
|
802
|
+
method: 'POST',
|
|
803
|
+
headers: {
|
|
804
|
+
authorization: "Bearer ".concat(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({ 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
|
+
}
|
|
825
|
+
});
|
|
826
|
+
}); };
|
|
827
|
+
this.sendApplicationEmail = function (locale, form) { return __awaiter(_this, void 0, void 0, function () {
|
|
828
|
+
var cvBase64, fetchData, responseData, error_4;
|
|
829
|
+
return __generator(this, function (_a) {
|
|
830
|
+
switch (_a.label) {
|
|
831
|
+
case 0:
|
|
832
|
+
_a.trys.push([0, 4, , 5]);
|
|
833
|
+
if (!!!form.cv)
|
|
834
|
+
return [2, {
|
|
835
|
+
error: "Couldn't find cv"
|
|
836
|
+
}];
|
|
837
|
+
return [4, (0, functions_2.toBase64)(form.cv)];
|
|
838
|
+
case 1:
|
|
839
|
+
cvBase64 = _a.sent();
|
|
840
|
+
if (typeof cvBase64 !== 'string') {
|
|
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
|
+
}
|
|
868
|
+
});
|
|
869
|
+
}); };
|
|
870
|
+
this.sendContactEmail = function (locale, form) { return __awaiter(_this, void 0, void 0, function () {
|
|
871
|
+
var fetchData, responseData;
|
|
872
|
+
return __generator(this, function (_a) {
|
|
873
|
+
switch (_a.label) {
|
|
874
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendContactEmail"), {
|
|
875
|
+
method: 'POST',
|
|
876
|
+
headers: {
|
|
877
|
+
authorization: "Bearer ".concat(this._token),
|
|
878
|
+
'Content-Type': 'application/json',
|
|
879
|
+
'x-gng-ecomm-token': this._userToken,
|
|
880
|
+
'x-gng-ecomm-locale': locale
|
|
881
|
+
},
|
|
882
|
+
body: JSON.stringify(form)
|
|
883
|
+
})];
|
|
884
|
+
case 1:
|
|
885
|
+
fetchData = _a.sent();
|
|
886
|
+
return [4, fetchData.json()];
|
|
887
|
+
case 2:
|
|
888
|
+
responseData = (_a.sent());
|
|
889
|
+
if (responseData.status === 200)
|
|
890
|
+
return [2, responseData.data];
|
|
891
|
+
return [2, responseData.error];
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
}); };
|
|
895
|
+
this.sendGenericOtherEmail = function (locale, form, templateId, to, replyTo) { return __awaiter(_this, void 0, void 0, function () {
|
|
896
|
+
var getSubjectByType, fetchData, responseData, error_5;
|
|
897
|
+
return __generator(this, function (_a) {
|
|
898
|
+
switch (_a.label) {
|
|
899
|
+
case 0:
|
|
900
|
+
getSubjectByType = function (type) {
|
|
901
|
+
switch (type) {
|
|
902
|
+
case 'confirmation_lawn_submission':
|
|
903
|
+
return { fr: 'Soumission gazon - Confirmation de réception', en: 'Lawn submission - Confirmation' };
|
|
904
|
+
default:
|
|
905
|
+
return undefined;
|
|
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];
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
}); };
|
|
937
|
+
this.sendServicePageEmail = function (locale, form, type, testEmail) { return __awaiter(_this, void 0, void 0, function () {
|
|
938
|
+
var attachments, rest, updatedAttachments, _i, _a, att, cvBase64, e_4, getSubjectByType, fetchData, responseData, e_5;
|
|
939
|
+
return __generator(this, function (_b) {
|
|
940
|
+
switch (_b.label) {
|
|
941
|
+
case 0:
|
|
942
|
+
attachments = form.attachments, rest = __rest(form, ["attachments"]);
|
|
943
|
+
updatedAttachments = [];
|
|
944
|
+
if (!!!attachments) return [3, 6];
|
|
945
|
+
_i = 0, _a = attachments;
|
|
946
|
+
_b.label = 1;
|
|
947
|
+
case 1:
|
|
948
|
+
if (!(_i < _a.length)) return [3, 6];
|
|
949
|
+
att = _a[_i];
|
|
950
|
+
_b.label = 2;
|
|
951
|
+
case 2:
|
|
952
|
+
_b.trys.push([2, 4, , 5]);
|
|
953
|
+
return [4, (0, functions_2.toBase64)(att)];
|
|
954
|
+
case 3:
|
|
955
|
+
cvBase64 = _b.sent();
|
|
956
|
+
updatedAttachments.push({ name: att.name, content: cvBase64 });
|
|
957
|
+
return [3, 5];
|
|
958
|
+
case 4:
|
|
959
|
+
e_4 = _b.sent();
|
|
960
|
+
console.log('error on converting to base64: ', e_4);
|
|
961
|
+
return [3, 5];
|
|
962
|
+
case 5:
|
|
963
|
+
_i++;
|
|
964
|
+
return [3, 1];
|
|
965
|
+
case 6:
|
|
966
|
+
getSubjectByType = function () {
|
|
967
|
+
switch (type) {
|
|
968
|
+
case 'admin_3D_plans':
|
|
969
|
+
if (!!form.project_type && form.project_type === 'conception') {
|
|
970
|
+
return { fr: 'Conception de plans - Nouvelle demande', en: 'Project design - new request' };
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
return { fr: 'Images 3D - Nouvelle demande', en: '3D plans - new request' };
|
|
974
|
+
}
|
|
975
|
+
case 'admin_vegetals':
|
|
976
|
+
return { fr: 'Commande de végétaux - nouvelle soumission', en: 'Vegetals - new quotation' };
|
|
977
|
+
case 'admin_pickup_on_site':
|
|
978
|
+
return { fr: 'Ramassage sur chantier - nouvelle demande', en: 'Pickup on site - new request' };
|
|
979
|
+
case 'admin_borrow_tools':
|
|
980
|
+
return { fr: "Location d'outils - nouvelle demande", en: 'Rent tools - new request' };
|
|
981
|
+
case 'admin_sales_info':
|
|
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
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
_b.label = 7;
|
|
1011
|
+
case 7:
|
|
1012
|
+
_b.trys.push([7, 10, , 11]);
|
|
1013
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/email/sendServiceStaticPageEmail"), {
|
|
1014
|
+
method: 'POST',
|
|
1015
|
+
headers: {
|
|
1016
|
+
authorization: "Bearer ".concat(this._token),
|
|
1017
|
+
'Content-Type': 'application/json',
|
|
1018
|
+
'x-gng-ecomm-token': this._userToken,
|
|
1019
|
+
'x-gng-ecomm-locale': locale
|
|
1020
|
+
},
|
|
1021
|
+
body: JSON.stringify(__assign(__assign(__assign(__assign({}, rest), (!!updatedAttachments && !!updatedAttachments.length ? { attachments: updatedAttachments } : {})), { subject: getSubjectByType(), title: getSubjectByType(), type: type }), (!!testEmail ? { test_email: testEmail } : {})))
|
|
1022
|
+
})];
|
|
1023
|
+
case 8:
|
|
1024
|
+
fetchData = _b.sent();
|
|
1025
|
+
return [4, fetchData.json()];
|
|
1026
|
+
case 9:
|
|
1027
|
+
responseData = (_b.sent());
|
|
1028
|
+
if (responseData.status === 200)
|
|
1029
|
+
return [2, true];
|
|
1030
|
+
return [2, responseData.error];
|
|
1031
|
+
case 10:
|
|
1032
|
+
e_5 = _b.sent();
|
|
1033
|
+
console.log('error on calling api: ', e_5);
|
|
1034
|
+
if (!!updatedAttachments) {
|
|
1035
|
+
return [2, {
|
|
1036
|
+
status: 413,
|
|
1037
|
+
error: {
|
|
1038
|
+
fr: "Vos pièces jointes n'ont pas pu être envoyées. Veuillez réessayer.",
|
|
1039
|
+
en: 'Your attachments could not be sent. Please try again.'
|
|
1040
|
+
}
|
|
1041
|
+
}];
|
|
1042
|
+
}
|
|
1043
|
+
return [2, ''];
|
|
1044
|
+
case 11: return [2];
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
}); };
|
|
1048
|
+
this.sendSponsorRequestEmail = function (locale, form, template_name) { return __awaiter(_this, void 0, void 0, function () {
|
|
1049
|
+
var plan, rest, updatedPlan, planBase64, splitString, e_6, fetchData, responseData;
|
|
1050
|
+
return __generator(this, function (_a) {
|
|
1051
|
+
switch (_a.label) {
|
|
1052
|
+
case 0:
|
|
1053
|
+
plan = form.plan, rest = __rest(form, ["plan"]);
|
|
1054
|
+
if (!!!plan) return [3, 4];
|
|
1055
|
+
_a.label = 1;
|
|
1056
|
+
case 1:
|
|
1057
|
+
_a.trys.push([1, 3, , 4]);
|
|
1058
|
+
return [4, (0, functions_2.toBase64)(plan)];
|
|
1059
|
+
case 2:
|
|
1060
|
+
planBase64 = _a.sent();
|
|
1061
|
+
if (typeof planBase64 === 'string') {
|
|
1062
|
+
splitString = planBase64.split(';base64,');
|
|
1063
|
+
if (!!splitString.length && !!splitString[1]) {
|
|
1064
|
+
updatedPlan = {
|
|
1065
|
+
name: plan.name,
|
|
1066
|
+
content: splitString[1]
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
return [3, 4];
|
|
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];
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
}); };
|
|
1103
|
+
this.sendPreMeetingFormEmail = function (locale, form, proId) { return __awaiter(_this, void 0, void 0, function () {
|
|
1104
|
+
var attachments, rest, _a, pro_logo, restProInfos, updatedAttachments, updatedLogo, _i, _b, att, cvBase64, e_7, logoBase64, e_8, fetchData, responseData;
|
|
1105
|
+
return __generator(this, function (_c) {
|
|
1106
|
+
switch (_c.label) {
|
|
1107
|
+
case 0:
|
|
1108
|
+
attachments = form.attachments, rest = __rest(form, ["attachments"]);
|
|
1109
|
+
_a = rest.pro_infos, pro_logo = _a.pro_logo, restProInfos = __rest(_a, ["pro_logo"]);
|
|
1110
|
+
updatedAttachments = [];
|
|
1111
|
+
updatedLogo = '';
|
|
1112
|
+
if (!!!attachments) return [3, 6];
|
|
1113
|
+
_i = 0, _b = attachments;
|
|
1114
|
+
_c.label = 1;
|
|
1115
|
+
case 1:
|
|
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();
|
|
1124
|
+
updatedAttachments.push({ name: att.name, content: cvBase64 });
|
|
1125
|
+
return [3, 5];
|
|
1126
|
+
case 4:
|
|
1127
|
+
e_7 = _c.sent();
|
|
1128
|
+
console.log('error on converting to base64: ', e_7);
|
|
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];
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
}); };
|
|
1168
|
+
this.sendWishlistByEmail = function (locale, contenu, template_name) { return __awaiter(_this, void 0, void 0, function () {
|
|
1169
|
+
var fetchData, responseData;
|
|
1170
|
+
return __generator(this, function (_a) {
|
|
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];
|
|
1190
|
+
}
|
|
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];
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
}); };
|
|
1222
|
+
this.user = {
|
|
1223
|
+
getUser: this.getUser,
|
|
1224
|
+
saveUser: this.saveUser,
|
|
1225
|
+
deleteUser: this.deleteUser,
|
|
1226
|
+
loginUser: this.loginUser,
|
|
1227
|
+
loginUserWithID: this.loginUserWithID,
|
|
1228
|
+
loginUserWithFacebook: this.loginUserWithFacebook,
|
|
1229
|
+
logout: this.logout,
|
|
1230
|
+
registerUser: this.registerUser,
|
|
1231
|
+
killRepCart: this.killRepCart,
|
|
1232
|
+
getOrder: this.getOrder,
|
|
1233
|
+
getOrders: this.getOrders,
|
|
1234
|
+
changePassword: this.changePassword,
|
|
1235
|
+
changeProfilePicture: this.changeProfilePicture,
|
|
1236
|
+
validateAccount: this.validateAccount,
|
|
1237
|
+
sendResetPasswordEmail: this.sendResetPasswordEmail,
|
|
1238
|
+
resetPassword: this.resetPassword,
|
|
1239
|
+
sendApplicationEmail: this.sendApplicationEmail,
|
|
1240
|
+
sendContactEmail: this.sendContactEmail,
|
|
1241
|
+
sendServiceEmail: this.sendServicePageEmail,
|
|
1242
|
+
anonymousResetPassword: this.anonymousResetPassword,
|
|
1243
|
+
checkG2: this.checkG2ForCustomer,
|
|
1244
|
+
createPro: this.createProCustomer,
|
|
1245
|
+
fetchCustomPriceList: this.fetchCustomPriceList
|
|
1246
|
+
};
|
|
1247
|
+
this.getImage = function (imgName, formatQuery, addImgPath) {
|
|
1248
|
+
if (addImgPath === void 0) { addImgPath = false; }
|
|
1249
|
+
var img = new image_1.default("".concat(addImgPath ? _this._imgPath : '').concat(_this._imgPath, "/").concat(imgName));
|
|
1250
|
+
return img.getFileDownloadUrl(formatQuery);
|
|
1251
|
+
};
|
|
1252
|
+
this.getProducts = function (page, hpp, query, filters, indice, f, useProspr) {
|
|
1253
|
+
if (page === void 0) { page = 0; }
|
|
1254
|
+
if (hpp === void 0) { hpp = 10; }
|
|
1255
|
+
if (query === void 0) { query = ''; }
|
|
1256
|
+
if (filters === void 0) { filters = ''; }
|
|
1257
|
+
if (indice === void 0) { indice = 'products'; }
|
|
1258
|
+
if (f === void 0) { f = ''; }
|
|
1259
|
+
if (useProspr === void 0) { useProspr = false; }
|
|
1260
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1261
|
+
var error_6;
|
|
1262
|
+
return __generator(this, function (_a) {
|
|
1263
|
+
switch (_a.label) {
|
|
1264
|
+
case 0:
|
|
1265
|
+
_a.trys.push([0, 2, , 3]);
|
|
1266
|
+
return [4, Product_1.default.fetch({
|
|
1267
|
+
app: process.env.NEXT_PUBLIC_ALGOLIA_APP,
|
|
1268
|
+
api: process.env.NEXT_PUBLIC_ALGOLIA_TOKEN,
|
|
1269
|
+
page: page,
|
|
1270
|
+
hpp: hpp,
|
|
1271
|
+
query: query,
|
|
1272
|
+
filters: filters,
|
|
1273
|
+
indice: indice || 'products',
|
|
1274
|
+
f: f,
|
|
1275
|
+
useProspr: useProspr,
|
|
1276
|
+
space: undefined
|
|
1277
|
+
})];
|
|
1278
|
+
case 1: return [2, _a.sent()];
|
|
1279
|
+
case 2:
|
|
1280
|
+
error_6 = _a.sent();
|
|
1281
|
+
throw error_6;
|
|
1282
|
+
case 3: return [2];
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
});
|
|
1286
|
+
};
|
|
1287
|
+
this.getProduct = function (parentSlug, locale, useProdArray, noDrafts) { return __awaiter(_this, void 0, void 0, function () {
|
|
1288
|
+
var prod, fetchData, responseData;
|
|
1289
|
+
return __generator(this, function (_a) {
|
|
1290
|
+
switch (_a.label) {
|
|
1291
|
+
case 0:
|
|
1292
|
+
prod = undefined;
|
|
1293
|
+
if (!!useProdArray && !!useProdArray.length) {
|
|
1294
|
+
prod = useProdArray.find(function (fee) { return fee.slug === parentSlug; });
|
|
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
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
}); };
|
|
1506
|
+
this._getFees = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1507
|
+
var fetchData, resJson, error_13;
|
|
1508
|
+
return __generator(this, function (_a) {
|
|
1509
|
+
switch (_a.label) {
|
|
1510
|
+
case 0:
|
|
1511
|
+
_a.trys.push([0, 3, , 4]);
|
|
1512
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/products/getFees"), {
|
|
1513
|
+
method: 'GET',
|
|
1514
|
+
headers: {
|
|
1515
|
+
authorization: "Bearer ".concat(this._token),
|
|
1516
|
+
'x-gng-ecomm-token': this._userToken
|
|
1517
|
+
}
|
|
1518
|
+
})];
|
|
1519
|
+
case 1:
|
|
1520
|
+
fetchData = _a.sent();
|
|
1521
|
+
return [4, fetchData.json()];
|
|
1522
|
+
case 2:
|
|
1523
|
+
resJson = (_a.sent());
|
|
1524
|
+
if (resJson.status !== 200) {
|
|
1525
|
+
console.log('error on fetching fees: ', !!resJson.error ? resJson.error.toString() : '');
|
|
1526
|
+
return [2, []];
|
|
1527
|
+
}
|
|
1528
|
+
return [2, resJson.data];
|
|
1529
|
+
case 3:
|
|
1530
|
+
error_13 = _a.sent();
|
|
1531
|
+
console.log("error fetching fees", error_13);
|
|
1532
|
+
return [3, 4];
|
|
1533
|
+
case 4: return [2];
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
}); };
|
|
1537
|
+
this.products = {
|
|
1538
|
+
getProducts: this.getProducts,
|
|
1539
|
+
getProduct: this.getProduct,
|
|
1540
|
+
getUpsellOfProducts: this.getUpsellOfProducts,
|
|
1541
|
+
getAttributes: this.getAttributes,
|
|
1542
|
+
getCategories: this.getCategories,
|
|
1543
|
+
getBrands: this.getBrands,
|
|
1544
|
+
getInventoryItems: this.getInventoryItems,
|
|
1545
|
+
getOneInventoryItem: this.getOneInventoryItem,
|
|
1546
|
+
getLatestProducts: this.getLatestProducts,
|
|
1547
|
+
getFees: this._getFees
|
|
1548
|
+
};
|
|
1549
|
+
this.getIfAddressIsInsideZones = function (address) { return __awaiter(_this, void 0, void 0, function () {
|
|
1550
|
+
var userPos, lat, lng, zone, zones, google_1, insideZones, _i, zones_2, zone_1, polygon, error_14;
|
|
1551
|
+
return __generator(this, function (_a) {
|
|
1552
|
+
switch (_a.label) {
|
|
1553
|
+
case 0:
|
|
1554
|
+
_a.trys.push([0, 4, , 5]);
|
|
1555
|
+
return [4, (0, zones_1.getPositionFromAddress)(address)];
|
|
1556
|
+
case 1:
|
|
1557
|
+
userPos = _a.sent();
|
|
1558
|
+
if (!!!userPos)
|
|
1559
|
+
return [2, []];
|
|
1560
|
+
lat = userPos.lat, lng = userPos.lng;
|
|
1561
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/shipping/zones"), {
|
|
1562
|
+
method: 'POST',
|
|
1563
|
+
headers: {
|
|
1564
|
+
authorization: "Bearer ".concat(this._token),
|
|
1565
|
+
'Content-Type': 'application/json'
|
|
1566
|
+
},
|
|
1567
|
+
body: JSON.stringify({ address: address })
|
|
1568
|
+
})];
|
|
1569
|
+
case 2:
|
|
1570
|
+
zone = _a.sent();
|
|
1571
|
+
if (zone.status !== 200)
|
|
1572
|
+
return [2, []];
|
|
1573
|
+
return [4, zone.json()];
|
|
1574
|
+
case 3:
|
|
1575
|
+
zones = (_a.sent()).data.zones;
|
|
1576
|
+
google_1 = window.google;
|
|
1577
|
+
insideZones = [];
|
|
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];
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
}); };
|
|
1603
|
+
this._pricingByQuery = function (query) { return __awaiter(_this, void 0, void 0, function () {
|
|
1604
|
+
var fetchData, resJson, error_15;
|
|
1605
|
+
return __generator(this, function (_a) {
|
|
1606
|
+
switch (_a.label) {
|
|
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];
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
}); };
|
|
1630
|
+
this._buyFromForm = function (form) { return __awaiter(_this, void 0, void 0, function () {
|
|
1631
|
+
var fetchData, resJson, error_16;
|
|
1632
|
+
return __generator(this, function (_a) {
|
|
1633
|
+
switch (_a.label) {
|
|
1634
|
+
case 0:
|
|
1635
|
+
_a.trys.push([0, 3, , 4]);
|
|
1636
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/services/buy/fromForm"), {
|
|
1637
|
+
method: 'POST',
|
|
1638
|
+
headers: {
|
|
1639
|
+
authorization: "Bearer ".concat(this._token),
|
|
1640
|
+
'Content-Type': 'application/json'
|
|
1641
|
+
},
|
|
1642
|
+
body: JSON.stringify(form)
|
|
1643
|
+
})];
|
|
1644
|
+
case 1:
|
|
1645
|
+
fetchData = _a.sent();
|
|
1646
|
+
return [4, fetchData.json()];
|
|
1647
|
+
case 2:
|
|
1648
|
+
resJson = _a.sent();
|
|
1649
|
+
if (!!resJson.error) {
|
|
1650
|
+
return [2, false];
|
|
1651
|
+
}
|
|
1652
|
+
return [2, true];
|
|
1653
|
+
case 3:
|
|
1654
|
+
error_16 = _a.sent();
|
|
1655
|
+
throw error_16;
|
|
1656
|
+
case 4: return [2];
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
}); };
|
|
1660
|
+
this._getSearchServices = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1661
|
+
var fetchData, resJson, space, error_17;
|
|
1662
|
+
return __generator(this, function (_a) {
|
|
1663
|
+
switch (_a.label) {
|
|
1664
|
+
case 0:
|
|
1665
|
+
_a.trys.push([0, 3, , 4]);
|
|
1666
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/space"), {
|
|
1667
|
+
method: 'GET',
|
|
1668
|
+
headers: {
|
|
1669
|
+
authorization: "Bearer ".concat(this._token),
|
|
1670
|
+
'Content-Type': 'application/json'
|
|
1671
|
+
}
|
|
1672
|
+
})];
|
|
1673
|
+
case 1:
|
|
1674
|
+
fetchData = _a.sent();
|
|
1675
|
+
return [4, fetchData.json()];
|
|
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];
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
}); };
|
|
1692
|
+
this.services = {
|
|
1693
|
+
pricingByQuery: this._pricingByQuery,
|
|
1694
|
+
buy: {
|
|
1695
|
+
fromForm: this._buyFromForm
|
|
1696
|
+
},
|
|
1697
|
+
searchServices: this._getSearchServices
|
|
1698
|
+
};
|
|
1699
|
+
this._getAllCatalogues = function (locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
1700
|
+
var fetchData, responseData;
|
|
1701
|
+
return __generator(this, function (_a) {
|
|
1702
|
+
switch (_a.label) {
|
|
1703
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/catalogues"), {
|
|
1704
|
+
method: 'GET',
|
|
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; })];
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
}); };
|
|
1721
|
+
this._getCatalogueBySlug = function (slug, locale) { return __awaiter(_this, void 0, void 0, function () {
|
|
1722
|
+
var fetchData, responseData;
|
|
1723
|
+
return __generator(this, function (_a) {
|
|
1724
|
+
switch (_a.label) {
|
|
1725
|
+
case 0: return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/catalogues/").concat(slug), {
|
|
1726
|
+
method: 'GET',
|
|
1727
|
+
headers: {
|
|
1728
|
+
Authorization: "Bearer ".concat(this._token),
|
|
1729
|
+
'x-gng-ecomm-locale': locale
|
|
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];
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
}); };
|
|
1743
|
+
this.catalogues = {
|
|
1744
|
+
getAll: this._getAllCatalogues,
|
|
1745
|
+
getOne: this._getCatalogueBySlug
|
|
1746
|
+
};
|
|
1747
|
+
this.saveCustomerToMailchimpList = function (customerEmail, listID, mergeFields, tags) { return __awaiter(_this, void 0, void 0, function () {
|
|
1748
|
+
var saved, responseData, e_9;
|
|
1749
|
+
return __generator(this, function (_a) {
|
|
1750
|
+
switch (_a.label) {
|
|
1751
|
+
case 0:
|
|
1752
|
+
_a.trys.push([0, 3, , 4]);
|
|
1753
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/marketing/mailchimp/updateOrCreateCustomer"), {
|
|
1754
|
+
method: 'POST',
|
|
1755
|
+
headers: {
|
|
1756
|
+
Authorization: "Bearer ".concat(this._token),
|
|
1757
|
+
'Content-Type': 'application/json'
|
|
1758
|
+
},
|
|
1759
|
+
body: JSON.stringify(__assign(__assign({ email: customerEmail, listID: listID }, (!!mergeFields ? { mergeFields: mergeFields } : {})), (!!tags ? { tags: tags } : {})))
|
|
1760
|
+
})];
|
|
1761
|
+
case 1:
|
|
1762
|
+
saved = _a.sent();
|
|
1763
|
+
return [4, saved.json()];
|
|
1764
|
+
case 2:
|
|
1765
|
+
responseData = _a.sent();
|
|
1766
|
+
if (responseData.status !== 200)
|
|
1767
|
+
throw new Error(JSON.stringify({ status: responseData.status, error: responseData.error }));
|
|
1768
|
+
return [2, true];
|
|
1769
|
+
case 3:
|
|
1770
|
+
e_9 = _a.sent();
|
|
1771
|
+
console.log('error on saving customer to mailchimp list: ', e_9.toString());
|
|
1772
|
+
return [2, false];
|
|
1773
|
+
case 4: return [2];
|
|
1774
|
+
}
|
|
1775
|
+
});
|
|
1776
|
+
}); };
|
|
1777
|
+
this.getProductListForSitemap = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1778
|
+
var fetchData, result, e_10;
|
|
1779
|
+
return __generator(this, function (_a) {
|
|
1780
|
+
switch (_a.label) {
|
|
1781
|
+
case 0:
|
|
1782
|
+
_a.trys.push([0, 3, , 4]);
|
|
1783
|
+
return [4, (0, isomorphic_unfetch_1.default)("".concat(this._api, "/analytics/sitmap_data"), {
|
|
1784
|
+
method: 'GET',
|
|
1785
|
+
headers: {
|
|
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
|
+
}); };
|
|
1806
|
+
this._api = '';
|
|
1807
|
+
this._imgPath = '';
|
|
1808
|
+
this._token = '';
|
|
1809
|
+
this._userToken = '';
|
|
1810
|
+
this._url = '';
|
|
1811
|
+
this._org = '';
|
|
1812
|
+
this._storeData = null;
|
|
1813
|
+
this._wishlist = null;
|
|
1814
|
+
this._stockNotif = null;
|
|
1815
|
+
}
|
|
1816
|
+
return SDK;
|
|
1817
|
+
}());
|
|
1818
|
+
exports.default = SDK;
|
|
1819
1819
|
//# sourceMappingURL=index.js.map
|