cordova-plugin-insider 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.github/CODEOWNERS +8 -0
  2. package/.github/workflows/git-leak.yml +25 -0
  3. package/.github/workflows/insider-cordova-SDK_release.yml +61 -0
  4. package/.github/workflows/release_task_merger.yml +22 -0
  5. package/.github/workflows/release_version_setter.yml +43 -0
  6. package/README.md +104 -0
  7. package/hooks/FSUtils.js +28 -0
  8. package/hooks/after_plugin_install.js +81 -0
  9. package/hooks/before_plugin_uninstall.js +49 -0
  10. package/package.json +19 -0
  11. package/plugin.xml +91 -0
  12. package/release_version.sh +27 -0
  13. package/slack_notifier.sh +20 -0
  14. package/src/android/CDVUtils.java +120 -0
  15. package/src/android/Constants.java +41 -0
  16. package/src/android/InsiderPlugin.java +814 -0
  17. package/src/android/build-extras.gradle +38 -0
  18. package/src/android/res/values/dimens.xml +4 -0
  19. package/src/android/res/values-sw600dp/dimens.xml +3 -0
  20. package/src/android/res/values-sw720dp/dimens.xml +3 -0
  21. package/src/android/res/values-xhdpi/dimens.xml +4 -0
  22. package/src/android/res/values-xxhdpi/dimens.xml +4 -0
  23. package/src/android/res/values-xxxhdpi/dimens.xml +4 -0
  24. package/src/ios/IDFAHelper.h +7 -0
  25. package/src/ios/IDFAHelper.m +19 -0
  26. package/src/ios/InsiderPlugin.h +58 -0
  27. package/src/ios/InsiderPlugin.m +758 -0
  28. package/types/CallbackType.d.ts +7 -0
  29. package/types/ContentOptimizerDataType.d.ts +4 -0
  30. package/types/Event.d.ts +9 -0
  31. package/types/Gender.d.ts +5 -0
  32. package/types/Identifier.d.ts +7 -0
  33. package/types/InsiderPlugin.d.ts +51 -0
  34. package/types/Product.d.ts +18 -0
  35. package/types/User.d.ts +27 -0
  36. package/www/CallbackType.js +7 -0
  37. package/www/Constants.js +86 -0
  38. package/www/ContentOptimizerDataType.js +4 -0
  39. package/www/Event.js +96 -0
  40. package/www/Gender.js +5 -0
  41. package/www/Identifier.js +66 -0
  42. package/www/InsiderPlugin.js +364 -0
  43. package/www/Product.js +211 -0
  44. package/www/User.js +303 -0
  45. package/www/Utils.js +18 -0
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+
3
+ let InsiderProduct = require("./Product");
4
+ let InsiderEvent = require("./Event");
5
+ let InsiderUser = require("./User");
6
+ let InsiderIdentifier = require('./Identifier');
7
+ let InsiderCallbackType = require('./CallbackType');
8
+ let InsiderGender = require('./Gender');
9
+ let InsiderContentOptimizerDataType = require('./ContentOptimizerDataType');
10
+
11
+ const Utils = require("./Utils");
12
+ const InsiderConstants = require("./Constants");
13
+
14
+ class InsiderPlugin {
15
+ insiderUser = {};
16
+ gender = InsiderGender;
17
+ callbackType = InsiderCallbackType;
18
+ contentOptimizerDataType = InsiderContentOptimizerDataType;
19
+
20
+ constructor() {
21
+ this.insiderUser = new InsiderUser();
22
+ }
23
+
24
+ initCordovaBase = (partnerName, appGroup, customEndpoint, handleNotificationCallback) => {
25
+ try {
26
+ const sdkVersion = InsiderConstants.SDK_VERSION;
27
+
28
+ document.addEventListener('ins_notification_handle', handleNotificationCallback, false);
29
+
30
+ if (customEndpoint !== null)
31
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.INIT_WITH_CUSTOM_ENDPOINT, [partnerName, sdkVersion, appGroup, customEndpoint]);
32
+ else if (cordova.platformId === "ios")
33
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.INIT_WITH_LAUNCH_OPTIONS, [partnerName, sdkVersion, appGroup]);
34
+ else
35
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.INIT, [partnerName, sdkVersion]);
36
+ } catch (error) {
37
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
38
+ }
39
+ }
40
+
41
+ init = (partnerName, appGroup, handleNotificationCallback) => {
42
+ if (partnerName === null || appGroup === null || handleNotificationCallback === null) return;
43
+
44
+ try {
45
+ this.initCordovaBase(partnerName, appGroup, null, handleNotificationCallback);
46
+ } catch (error) {
47
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
48
+ }
49
+ };
50
+
51
+ initWithCustomEndpoint = (partnerName, appGroup, endpoint, handleNotificationCallback) => {
52
+ if (partnerName === null || appGroup === null || endpoint === null || handleNotificationCallback === null) return;
53
+
54
+ try {
55
+ this.initCordovaBase(partnerName, appGroup, endpoint, handleNotificationCallback);
56
+ } catch (error) {
57
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
58
+ }
59
+ }
60
+
61
+ getCurrentUser = () => {
62
+ try {
63
+ return this.insiderUser;
64
+ } catch (error) {
65
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
66
+ }
67
+ }
68
+
69
+ tagEvent = (eventName) => {
70
+ if (eventName === null) { Utils.showWarning('eventName'); return; }
71
+ try {
72
+ return new InsiderEvent(eventName);
73
+ } catch (error) {
74
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
75
+ }
76
+ }
77
+
78
+ createNewProduct = (productID, name, taxonomy, imageURL, price, currency) => {
79
+ if (productID === null || name === null || taxonomy === null || imageURL === null || price === null || currency === null || Utils.isEmpty(taxonomy) || Utils.isEmpty(price))
80
+ return new InsiderProduct('', '', [], '', 0, '');
81
+
82
+ return new InsiderProduct(productID, name, taxonomy, imageURL, price, currency);
83
+ }
84
+
85
+ itemPurchased = (uniqueSaleID, product) => {
86
+ if (uniqueSaleID === null || product === null) return;
87
+
88
+ try {
89
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_PURCHASED, [uniqueSaleID, product.productMustMap, product.productOptMap]);
90
+ } catch (error) {
91
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
92
+ }
93
+ }
94
+
95
+ itemAddedToCart = (product) => {
96
+ if (product === null) return;
97
+
98
+ try {
99
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_ADDED_TO_CART, [product.productMustMap, product.productOptMap]);
100
+ } catch (error) {
101
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
102
+ }
103
+ }
104
+
105
+ itemRemovedFromCart = (productID) => {
106
+ if (productID === null) return;
107
+
108
+ try {
109
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_REMOVED_FROM_CART, [productID]);
110
+ } catch (error) {
111
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
112
+ }
113
+ }
114
+
115
+ cartCleared = () => {
116
+ try {
117
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.CART_CLEARED, []);
118
+ } catch (error) {
119
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
120
+ }
121
+ }
122
+
123
+ getMessageCenterData = (limit, startDate, endDate) => {
124
+ if (limit === null || startDate === null || endDate === null || startDate.getTime() === endDate.getTime() || startDate.getTime() > endDate.getTime()) return;
125
+
126
+ try {
127
+ return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_MESSAGE_CENTER_DATA, [limit, startDate, endDate]);
128
+ } catch (error) {
129
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
130
+ }
131
+ }
132
+
133
+ getSmartRecommendation = (recommendationID, locale, currency) => {
134
+ if (recommendationID === null || locale === null || currency === null) return;
135
+
136
+ try {
137
+ return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_SMART_RECOMMENDATION, [recommendationID, locale, currency]);
138
+ } catch (error) {
139
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
140
+ }
141
+ }
142
+
143
+ getSmartRecommendationWithProduct = (product, recommendationID, locale) => {
144
+ if (product === null || recommendationID === null || locale === null) return;
145
+
146
+ try {
147
+ return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_SMART_RECOMMENDATION_WITH_PRODUCT, [product.productMustMap, product.productOptMap, recommendationID, locale]);
148
+ } catch (error) {
149
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
150
+ }
151
+ }
152
+
153
+ clickSmartRecommendationProduct = (product, recommendationID) => {
154
+ if (product === null || recommendationID === null) return;
155
+
156
+ try {
157
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.CLICK_SMART_RECOMMENDATION_PRODUCT, [product.productMustMap, product.productOptMap, recommendationID]);
158
+ } catch (error) {
159
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
160
+ }
161
+ }
162
+
163
+ getContentStringWithName = (variableName, defaultValue, contentOptimizerDataType) => {
164
+ if (defaultValue === null || contentOptimizerDataType === null) return;
165
+
166
+ try {
167
+ return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_STRING_WITH_NAME, [variableName, defaultValue, contentOptimizerDataType]);
168
+ } catch (error) {
169
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
170
+ }
171
+ }
172
+
173
+ getContentBoolWithName = (variableName, defaultValue, contentOptimizerDataType) => {
174
+ if (variableName === null || defaultValue === null || contentOptimizerDataType === null) return;
175
+
176
+ try {
177
+ return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_BOOL_WITH_NAME, [variableName, defaultValue, contentOptimizerDataType]);
178
+ } catch (error) {
179
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
180
+ }
181
+ }
182
+
183
+ getContentIntWithName = (variableName, defaultValue, contentOptimizerDataType) => {
184
+ if (variableName === null || defaultValue === null || contentOptimizerDataType === null) return;
185
+
186
+ try {
187
+ return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_INT_WITH_NAME, [variableName, defaultValue, contentOptimizerDataType]);
188
+ } catch (error) {
189
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
190
+ }
191
+ }
192
+
193
+ visitHomePage = () => {
194
+ try {
195
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_HOME_PAGE, []);
196
+ } catch (error) {
197
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
198
+ }
199
+ }
200
+
201
+ visitListingPage = (taxonomy) => {
202
+ if (taxonomy === null) return;
203
+
204
+ try {
205
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_LISTING_PAGE, [taxonomy]);
206
+ } catch (error) {
207
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
208
+ }
209
+ }
210
+
211
+ visitProductDetailPage = (product) => {
212
+ if (product === null) return;
213
+
214
+ try {
215
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_PRODUCT_DETAIL_PAGE, [product.productMustMap, product.productOptMap]);
216
+ } catch (error) {
217
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
218
+ }
219
+ }
220
+
221
+ visitCartPage = (products) => {
222
+ if (products === null) return;
223
+ try {
224
+ let productMap = {};
225
+ let mappedProducts = new Array(products.length);
226
+ products.forEach((product, i) => {
227
+ productMap['productMustMap'] = product.productMustMap;
228
+ productMap['productOptMap'] = product.productOptMap;
229
+
230
+ mappedProducts[i] = productMap;
231
+ });
232
+
233
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_CART_PAGE, [mappedProducts]);
234
+ } catch (error) {
235
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
236
+ }
237
+ }
238
+
239
+ startTrackingGeofence = () => {
240
+ try {
241
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.START_TRACKING_GEOFENCE, []);
242
+ } catch (error) {
243
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
244
+ }
245
+ }
246
+
247
+ setGDPRConsent = (gdprConsent) => {
248
+ try {
249
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_GDPR_CONSENT, [gdprConsent.toString().toLowerCase()]);
250
+ } catch (error) {
251
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
252
+ }
253
+ };
254
+
255
+ enableIDFACollection = (idfaCollection) => {
256
+ try {
257
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_IDFA_COLLECTION, [idfaCollection.toString().toLowerCase()]);
258
+ } catch (error) {
259
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
260
+ }
261
+ };
262
+
263
+ removeInapp = () => {
264
+ try {
265
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.REMOVE_IN_APP, []);
266
+ } catch (error) {
267
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
268
+ }
269
+ };
270
+
271
+ registerWithQuietPermission = (permission) => {
272
+ if (cordova.platformId !== InsiderConstants.IOS) return;
273
+
274
+ try {
275
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.REGISTER_WITH_QUIET_PERMISSION, [permission.toString().toLowerCase()]);
276
+ } catch (error) {
277
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
278
+ }
279
+ };
280
+
281
+ setHybridPushToken = (token) => {
282
+ if (stoken === null) return;
283
+
284
+ try {
285
+ if (Platform.OS !== InsiderConstants.ANDROID) return;
286
+
287
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_HYBRID_PUSH_TOKEN, [token]);
288
+ } catch (error) {
289
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
290
+ }
291
+ }
292
+
293
+ enableLocationCollection = (locationCollection) => {
294
+ try {
295
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_LOCATION_COLLECTION, [locationCollection]);
296
+ } catch (error) {
297
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
298
+ }
299
+ }
300
+
301
+ enableIpCollection = (ipCollection) => {
302
+ try {
303
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_IP_COLLECTION, [ipCollection]);
304
+ } catch (error) {
305
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
306
+ }
307
+ }
308
+
309
+ enableCarrierCollection = (carrierCollection) => {
310
+ try {
311
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_CARRIER_COLLECTION, [carrierCollection]);
312
+ } catch (error) {
313
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
314
+ }
315
+ }
316
+
317
+ signUpConfirmation = () => {
318
+ try {
319
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SIGN_UP_CONFIRMATION, []);
320
+ } catch (error) {
321
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
322
+ }
323
+ }
324
+
325
+ identifier = () => {
326
+ try {
327
+ return new InsiderIdentifier();
328
+ } catch (error) {
329
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
330
+ }
331
+ }
332
+
333
+ setActiveForegroundPushView = () => {
334
+ try {
335
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_ACTIVE_FOREGROUND_PUSH_VIEW, []);
336
+ } catch (error) {
337
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
338
+ }
339
+ }
340
+
341
+ setForegroundPushCallback = (callback) => {
342
+ try {
343
+ if (cordova.platformId === "ios") {
344
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_FOREGROUND_PUSH_CALLBACK, []);
345
+
346
+ document.addEventListener('ins_foreground_push_callback', (data) => {
347
+ data && callback(data);
348
+ }, false);
349
+ }
350
+ } catch (error) {
351
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
352
+ }
353
+ }
354
+
355
+ handleNotification = (userInfo) => {
356
+ try {
357
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.HANDLE_NOTIFICATION, [userInfo]);
358
+ } catch (error) {
359
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
360
+ }
361
+ }
362
+ }
363
+
364
+ module.exports = new InsiderPlugin();
package/www/Product.js ADDED
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+
3
+ const InsiderConstants = require("./Constants");
4
+ const Utils = require("./Utils");
5
+
6
+ class Product {
7
+ productMustMap = {};
8
+ productOptMap = {};
9
+
10
+ constructor(productID, name, taxonomy, imageURL, price, currency) {
11
+ this.productMustMap = {
12
+ product_id: productID,
13
+ name: name,
14
+ taxonomy: taxonomy,
15
+ image_url: imageURL,
16
+ unit_price: price,
17
+ currency: currency,
18
+ };
19
+ }
20
+
21
+ setColor(color) {
22
+ if (color === null|| Utils.isEmpty(color)){ Utils.showWarning(this.constructor.name + '-color'); return this;}
23
+
24
+ try {
25
+ this.productOptMap[InsiderConstants.COLOR] = color;
26
+ } catch (error) {
27
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
28
+ }
29
+
30
+ return this;
31
+ }
32
+
33
+ setVoucherName(voucherName) {
34
+ if (voucherName === null|| Utils.isEmpty(voucherName)){ Utils.showWarning(this.constructor.name + '-voucherName'); return this;}
35
+
36
+ try {
37
+ this.productOptMap[InsiderConstants.VOUCHER_NAME] = voucherName;
38
+ } catch (error) {
39
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
40
+ }
41
+
42
+ return this;
43
+ }
44
+
45
+ setPromotionName(promotionName) {
46
+ if (promotionName === null|| Utils.isEmpty(promotionName)){ Utils.showWarning(this.constructor.name + '-promotionName'); return this;}
47
+
48
+ try {
49
+ this.productOptMap[InsiderConstants.PROMOTION_NAME] = promotionName;
50
+ } catch (error) {
51
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
52
+ }
53
+
54
+ return this;
55
+ }
56
+
57
+ setSize(size) {
58
+ if (size === null|| Utils.isEmpty(size)){ Utils.showWarning(this.constructor.name + '-size'); return this;}
59
+
60
+ try {
61
+ this.productOptMap[InsiderConstants.SIZE] = size;
62
+ } catch (error) {
63
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
64
+ }
65
+
66
+ return this;
67
+ }
68
+
69
+ setSalePrice(salePrice) {
70
+ if (salePrice === null|| Utils.isEmpty(salePrice)){ Utils.showWarning(this.constructor.name + '-salePrice'); return this;}
71
+
72
+ try {
73
+ this.productOptMap[InsiderConstants.SALE_PRICE] = salePrice;
74
+ } catch (error) {
75
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
76
+ }
77
+ return this;
78
+ }
79
+
80
+ setShippingCost(shippingCost) {
81
+ if (shippingCost === null|| Utils.isEmpty(shippingCost)){ Utils.showWarning(this.constructor.name + '-shippingCost'); return this;}
82
+
83
+ try {
84
+ this.productOptMap[InsiderConstants.SHIPPING_COST] = shippingCost;
85
+ } catch (error) {
86
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
87
+ }
88
+
89
+ return this;
90
+ }
91
+
92
+ setVoucherDiscount(voucherDiscount) {
93
+ if (voucherDiscount === null|| Utils.isEmpty(voucherDiscount)){ Utils.showWarning(this.constructor.name + '-voucherDiscount'); return this;}
94
+
95
+ try {
96
+ this.productOptMap[InsiderConstants.VOUCHER_DISCOUNT] = voucherDiscount;
97
+ } catch (error) {
98
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
99
+ }
100
+
101
+ return this;
102
+ }
103
+
104
+ setPromotionDiscount(promotionDiscount) {
105
+ if (promotionDiscount === null|| Utils.isEmpty(promotionDiscount)){ Utils.showWarning(this.constructor.name + '-promotionDiscount'); return this;}
106
+
107
+ try {
108
+ this.productOptMap[InsiderConstants.PROMOTION_DISCOUNT] = promotionDiscount;
109
+ } catch (error) {
110
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
111
+ }
112
+
113
+ return this;
114
+ }
115
+
116
+ setStock(stock) {
117
+ if (stock === null|| Utils.isEmpty(stock)){ Utils.showWarning(this.constructor.name + '-stock'); return this;}
118
+
119
+ try {
120
+ this.productOptMap[InsiderConstants.STOCK] = stock;
121
+ } catch (error) {
122
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
123
+ }
124
+
125
+ return this;
126
+ }
127
+
128
+ setQuantity(quantity) {
129
+ if (quantity === null|| Utils.isEmpty(quantity)|| Utils.isEmpty(quantity)){ Utils.showWarning(this.constructor.name + '-quantity'); return this;}
130
+
131
+ try {
132
+ this.productOptMap[InsiderConstants.QUANTITY] = quantity;
133
+ } catch (error) {
134
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
135
+ }
136
+
137
+ return this;
138
+ }
139
+
140
+ setCustomAttributeWithString(key, value) {
141
+ if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithString key or value'); return this;}
142
+
143
+ try {
144
+ this.productOptMap[key] = value;
145
+ } catch (error) {
146
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
147
+ }
148
+
149
+ return this;
150
+ }
151
+
152
+ setCustomAttributeWithInt(key, value) {
153
+ if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithInt key or value'); return this;}
154
+
155
+ try {
156
+ this.productOptMap[key] = value;
157
+ } catch (error) {
158
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
159
+ }
160
+ return this;
161
+ }
162
+
163
+ setCustomAttributeWithBoolean(key, value) {
164
+ if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithBoolean key or value'); return this;}
165
+
166
+ try {
167
+ this.productOptMap[key] = value;
168
+ } catch (error) {
169
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
170
+ }
171
+ return this;
172
+ }
173
+
174
+ setCustomAttributeWithDouble(key, value) {
175
+ if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDouble key or value'); return this;}
176
+
177
+ try {
178
+ this.productOptMap[key] = value;
179
+ } catch (error) {
180
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
181
+ }
182
+
183
+ return this;
184
+ }
185
+
186
+ setCustomAttributeWithDate(key, value) {
187
+ if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDate key or value'); return this;}
188
+
189
+ try {
190
+ this.productOptMap[key] = value.toISOString();
191
+ } catch (error) {
192
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
193
+ }
194
+
195
+ return this;
196
+ }
197
+
198
+ setCustomAttributeWithArray(key, value) {
199
+ if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithArray key or value'); return this;}
200
+
201
+ try {
202
+ this.productOptMap[key] = value;
203
+ } catch (error) {
204
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
205
+ }
206
+
207
+ return this;
208
+ }
209
+ }
210
+
211
+ module.exports = Product;