cordova-plugin-insider 1.4.0 → 1.6.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.
package/www/Product.js CHANGED
@@ -19,7 +19,10 @@ class Product {
19
19
  }
20
20
 
21
21
  setColor(color) {
22
- if (color === null|| Utils.isEmpty(color)){ Utils.showWarning(this.constructor.name + '-color'); return this;}
22
+ if (Utils.checkParameters([{ type: 'string', value: color }])) {
23
+ Utils.showParameterWarningLog(this.constructor.name + '-color');
24
+ return this;
25
+ }
23
26
 
24
27
  try {
25
28
  this.productOptMap[InsiderConstants.COLOR] = color;
@@ -31,7 +34,10 @@ class Product {
31
34
  }
32
35
 
33
36
  setVoucherName(voucherName) {
34
- if (voucherName === null|| Utils.isEmpty(voucherName)){ Utils.showWarning(this.constructor.name + '-voucherName'); return this;}
37
+ if (Utils.checkParameters([{ type: 'string', value: voucherName }])) {
38
+ Utils.showParameterWarningLog(this.constructor.name + '-voucherName');
39
+ return this;
40
+ }
35
41
 
36
42
  try {
37
43
  this.productOptMap[InsiderConstants.VOUCHER_NAME] = voucherName;
@@ -43,19 +49,25 @@ class Product {
43
49
  }
44
50
 
45
51
  setPromotionName(promotionName) {
46
- if (promotionName === null|| Utils.isEmpty(promotionName)){ Utils.showWarning(this.constructor.name + '-promotionName'); return this;}
52
+ if (Utils.checkParameters([{ type: 'string', value: promotionName }])) {
53
+ Utils.showParameterWarningLog(this.constructor.name + '-promotionName');
54
+ return this;
55
+ }
47
56
 
48
57
  try {
49
58
  this.productOptMap[InsiderConstants.PROMOTION_NAME] = promotionName;
50
59
  } catch (error) {
51
60
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
52
61
  }
53
-
62
+
54
63
  return this;
55
64
  }
56
65
 
57
66
  setSize(size) {
58
- if (size === null|| Utils.isEmpty(size)){ Utils.showWarning(this.constructor.name + '-size'); return this;}
67
+ if (Utils.checkParameters([{ type: 'string', value: size }])) {
68
+ Utils.showParameterWarningLog(this.constructor.name + '-size');
69
+ return this;
70
+ }
59
71
 
60
72
  try {
61
73
  this.productOptMap[InsiderConstants.SIZE] = size;
@@ -67,7 +79,10 @@ class Product {
67
79
  }
68
80
 
69
81
  setGroupCode(groupCode) {
70
- if (!groupCode) { Utils.showWarning(this.constructor.name + '-groupCode'); return this; }
82
+ if (Utils.checkParameters([{ type: 'string', value: groupCode }])) {
83
+ Utils.showParameterWarningLog(this.constructor.name + '-groupCode');
84
+ return this;
85
+ }
71
86
 
72
87
  try {
73
88
  this.productOptMap[InsiderConstants.GROUP_CODE] = groupCode;
@@ -79,7 +94,10 @@ class Product {
79
94
  }
80
95
 
81
96
  setSalePrice(salePrice) {
82
- if (salePrice === null|| Utils.isEmpty(salePrice)){ Utils.showWarning(this.constructor.name + '-salePrice'); return this;}
97
+ if (Utils.checkParameters([{ type: 'number', value: salePrice }])) {
98
+ Utils.showParameterWarningLog(this.constructor.name + '-salePrice');
99
+ return this;
100
+ }
83
101
 
84
102
  try {
85
103
  this.productOptMap[InsiderConstants.SALE_PRICE] = salePrice;
@@ -90,7 +108,10 @@ class Product {
90
108
  }
91
109
 
92
110
  setShippingCost(shippingCost) {
93
- if (shippingCost === null|| Utils.isEmpty(shippingCost)){ Utils.showWarning(this.constructor.name + '-shippingCost'); return this;}
111
+ if (Utils.checkParameters([{ type: 'number', value: shippingCost }])) {
112
+ Utils.showParameterWarningLog(this.constructor.name + '-shippingCost');
113
+ return this;
114
+ }
94
115
 
95
116
  try {
96
117
  this.productOptMap[InsiderConstants.SHIPPING_COST] = shippingCost;
@@ -102,7 +123,10 @@ class Product {
102
123
  }
103
124
 
104
125
  setVoucherDiscount(voucherDiscount) {
105
- if (voucherDiscount === null|| Utils.isEmpty(voucherDiscount)){ Utils.showWarning(this.constructor.name + '-voucherDiscount'); return this;}
126
+ if (Utils.checkParameters([{ type: 'number', value: voucherDiscount }])) {
127
+ Utils.showParameterWarningLog(this.constructor.name + '-voucherDiscount');
128
+ return this;
129
+ }
106
130
 
107
131
  try {
108
132
  this.productOptMap[InsiderConstants.VOUCHER_DISCOUNT] = voucherDiscount;
@@ -114,7 +138,10 @@ class Product {
114
138
  }
115
139
 
116
140
  setPromotionDiscount(promotionDiscount) {
117
- if (promotionDiscount === null|| Utils.isEmpty(promotionDiscount)){ Utils.showWarning(this.constructor.name + '-promotionDiscount'); return this;}
141
+ if (Utils.checkParameters([{ type: 'number', value: promotionDiscount }])) {
142
+ Utils.showParameterWarningLog(this.constructor.name + '-promotionDiscount');
143
+ return this;
144
+ }
118
145
 
119
146
  try {
120
147
  this.productOptMap[InsiderConstants.PROMOTION_DISCOUNT] = promotionDiscount;
@@ -126,7 +153,10 @@ class Product {
126
153
  }
127
154
 
128
155
  setStock(stock) {
129
- if (stock === null|| Utils.isEmpty(stock)){ Utils.showWarning(this.constructor.name + '-stock'); return this;}
156
+ if (Utils.checkParameters([{ type: 'number', value: stock }])) {
157
+ Utils.showParameterWarningLog(this.constructor.name + '-stock');
158
+ return this;
159
+ }
130
160
 
131
161
  try {
132
162
  this.productOptMap[InsiderConstants.STOCK] = stock;
@@ -138,7 +168,10 @@ class Product {
138
168
  }
139
169
 
140
170
  setQuantity(quantity) {
141
- if (quantity === null|| Utils.isEmpty(quantity)|| Utils.isEmpty(quantity)){ Utils.showWarning(this.constructor.name + '-quantity'); return this;}
171
+ if (Utils.checkParameters([{ type: 'number', value: quantity }])) {
172
+ Utils.showParameterWarningLog(this.constructor.name + '-quantity');
173
+ return this;
174
+ }
142
175
 
143
176
  try {
144
177
  this.productOptMap[InsiderConstants.QUANTITY] = quantity;
@@ -150,7 +183,10 @@ class Product {
150
183
  }
151
184
 
152
185
  setCustomAttributeWithString(key, value) {
153
- if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithString key or value'); return this;}
186
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'string', value: value }])) {
187
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithString');
188
+ return this;
189
+ }
154
190
 
155
191
  try {
156
192
  this.productOptMap[key] = value;
@@ -162,7 +198,10 @@ class Product {
162
198
  }
163
199
 
164
200
  setCustomAttributeWithInt(key, value) {
165
- if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithInt key or value'); return this;}
201
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'number', value: value }])) {
202
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithInt');
203
+ return this;
204
+ }
166
205
 
167
206
  try {
168
207
  this.productOptMap[key] = value;
@@ -173,7 +212,10 @@ class Product {
173
212
  }
174
213
 
175
214
  setCustomAttributeWithBoolean(key, value) {
176
- if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithBoolean key or value'); return this;}
215
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'boolean', value: value }])) {
216
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithBoolean');
217
+ return this;
218
+ }
177
219
 
178
220
  try {
179
221
  this.productOptMap[key] = value;
@@ -184,7 +226,10 @@ class Product {
184
226
  }
185
227
 
186
228
  setCustomAttributeWithDouble(key, value) {
187
- if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDouble key or value'); return this;}
229
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'number', value: value }])) {
230
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithDouble');
231
+ return this;
232
+ }
188
233
 
189
234
  try {
190
235
  this.productOptMap[key] = value;
@@ -196,7 +241,10 @@ class Product {
196
241
  }
197
242
 
198
243
  setCustomAttributeWithDate(key, value) {
199
- if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDate key or value'); return this;}
244
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'object', value: value }])) {
245
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithDate');
246
+ return this;
247
+ }
200
248
 
201
249
  try {
202
250
  this.productOptMap[key] = value.toISOString();
@@ -208,7 +256,10 @@ class Product {
208
256
  }
209
257
 
210
258
  setCustomAttributeWithArray(key, value) {
211
- if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithArray key or value'); return this;}
259
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'object', value: value }])) {
260
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithArray');
261
+ return this;
262
+ }
212
263
 
213
264
  try {
214
265
  this.productOptMap[key] = value;
package/www/User.js CHANGED
@@ -7,7 +7,10 @@ class User {
7
7
  constructor() {}
8
8
 
9
9
  setGender(gender) {
10
- if (gender === null || Utils.isEmpty(gender)){ Utils.showWarning(this.constructor.name + '-gender'); return this;}
10
+ if (Utils.checkParameters([{ type: 'number', value: gender }])) {
11
+ Utils.showParameterWarningLog(this.constructor.name + '-setGender');
12
+ return this;
13
+ }
11
14
 
12
15
  try {
13
16
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_GENDER, [gender]);
@@ -19,7 +22,10 @@ class User {
19
22
  }
20
23
 
21
24
  setBirthday(birthday) {
22
- if (birthday === null || Utils.isEmpty(birthday)){ Utils.showWarning(this.constructor.name + '-birthday'); return this;}
25
+ if (Utils.checkParameters([{ type: 'string', value: birthday }])) {
26
+ Utils.showParameterWarningLog(this.constructor.name + '-setBirthday');
27
+ return this;
28
+ }
23
29
 
24
30
  try {
25
31
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_BIRTDAY, [birthday.toISOString()]);
@@ -30,7 +36,10 @@ class User {
30
36
  }
31
37
 
32
38
  setName(name) {
33
- if (name === null || Utils.isEmpty(name)){ Utils.showWarning(this.constructor.name + '-name'); return this;}
39
+ if (Utils.checkParameters([{ type: 'string', value: name }])) {
40
+ Utils.showParameterWarningLog(this.constructor.name + '-setName');
41
+ return this;
42
+ }
34
43
 
35
44
  try {
36
45
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_NAME, [name]);
@@ -41,7 +50,10 @@ class User {
41
50
  }
42
51
 
43
52
  setSurname(surname) {
44
- if (surname === null || Utils.isEmpty(surname)){ Utils.showWarning(this.constructor.name + '-surname'); return this;}
53
+ if (Utils.checkParameters([{ type: 'string', value: surname }])) {
54
+ Utils.showParameterWarningLog(this.constructor.name + '-setSurname');
55
+ return this;
56
+ }
45
57
 
46
58
  try {
47
59
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_SURNAME, [surname]);
@@ -53,7 +65,10 @@ class User {
53
65
  }
54
66
 
55
67
  setAge(age) {
56
- if (age === null || Utils.isEmpty(age)){ Utils.showWarning(this.constructor.name + '-age'); return this;}
68
+ if (Utils.checkParameters([{ type: 'string', value: age }])) {
69
+ Utils.showParameterWarningLog(this.constructor.name + '-setAge');
70
+ return this;
71
+ }
57
72
 
58
73
  try {
59
74
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_AGE, [age]);
@@ -66,7 +81,10 @@ class User {
66
81
 
67
82
 
68
83
  setEmail(email) {
69
- if (email === null || Utils.isEmpty(email)){ Utils.showWarning(this.constructor.name + '-email'); return this;}
84
+ if (Utils.checkParameters([{ type: 'string', value: email }])) {
85
+ Utils.showParameterWarningLog(this.constructor.name + '-setEmail');
86
+ return this;
87
+ }
70
88
 
71
89
  try {
72
90
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_EMAIL, [email]);
@@ -78,7 +96,10 @@ class User {
78
96
  }
79
97
 
80
98
  setPhoneNumber(phone) {
81
- if (phone === null || Utils.isEmpty(phone)){ Utils.showWarning(this.constructor.name + '-phone'); return this;}
99
+ if (Utils.checkParameters([{ type: 'string', value: phone }])) {
100
+ Utils.showParameterWarningLog(this.constructor.name + '-setPhoneNumber');
101
+ return this;
102
+ }
82
103
 
83
104
  try {
84
105
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_PHONE_NUMBER, [phone]);
@@ -90,7 +111,10 @@ class User {
90
111
  }
91
112
 
92
113
  setLanguage(language) {
93
- if (language === null || Utils.isEmpty(language)){ Utils.showWarning(this.constructor.name + '-language'); return this;}
114
+ if (Utils.checkParameters([{ type: 'string', value: language }])) {
115
+ Utils.showParameterWarningLog(this.constructor.name + '-setLanguage');
116
+ return this;
117
+ }
94
118
 
95
119
  try {
96
120
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LANGUAGE, [language]);
@@ -102,7 +126,10 @@ class User {
102
126
  }
103
127
 
104
128
  setLocale(locale) {
105
- if (locale === null || Utils.isEmpty(locale)){ Utils.showWarning(this.constructor.name + '-locale'); return this;}
129
+ if (Utils.checkParameters([{ type: 'string', value: locale }])) {
130
+ Utils.showParameterWarningLog(this.constructor.name + '-setLocale');
131
+ return this;
132
+ }
106
133
 
107
134
  try {
108
135
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LOCALE, [locale]);
@@ -114,7 +141,10 @@ class User {
114
141
  }
115
142
 
116
143
  setFacebookID(facebookID) {
117
- if (facebookID === null || Utils.isEmpty(facebookID)){ Utils.showWarning(this.constructor.name + '-facebookID'); return this;}
144
+ if (Utils.checkParameters([{ type: 'string', value: facebookID }])) {
145
+ Utils.showParameterWarningLog(this.constructor.name + '-setFacebookID');
146
+ return this;
147
+ }
118
148
 
119
149
  try {
120
150
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_FACEBOOK_ID, [facebookID]);
@@ -126,7 +156,10 @@ class User {
126
156
  }
127
157
 
128
158
  setTwitterID(twitterID) {
129
- if (twitterID === null || Utils.isEmpty(twitterID)){ Utils.showWarning(this.constructor.name + '-twitterID'); return this;}
159
+ if (Utils.checkParameters([{ type: 'string', value: twitterID }])) {
160
+ Utils.showParameterWarningLog(this.constructor.name + '-setTwitterID');
161
+ return this;
162
+ }
130
163
 
131
164
  try {
132
165
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_TWITTER_ID, [twitterID]);
@@ -138,7 +171,10 @@ class User {
138
171
  }
139
172
 
140
173
  setEmailOptin(emailOptIn) {
141
- if (emailOptIn === null || Utils.isEmpty(emailOptIn)){ Utils.showWarning(this.constructor.name + '-emailOptIn'); return this;}
174
+ if (Utils.checkParameters([{ type: 'boolean', value: emailOptIn }])) {
175
+ Utils.showParameterWarningLog(this.constructor.name + '-setEmailOptin');
176
+ return this;
177
+ }
142
178
 
143
179
  try {
144
180
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_EMAIL_OPTIN, [emailOptIn]);
@@ -150,7 +186,10 @@ class User {
150
186
  }
151
187
 
152
188
  setSMSOptin(smsOptIn) {
153
- if (smsOptIn === null || Utils.isEmpty(smsOptIn)){ Utils.showWarning(this.constructor.name + '-smsOptIn'); return this;}
189
+ if (Utils.checkParameters([{ type: 'boolean', value: emailOptIn }])) {
190
+ Utils.showParameterWarningLog(this.constructor.name + '-setSMSOptin');
191
+ return this;
192
+ }
154
193
 
155
194
  try {
156
195
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_SMS_OPTIN, [smsOptIn]);
@@ -161,7 +200,10 @@ class User {
161
200
  }
162
201
 
163
202
  setPushOptin(pushOptIn) {
164
- if (pushOptIn === null || Utils.isEmpty(pushOptIn)){ Utils.showWarning(this.constructor.name + '-pushOptIn'); return this;}
203
+ if (Utils.checkParameters([{ type: 'boolean', value: pushOptIn }])) {
204
+ Utils.showParameterWarningLog(this.constructor.name + '-setPushOptin');
205
+ return this;
206
+ }
165
207
 
166
208
  try {
167
209
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_PUSH_OPTIN, [pushOptIn]);
@@ -173,10 +215,13 @@ class User {
173
215
  }
174
216
 
175
217
  setLocationOptin(locationOptIn) {
176
- if (locationOptIn === null || locationOptIn == undefined) { Utils.showWarning(this.constructor.name + '-locationOptIn'); return this; }
218
+ if (Utils.checkParameters([{ type: 'boolean', value: locationOptIn }])) {
219
+ Utils.showParameterWarningLog(this.constructor.name + '-setLocationOptin');
220
+ return this;
221
+ }
177
222
 
178
223
  try {
179
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LOCATION_OPTIN, [!!locationOptIn]);
224
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LOCATION_OPTIN, [locationOptIn]);
180
225
  } catch (error) {
181
226
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
182
227
  }
@@ -185,7 +230,10 @@ class User {
185
230
  }
186
231
 
187
232
  setWhatsappOptin(whatsappOptin) {
188
- if (whatsappOptin === null || Utils.isEmpty(whatsappOptin)){ Utils.showWarning(this.constructor.name + '-whatsappOptin'); return this;}
233
+ if (Utils.checkParameters([{ type: 'boolean', value: whatsappOptin }])) {
234
+ Utils.showParameterWarningLog(this.constructor.name + '-setWhatsappOptin');
235
+ return this;
236
+ }
189
237
 
190
238
  try {
191
239
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_WHATSAPP_OPTIN, [whatsappOptin]);
@@ -198,11 +246,13 @@ class User {
198
246
 
199
247
  login(identifiers, insiderIDResult) {
200
248
  try {
201
- if (insiderIDResult !== null) {
249
+ if (!Utils.checkParameters([{ type: 'function', value: insiderIDResult }, { type: 'object', value: identifiers }])) {
202
250
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGIN, [identifiers, insiderIDResult]).then(id => insiderIDResult(id));
251
+ } else if (!Utils.checkParameters([{ type: 'object', value: identifiers }])) {
252
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGIN, [identifiers]);
253
+ } else {
254
+ Utils.showParameterWarningLog(this.constructor.name + '-login');
203
255
  }
204
-
205
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGIN, [identifiers]);
206
256
  } catch (error) {
207
257
  Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
208
258
  }
@@ -217,7 +267,10 @@ class User {
217
267
  }
218
268
 
219
269
  setCustomAttributeWithString(key, value) {
220
- if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithString key or value'); return this;}
270
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'string', value: value }])) {
271
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithString');
272
+ return this;
273
+ }
221
274
 
222
275
  try {
223
276
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_STRING, [key, value]);
@@ -229,7 +282,10 @@ class User {
229
282
  }
230
283
 
231
284
  setCustomAttributeWithInt(key, value) {
232
- if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithInt key or value'); return this;}
285
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'number', value: value }])) {
286
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithInt');
287
+ return this;
288
+ }
233
289
 
234
290
  try {
235
291
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_INT, [key, value]);
@@ -241,7 +297,10 @@ class User {
241
297
  }
242
298
 
243
299
  setCustomAttributeWithDouble(key, value) {
244
- if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDouble key or value'); return this;}
300
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'number', value: value }])) {
301
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithDouble');
302
+ return this;
303
+ }
245
304
 
246
305
  try {
247
306
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_DOUBLE, [key, value]);
@@ -253,7 +312,10 @@ class User {
253
312
  }
254
313
 
255
314
  setCustomAttributeWithBoolean(key, value) {
256
- if (key == null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithBoolean key or value'); return this;}
315
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'boolean', value: value }])) {
316
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithBoolean');
317
+ return this;
318
+ }
257
319
 
258
320
  try {
259
321
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_BOOLEAN, [key, value]);
@@ -265,7 +327,10 @@ class User {
265
327
  }
266
328
 
267
329
  setCustomAttributeWithDate(key, value) {
268
- if (key == null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDate key or value'); return this;}
330
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'object', value: value }])) {
331
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithDate');
332
+ return this;
333
+ }
269
334
 
270
335
  try {
271
336
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_DATE, [key, value.toISOString()]);
@@ -277,7 +342,10 @@ class User {
277
342
  }
278
343
 
279
344
  setCustomAttributeWithArray(key, value) {
280
- if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithArray key or value'); return this;}
345
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'object', value: value }])) {
346
+ Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithArray');
347
+ return this;
348
+ }
281
349
 
282
350
  try {
283
351
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_ARRAY, [key, value]);
@@ -289,7 +357,11 @@ class User {
289
357
  }
290
358
 
291
359
  unsetCustomAttribute(key) {
292
- if (key == null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-unsetCustomAttribute key'); return this;}
360
+ if (Utils.checkParameters([{ type: 'string', value: key }])) {
361
+ Utils.showParameterWarningLog(this.constructor.name + '-unsetCustomAttribute');
362
+ return this;
363
+ }
364
+
293
365
  try {
294
366
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.UNSET_CUSTOM_ATTRIBUTE, [key]);
295
367
  } catch (error) {
package/www/Utils.js CHANGED
@@ -7,12 +7,14 @@ module.exports = {
7
7
  });
8
8
  },
9
9
  generateJSONErrorString: (error) => {
10
- return ('[JavaScript Error] ' + error);
10
+ return ('[InsiderCordova][JavaScriptError] ' + error);
11
11
  },
12
- isEmpty(str) {
13
- return (!str || str.length === 0 );
12
+ checkParameters(parameters) {
13
+ return parameters.some((parameterConfig) => {
14
+ return parameterConfig.type !== typeof parameterConfig.value;
15
+ });
14
16
  },
15
- showWarning(name){
16
- console.log("[InsiderPlugin Warning] Value is null or empty: " + name);
17
+ showParameterWarningLog(functionName) {
18
+ console.warn("[InsiderCordova] paramaters is not valid, function: " + functionName);
17
19
  }
18
20
  };
@@ -1,8 +0,0 @@
1
- # This is a comment.
2
- # Each line is a file pattern followed by one or more owners.
3
-
4
- # These owners will be the default owners for everything in
5
- # the repo. Unless a later match takes precedence,
6
- # @global-owner1 and @global-owner2 will be requested for
7
- # review when someone opens a pull request.
8
- * @melih-useinsider
@@ -1,25 +0,0 @@
1
- name: gitleaks
2
- on: [push]
3
- env:
4
- GIT_DISCOVERY_ACROSS_FILESYSTEM: 1
5
-
6
- jobs:
7
- gitleaks:
8
- runs-on: self-runner-node
9
- steps:
10
- - name: Checkout Repository
11
- uses: actions/checkout@v2
12
- with:
13
- fetch-depth: '2'
14
- - name: Clone GitLeak Action
15
- uses: actions/checkout@v2
16
- with:
17
- repository: useinsider/gitleaks-action
18
- ref: master
19
- token: ${{ secrets.PAT }}
20
- path: .github/actions/gitleaks-action
21
- - name: Install Dependencies
22
- run: npm install
23
- working-directory: .github/actions/gitleaks-action
24
- - name: gitleaks-action
25
- uses: ./.github/actions/gitleaks-action
@@ -1,35 +0,0 @@
1
- name: Cordova Insider Release
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- version_name:
7
- required: true
8
- description: The new version name of the SDK to be released (1.3.0)
9
-
10
- jobs:
11
- release:
12
- if: github.actor == 'sonerdm' || github.actor == 'melih-useinsider'
13
- name: Create Release
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - name: Checkout code
18
- uses: actions/checkout@v3
19
- with:
20
- ref: develop
21
-
22
- - name: Publish Cordova SDK
23
- uses: actions/setup-node@v3.2.0
24
- with:
25
- node-version: 12
26
- registry-url: https://registry.npmjs.org/
27
- run: |
28
- npm ci
29
- npm test
30
- npm publish
31
- text=":iphone: Cordova SDK is published with version: ${{ github.event.inputs.version_name }}"
32
- ./slack_notifier.sh mob-deployment mob-sdk-releaser "$text"
33
- env:
34
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35
- SLACK_NOTIFIER_AUTH_KEY: ${{ secrets.SLACK_NOTIFIER_AUTH_KEY }}
@@ -1,22 +0,0 @@
1
- name: Release Task Merger
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- version_name:
7
- required: true
8
- description: The new version name of the SDK to be released (1.3.0)
9
-
10
- jobs:
11
- sdk_releaser:
12
- if: github.actor == 'sonerdm' || github.actor == 'melih-useinsider'
13
- name: Trigger mobile-devops repository task merger
14
- runs-on: ubuntu-latest
15
- steps:
16
- - name: Repository Dispatch
17
- uses: peter-evans/repository-dispatch@v1
18
- with:
19
- token: ${{ secrets.GIT_TOKEN }}
20
- repository: useinsider/mobile-devops
21
- event-type: sdk-release-module
22
- client-payload: '{"repo-name": "insider-cordova-SDK", "sdk_version_name": "${{ github.event.inputs.version_name }}"}'
@@ -1,43 +0,0 @@
1
- name: Release Version Setter
2
-
3
- on:
4
- repository_dispatch:
5
- types: [trigger-release-version-setter]
6
-
7
- jobs:
8
- release_version_setter:
9
- name: Run Version Setter
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: Checkout code
13
- uses: actions/checkout@v3
14
- with:
15
- ref: develop
16
-
17
- - name: Configure AWS credentials
18
- uses: aws-actions/configure-aws-credentials@v1
19
- with:
20
- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
21
- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
22
- aws-region: eu-west-1
23
-
24
- - name: Run release_version.sh
25
- run: |
26
- ./release_version.sh ${{ github.event.client_payload.sdk_version_name }}
27
-
28
- - name: Push changes to develop
29
- run: |
30
- git config --global user.name 'sonerdm'
31
- git config --global user.email 'soner@useinsider.com'
32
- git remote set-url origin https://x-access-token:${{ secrets.GIT_TOKEN }}@github.com/${{ github.repository }}
33
- git commit -am "Release version ${{ github.event.client_payload.sdk_version_name }}"
34
- git push
35
- env:
36
- GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
37
-
38
- - name: Notify QAs
39
- run: |
40
- text=":tatakae: Cordova SDK is ready to test with version: ${{ github.event.client_payload.sdk_version_name }} <!subteam^SUUGFQNVA|mobileqa>"
41
- ./slack_notifier.sh mob-deployment mob-sdk-releaser "$text"
42
- env:
43
- SLACK_NOTIFIER_AUTH_KEY: ${{ secrets.SLACK_NOTIFIER_AUTH_KEY }}