cordova-plugin-insider 3.0.2 → 3.1.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/package.json +1 -1
- package/plugin.xml +6 -2
- package/src/android/CDVUtils.java +279 -44
- package/src/android/Constants.java +2 -0
- package/src/android/InsiderPlugin.java +150 -238
- package/src/android/build-extras.gradle +1 -1
- package/src/ios/CDVUtils.h +14 -0
- package/src/ios/CDVUtils.m +228 -0
- package/src/ios/InsiderPlugin.m +88 -20
- package/types/Product.d.ts +10 -0
- package/www/CallbackType.js +0 -11
- package/www/Constants.js +0 -114
- package/www/ContentOptimizerDataType.js +0 -6
- package/www/Event.js +0 -190
- package/www/Gender.js +0 -7
- package/www/Identifier.js +0 -96
- package/www/InsiderPlugin.js +0 -742
- package/www/Product.js +0 -507
- package/www/User.js +0 -482
- package/www/Utils.js +0 -39
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#import "CDVUtils.h"
|
|
2
|
+
|
|
3
|
+
@implementation CDVUtils
|
|
4
|
+
|
|
5
|
+
+ (InsiderEvent *)parseEventFromEventName:(NSString *)eventName
|
|
6
|
+
andParameters:(NSArray *)parameters {
|
|
7
|
+
|
|
8
|
+
InsiderEvent *event = [Insider tagEvent:eventName];
|
|
9
|
+
|
|
10
|
+
if (![parameters isKindOfClass:[NSArray class]]) {
|
|
11
|
+
return event;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
for (id item in parameters) {
|
|
15
|
+
if (![item isKindOfClass:[NSDictionary class]]) continue;
|
|
16
|
+
|
|
17
|
+
NSDictionary *parameter = (NSDictionary *)item;
|
|
18
|
+
|
|
19
|
+
NSString *type = parameter[@"type"];
|
|
20
|
+
NSString *key = parameter[@"key"];
|
|
21
|
+
if (![type isKindOfClass:[NSString class]] || ![key isKindOfClass:[NSString class]]) continue;
|
|
22
|
+
|
|
23
|
+
id value = parameter[@"value"];
|
|
24
|
+
|
|
25
|
+
if ([type isEqualToString:@"string"] && [value isKindOfClass:[NSString class]]) {
|
|
26
|
+
NSString *stringValue = value;
|
|
27
|
+
event.addParameterWithString(key, stringValue);
|
|
28
|
+
}
|
|
29
|
+
else if ([type isEqualToString:@"integer"] && [value isKindOfClass:[NSNumber class]]) {
|
|
30
|
+
NSNumber *numberValue = value;
|
|
31
|
+
int integerValue = (int)(numberValue != nil ? numberValue.integerValue : 0);
|
|
32
|
+
event.addParameterWithInt(key, integerValue);
|
|
33
|
+
}
|
|
34
|
+
else if ([type isEqualToString:@"double"] && [value isKindOfClass:[NSNumber class]]) {
|
|
35
|
+
NSNumber *numberValue = value;
|
|
36
|
+
double doubleValue = (numberValue != nil ? numberValue.doubleValue : 0.0);
|
|
37
|
+
event.addParameterWithDouble(key, doubleValue);
|
|
38
|
+
}
|
|
39
|
+
else if ([type isEqualToString:@"boolean"] && [value isKindOfClass:[NSNumber class]]) {
|
|
40
|
+
NSNumber *numberValue = value;
|
|
41
|
+
BOOL booleanValue = (numberValue != nil ? numberValue.boolValue : NO);
|
|
42
|
+
event.addParameterWithBoolean(key, booleanValue);
|
|
43
|
+
}
|
|
44
|
+
else if ([type isEqualToString:@"date"] && [value isKindOfClass:[NSString class]]) {
|
|
45
|
+
long long epochMillis = [(NSString *)value longLongValue];
|
|
46
|
+
NSTimeInterval seconds = ((NSTimeInterval)epochMillis) / 1000.0;
|
|
47
|
+
NSDate *dateValue = [NSDate dateWithTimeIntervalSince1970:seconds];
|
|
48
|
+
event.addParameterWithDate(key, dateValue);
|
|
49
|
+
}
|
|
50
|
+
else if ([type isEqualToString:@"strings"] && [value isKindOfClass:[NSArray class]]) {
|
|
51
|
+
NSArray * stringsValue = value;
|
|
52
|
+
event.addParameterWithStringArray(key, stringsValue);
|
|
53
|
+
}
|
|
54
|
+
else if ([type isEqualToString:@"numbers"] && [value isKindOfClass:[NSArray class]]) {
|
|
55
|
+
NSArray * numbersValue = value;
|
|
56
|
+
event.addParameterWithNumericArray(key, numbersValue);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return event;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
+ (nonnull InsiderProduct *)parseProductFromRequiredFields:(nonnull NSDictionary *)requiredFields
|
|
64
|
+
andOptionalFields:(nullable NSDictionary *)optionalFields
|
|
65
|
+
andCustomParameters:(nullable NSArray *)customParameters {
|
|
66
|
+
|
|
67
|
+
/// Apply required fields
|
|
68
|
+
NSString *productId = requiredFields[@"product_id"];
|
|
69
|
+
NSString *name = requiredFields[@"name"];
|
|
70
|
+
NSArray *taxonomy = requiredFields[@"taxonomy"];
|
|
71
|
+
NSString *imageURL = requiredFields[@"image_url"];
|
|
72
|
+
NSNumber *priceNumber = requiredFields[@"unit_price"];
|
|
73
|
+
double price = [priceNumber isKindOfClass:[NSNumber class]] ? priceNumber.doubleValue : 0.0;
|
|
74
|
+
NSString *currency = requiredFields[@"currency"];
|
|
75
|
+
|
|
76
|
+
InsiderProduct *product = [Insider createNewProductWithID:productId name:name taxonomy:taxonomy imageURL:imageURL price:price currency:currency];
|
|
77
|
+
|
|
78
|
+
/// Apply optional fields
|
|
79
|
+
for (NSString *key in optionalFields) {
|
|
80
|
+
id value = optionalFields[key];
|
|
81
|
+
|
|
82
|
+
if ([key isEqualToString:@"color"]) {
|
|
83
|
+
NSString *color = (NSString *)value;
|
|
84
|
+
product.setColor(color);
|
|
85
|
+
}
|
|
86
|
+
else if ([key isEqualToString:@"voucher_name"]) {
|
|
87
|
+
NSString *voucherName = (NSString *)value;
|
|
88
|
+
product.setVoucherName(voucherName);
|
|
89
|
+
}
|
|
90
|
+
else if ([key isEqualToString:@"promotion_name"]) {
|
|
91
|
+
NSString *promotionName = (NSString *)value;
|
|
92
|
+
product.setPromotionName(promotionName);
|
|
93
|
+
}
|
|
94
|
+
else if ([key isEqualToString:@"size"]) {
|
|
95
|
+
NSString *size = (NSString *)value;
|
|
96
|
+
product.setSize(size);
|
|
97
|
+
}
|
|
98
|
+
else if ([key isEqualToString:@"sale_price"]) {
|
|
99
|
+
NSNumber *salePriceNumber = (NSNumber *)value;
|
|
100
|
+
double salePrice = salePriceNumber.doubleValue;
|
|
101
|
+
product.setSalePrice(salePrice);
|
|
102
|
+
}
|
|
103
|
+
else if ([key isEqualToString:@"shipping_cost"]) {
|
|
104
|
+
NSNumber *shippingCostNumber = (NSNumber *)value;
|
|
105
|
+
double shippingCost = shippingCostNumber.doubleValue;
|
|
106
|
+
product.setShippingCost(shippingCost);
|
|
107
|
+
}
|
|
108
|
+
else if ([key isEqualToString:@"voucher_discount"]) {
|
|
109
|
+
NSNumber *voucherDiscountNumber = (NSNumber *)value;
|
|
110
|
+
double voucherDiscount = voucherDiscountNumber.doubleValue;
|
|
111
|
+
product.setVoucherDiscount(voucherDiscount);
|
|
112
|
+
}
|
|
113
|
+
else if ([key isEqualToString:@"promotion_discount"]) {
|
|
114
|
+
NSNumber *promotionDiscountNumber = (NSNumber *)value;
|
|
115
|
+
double promotionDiscount = promotionDiscountNumber.doubleValue;
|
|
116
|
+
product.setPromotionDiscount(promotionDiscount);
|
|
117
|
+
}
|
|
118
|
+
else if ([key isEqualToString:@"stock"]) {
|
|
119
|
+
NSNumber *stockNumber = (NSNumber *)value;
|
|
120
|
+
int stock = stockNumber.intValue;
|
|
121
|
+
product.setStock(stock);
|
|
122
|
+
}
|
|
123
|
+
else if ([key isEqualToString:@"quantity"]) {
|
|
124
|
+
NSNumber *quantityNumber = (NSNumber *)value;
|
|
125
|
+
int quantity = quantityNumber.intValue;
|
|
126
|
+
product.setQuantity(quantity);
|
|
127
|
+
}
|
|
128
|
+
else if ([key isEqualToString:@"group_code"]) {
|
|
129
|
+
NSString *groupCode = (NSString *)value;
|
|
130
|
+
product.setGroupCode(groupCode);
|
|
131
|
+
}
|
|
132
|
+
else if ([key isEqualToString:@"brand"]) {
|
|
133
|
+
NSString *brand = (NSString *)value;
|
|
134
|
+
product.setBrand(brand);
|
|
135
|
+
}
|
|
136
|
+
else if ([key isEqualToString:@"sku"]) {
|
|
137
|
+
NSString *sku = (NSString *)value;
|
|
138
|
+
product.setSku(sku);
|
|
139
|
+
}
|
|
140
|
+
else if ([key isEqualToString:@"gender"]) {
|
|
141
|
+
NSString *gender = (NSString *)value;
|
|
142
|
+
product.setGender(gender);
|
|
143
|
+
}
|
|
144
|
+
else if ([key isEqualToString:@"multipack"]) {
|
|
145
|
+
NSString *multipack = (NSString *)value;
|
|
146
|
+
product.setMultipack(multipack);
|
|
147
|
+
}
|
|
148
|
+
else if ([key isEqualToString:@"product_type"]) {
|
|
149
|
+
NSString *productType = (NSString *)value;
|
|
150
|
+
product.setProductType(productType);
|
|
151
|
+
}
|
|
152
|
+
else if ([key isEqualToString:@"gtin"]) {
|
|
153
|
+
NSString *gtin = (NSString *)value;
|
|
154
|
+
product.setGtin(gtin);
|
|
155
|
+
}
|
|
156
|
+
else if ([key isEqualToString:@"description"]) {
|
|
157
|
+
NSString *desc = (NSString *)value;
|
|
158
|
+
product.setDescription(desc);
|
|
159
|
+
}
|
|
160
|
+
else if ([key isEqualToString:@"tags"]) {
|
|
161
|
+
NSArray *tagsArray = (NSArray *)value;
|
|
162
|
+
product.setTags(tagsArray);
|
|
163
|
+
}
|
|
164
|
+
else if ([key isEqualToString:@"in_stock"]) {
|
|
165
|
+
NSNumber *inStockNumber = (NSNumber *)value;
|
|
166
|
+
BOOL inStock = inStockNumber.boolValue;
|
|
167
|
+
product.setInStock(inStock);
|
|
168
|
+
}
|
|
169
|
+
else if ([key isEqualToString:@"product_url"]) {
|
|
170
|
+
NSString *productURL = (NSString *)value;
|
|
171
|
+
product.setProductURL(productURL);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/// Apply custom parameters
|
|
176
|
+
for (id item in customParameters) {
|
|
177
|
+
if (![item isKindOfClass:[NSDictionary class]]) continue;
|
|
178
|
+
|
|
179
|
+
NSDictionary *parameter = (NSDictionary *)item;
|
|
180
|
+
|
|
181
|
+
NSString *type = parameter[@"type"];
|
|
182
|
+
NSString *key = parameter[@"key"];
|
|
183
|
+
if (![type isKindOfClass:[NSString class]] || ![key isKindOfClass:[NSString class]]) continue;
|
|
184
|
+
|
|
185
|
+
id value = parameter[@"value"];
|
|
186
|
+
|
|
187
|
+
if ([type isEqualToString:@"string"] && [value isKindOfClass:[NSString class]]) {
|
|
188
|
+
NSString *stringValue = (NSString *)value;
|
|
189
|
+
product.setCustomAttributeWithString(key, stringValue);
|
|
190
|
+
}
|
|
191
|
+
else if ([type isEqualToString:@"integer"] && [value isKindOfClass:[NSNumber class]]) {
|
|
192
|
+
NSNumber *numberValue = (NSNumber *)value;
|
|
193
|
+
int intValue = (int)numberValue.integerValue;
|
|
194
|
+
product.setCustomAttributeWithInt(key, intValue);
|
|
195
|
+
}
|
|
196
|
+
else if ([type isEqualToString:@"double"] && [value isKindOfClass:[NSNumber class]]) {
|
|
197
|
+
NSNumber *numberValue = (NSNumber *)value;
|
|
198
|
+
double doubleValue = numberValue.doubleValue;
|
|
199
|
+
product.setCustomAttributeWithDouble(key, doubleValue);
|
|
200
|
+
}
|
|
201
|
+
else if ([type isEqualToString:@"boolean"] && [value isKindOfClass:[NSNumber class]]) {
|
|
202
|
+
NSNumber *numberValue = (NSNumber *)value;
|
|
203
|
+
BOOL booleanValue = numberValue.boolValue;
|
|
204
|
+
product.setCustomAttributeWithBoolean(key, booleanValue);
|
|
205
|
+
}
|
|
206
|
+
else if ([type isEqualToString:@"date"] && [value isKindOfClass:[NSString class]]) {
|
|
207
|
+
// Epoch millis passed as string from RN
|
|
208
|
+
NSString *epochString = (NSString *)value;
|
|
209
|
+
long long epochMillis = epochString.longLongValue;
|
|
210
|
+
NSTimeInterval seconds = ((NSTimeInterval)epochMillis) / 1000.0;
|
|
211
|
+
NSDate *dateValue = [NSDate dateWithTimeIntervalSince1970:seconds];
|
|
212
|
+
product.setCustomAttributeWithDate(key, dateValue);
|
|
213
|
+
}
|
|
214
|
+
else if ([type isEqualToString:@"strings"] && [value isKindOfClass:[NSArray class]]) {
|
|
215
|
+
NSArray *stringsValue = (NSArray *)value;
|
|
216
|
+
product.setCustomAttributeWithStringArray(key, stringsValue);
|
|
217
|
+
}
|
|
218
|
+
else if ([type isEqualToString:@"numbers"] && [value isKindOfClass:[NSArray class]]) {
|
|
219
|
+
NSArray *numbersValue = (NSArray *)value;
|
|
220
|
+
product.setCustomAttributeWithNumericArray(key, numbersValue);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return product;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@end
|
|
228
|
+
|
package/src/ios/InsiderPlugin.m
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <Cordova/CDV.h>
|
|
2
2
|
#import "InsiderPlugin.h"
|
|
3
|
+
#import "CDVUtils.h"
|
|
3
4
|
|
|
4
5
|
@interface InsiderPlugin (){
|
|
5
6
|
}
|
|
@@ -238,8 +239,12 @@
|
|
|
238
239
|
@try {
|
|
239
240
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
240
241
|
NSString* eventName = [[command arguments] objectAtIndex:0];
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
NSArray* parameters = [[command arguments] objectAtIndex:1];
|
|
243
|
+
|
|
244
|
+
InsiderEvent *event = [CDVUtils parseEventFromEventName:eventName andParameters:parameters];
|
|
245
|
+
if (event) {
|
|
246
|
+
[event build];
|
|
247
|
+
}
|
|
243
248
|
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
244
249
|
});
|
|
245
250
|
} @catch (NSException *exception) {
|
|
@@ -367,8 +372,11 @@
|
|
|
367
372
|
- (void)visitProductDetailPage:(CDVInvokedUrlCommand *)command {
|
|
368
373
|
@try {
|
|
369
374
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
370
|
-
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
371
|
-
|
|
375
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
376
|
+
NSDictionary *requiredFields = [command.arguments objectAtIndex:0];
|
|
377
|
+
NSDictionary *optionalFields = [command.arguments objectAtIndex:1];
|
|
378
|
+
NSArray *customParameters = [command.arguments objectAtIndex:2];
|
|
379
|
+
InsiderProduct* product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
372
380
|
[Insider visitProductDetailPageWithProduct:product];
|
|
373
381
|
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
374
382
|
});
|
|
@@ -381,7 +389,24 @@
|
|
|
381
389
|
@try {
|
|
382
390
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
383
391
|
if (![command.arguments objectAtIndex:0]) return;
|
|
384
|
-
|
|
392
|
+
NSArray *productsArray = [command.arguments objectAtIndex:0];
|
|
393
|
+
NSMutableArray *insiderProducts = [NSMutableArray array];
|
|
394
|
+
|
|
395
|
+
for (NSDictionary *productDict in productsArray) {
|
|
396
|
+
if (![productDict isKindOfClass:[NSDictionary class]]) continue;
|
|
397
|
+
NSDictionary *requiredFields = [productDict objectForKey:@"requiredFields"];
|
|
398
|
+
NSDictionary *optionalFields = [productDict objectForKey:@"optionalFields"];
|
|
399
|
+
NSArray *customParameters = [productDict objectForKey:@"customParameters"];
|
|
400
|
+
|
|
401
|
+
if (requiredFields) {
|
|
402
|
+
InsiderProduct *product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
403
|
+
if (product) {
|
|
404
|
+
[insiderProducts addObject:product];
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
[InsiderHybrid visitCartPage:insiderProducts];
|
|
385
410
|
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
386
411
|
});
|
|
387
412
|
} @catch (NSException *e) {
|
|
@@ -392,8 +417,11 @@
|
|
|
392
417
|
- (void)itemPurchased:(CDVInvokedUrlCommand *)command {
|
|
393
418
|
@try {
|
|
394
419
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
395
|
-
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
396
|
-
|
|
420
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2] || ![command.arguments objectAtIndex:3]) return;
|
|
421
|
+
NSDictionary *requiredFields = [command.arguments objectAtIndex:1];
|
|
422
|
+
NSDictionary *optionalFields = [command.arguments objectAtIndex:2];
|
|
423
|
+
NSArray *customParameters = [command.arguments objectAtIndex:3];
|
|
424
|
+
InsiderProduct *product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
397
425
|
[Insider itemPurchasedWithSaleID:[command.arguments objectAtIndex:0] product:product];
|
|
398
426
|
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
399
427
|
});
|
|
@@ -405,8 +433,11 @@
|
|
|
405
433
|
- (void)itemAddedToCart:(CDVInvokedUrlCommand *)command {
|
|
406
434
|
@try {
|
|
407
435
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
408
|
-
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
409
|
-
|
|
436
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
437
|
+
NSDictionary *requiredFields = [command.arguments objectAtIndex:0];
|
|
438
|
+
NSDictionary *optionalFields = [command.arguments objectAtIndex:1];
|
|
439
|
+
NSArray *customParameters = [command.arguments objectAtIndex:2];
|
|
440
|
+
InsiderProduct *product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
410
441
|
[Insider itemAddedToCartWithProduct:product];
|
|
411
442
|
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
412
443
|
});
|
|
@@ -454,9 +485,12 @@
|
|
|
454
485
|
- (void)getSmartRecommendationWithProduct:(CDVInvokedUrlCommand *)command {
|
|
455
486
|
@try {
|
|
456
487
|
[self.commandDelegate runInBackground:^{
|
|
457
|
-
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2] || ![command.arguments objectAtIndex:3]) return;
|
|
458
|
-
|
|
459
|
-
|
|
488
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2] || ![command.arguments objectAtIndex:3] || ![command.arguments objectAtIndex:4]) return;
|
|
489
|
+
NSDictionary *requiredFields = [command.arguments objectAtIndex:0];
|
|
490
|
+
NSDictionary *optionalFields = [command.arguments objectAtIndex:1];
|
|
491
|
+
NSArray *customParameters = [command.arguments objectAtIndex:2];
|
|
492
|
+
InsiderProduct *product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
493
|
+
[Insider getSmartRecommendationWithProduct:product recommendationID:[[command.arguments objectAtIndex:3] intValue] locale:[command.arguments objectAtIndex:4] smartRecommendation:^(NSDictionary *recommendation) {
|
|
460
494
|
[self sendSuccessResultWithDictionary:recommendation andCommand:command];
|
|
461
495
|
}];
|
|
462
496
|
}];
|
|
@@ -482,9 +516,12 @@
|
|
|
482
516
|
- (void)clickSmartRecommendationProduct:(CDVInvokedUrlCommand *)command {
|
|
483
517
|
@try {
|
|
484
518
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
485
|
-
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
486
|
-
|
|
487
|
-
|
|
519
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2] || ![command.arguments objectAtIndex:3]) return;
|
|
520
|
+
NSDictionary *requiredFields = [command.arguments objectAtIndex:0];
|
|
521
|
+
NSDictionary *optionalFields = [command.arguments objectAtIndex:1];
|
|
522
|
+
NSArray *customParameters = [command.arguments objectAtIndex:2];
|
|
523
|
+
InsiderProduct *product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
524
|
+
[Insider clickSmartRecommendationProductWithID:[[command.arguments objectAtIndex:3] intValue] product:product];
|
|
488
525
|
});
|
|
489
526
|
} @catch (NSException *e) {
|
|
490
527
|
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
@@ -522,7 +559,13 @@
|
|
|
522
559
|
- (void)setBirthday:(CDVInvokedUrlCommand *)command {
|
|
523
560
|
@try {
|
|
524
561
|
if (![command.arguments objectAtIndex:0]) return;
|
|
525
|
-
|
|
562
|
+
// value is epoch milliseconds as string
|
|
563
|
+
NSString *epochString = [command.arguments objectAtIndex:0];
|
|
564
|
+
long long epochMillis = [epochString longLongValue];
|
|
565
|
+
NSTimeInterval seconds = ((NSTimeInterval)epochMillis) / 1000.0;
|
|
566
|
+
NSDate *birthday = [NSDate dateWithTimeIntervalSince1970:seconds];
|
|
567
|
+
|
|
568
|
+
[Insider getCurrentUser].setBirthday(birthday);
|
|
526
569
|
} @catch (NSException *e) {
|
|
527
570
|
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
528
571
|
}
|
|
@@ -702,7 +745,12 @@
|
|
|
702
745
|
- (void)setCustomAttributeWithDate:(CDVInvokedUrlCommand *)command {
|
|
703
746
|
@try {
|
|
704
747
|
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
705
|
-
|
|
748
|
+
// value is epoch milliseconds as string
|
|
749
|
+
NSString *epochString = [command.arguments objectAtIndex:1];
|
|
750
|
+
long long epochMillis = [epochString longLongValue];
|
|
751
|
+
NSTimeInterval seconds = ((NSTimeInterval)epochMillis) / 1000.0;
|
|
752
|
+
NSDate *dateValue = [NSDate dateWithTimeIntervalSince1970:seconds];
|
|
753
|
+
[Insider getCurrentUser].setCustomAttributeWithDate([command.arguments objectAtIndex:0], dateValue);
|
|
706
754
|
|
|
707
755
|
} @catch (NSException *e) {
|
|
708
756
|
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
@@ -909,9 +957,12 @@
|
|
|
909
957
|
- (void)itemAddedToWishlist:(CDVInvokedUrlCommand *)command {
|
|
910
958
|
@try {
|
|
911
959
|
[self.commandDelegate runInBackground:^{
|
|
912
|
-
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
960
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
913
961
|
|
|
914
|
-
|
|
962
|
+
NSDictionary *requiredFields = [command.arguments objectAtIndex:0];
|
|
963
|
+
NSDictionary *optionalFields = [command.arguments objectAtIndex:1];
|
|
964
|
+
NSArray *customParameters = [command.arguments objectAtIndex:2];
|
|
965
|
+
InsiderProduct *product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
915
966
|
|
|
916
967
|
[Insider itemAddedToWishlistWithProduct:product];
|
|
917
968
|
|
|
@@ -951,7 +1002,24 @@
|
|
|
951
1002
|
@try {
|
|
952
1003
|
[self.commandDelegate runInBackground:^{
|
|
953
1004
|
if (![command.arguments objectAtIndex:0]) return;
|
|
954
|
-
|
|
1005
|
+
NSArray *productsArray = [command.arguments objectAtIndex:0];
|
|
1006
|
+
NSMutableArray *insiderProducts = [NSMutableArray array];
|
|
1007
|
+
|
|
1008
|
+
for (NSDictionary *productDict in productsArray) {
|
|
1009
|
+
if (![productDict isKindOfClass:[NSDictionary class]]) continue;
|
|
1010
|
+
NSDictionary *requiredFields = [productDict objectForKey:@"requiredFields"];
|
|
1011
|
+
NSDictionary *optionalFields = [productDict objectForKey:@"optionalFields"];
|
|
1012
|
+
NSArray *customParameters = [productDict objectForKey:@"customParameters"];
|
|
1013
|
+
|
|
1014
|
+
if (requiredFields) {
|
|
1015
|
+
InsiderProduct *product = [CDVUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
|
|
1016
|
+
if (product) {
|
|
1017
|
+
[insiderProducts addObject:product];
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
[Insider visitWishlistWithProducts:insiderProducts];
|
|
955
1023
|
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
956
1024
|
}];
|
|
957
1025
|
} @catch (NSException *e) {
|
package/types/Product.d.ts
CHANGED
|
@@ -10,6 +10,16 @@ export interface Product {
|
|
|
10
10
|
setStock(setStock: number):Product;
|
|
11
11
|
setQuantity(quantity: number):Product;
|
|
12
12
|
setGroupCode(groupCode: string):Product;
|
|
13
|
+
setBrand(brand: string):Product;
|
|
14
|
+
setGender(gender: string):Product;
|
|
15
|
+
setDescription(description: string):Product;
|
|
16
|
+
setSku(sku: string):Product;
|
|
17
|
+
setMultipack(multipack: string):Product;
|
|
18
|
+
setProductType(productType: string):Product;
|
|
19
|
+
setGtin(gtin: string):Product;
|
|
20
|
+
setTags(tags: string[]):Product;
|
|
21
|
+
setInStock(isInStock: boolean):Product;
|
|
22
|
+
setProductURL(productURL: string):Product;
|
|
13
23
|
setCustomAttributeWithString(key: string, value: string):Product;
|
|
14
24
|
setCustomAttributeWithInt(key: string, value: number):Product;
|
|
15
25
|
setCustomAttributeWithBoolean(key: string, value: boolean):Product;
|
package/www/CallbackType.js
DELETED
package/www/Constants.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
// Main Class Name
|
|
5
|
-
CLASS: 'InsiderPlugin',
|
|
6
|
-
// User
|
|
7
|
-
SET_GENDER: 'setGender',
|
|
8
|
-
SET_BIRTDAY: 'setBirthday',
|
|
9
|
-
SET_NAME: 'setName',
|
|
10
|
-
SET_SURNAME: 'setSurname',
|
|
11
|
-
SET_AGE: 'setAge',
|
|
12
|
-
SET_EMAIL: 'setEmail',
|
|
13
|
-
SET_PHONE_NUMBER: 'setPhoneNumber',
|
|
14
|
-
SET_LANGUAGE: 'setLanguage',
|
|
15
|
-
SET_LOCALE: 'setLocale',
|
|
16
|
-
SET_FACEBOOK_ID: 'setFacebookID',
|
|
17
|
-
SET_TWITTER_ID: 'setTwitterID',
|
|
18
|
-
SET_EMAIL_OPTIN: 'setEmailOptin',
|
|
19
|
-
SET_SMS_OPTIN: 'setSMSOptin',
|
|
20
|
-
SET_PUSH_OPTIN: 'setPushOptin',
|
|
21
|
-
SET_LOCATION_OPTIN: 'setLocationOptin',
|
|
22
|
-
SET_WHATSAPP_OPTIN: 'setWhatsappOptin',
|
|
23
|
-
LOGIN: 'login',
|
|
24
|
-
LOGOUT: 'logout',
|
|
25
|
-
LOGOUT_RESETTING_INSIDER_ID: 'logoutResettingInsiderID',
|
|
26
|
-
SET_CUSTOM_ATTRIBUTE_WITH_STRING: 'setCustomAttributeWithString',
|
|
27
|
-
SET_CUSTOM_ATTRIBUTE_WITH_INT: 'setCustomAttributeWithInt',
|
|
28
|
-
SET_CUSTOM_ATTRIBUTE_WITH_DOUBLE: 'setCustomAttributeWithDouble',
|
|
29
|
-
SET_CUSTOM_ATTRIBUTE_WITH_BOOLEAN: 'setCustomAttributeWithBoolean',
|
|
30
|
-
SET_CUSTOM_ATTRIBUTE_WITH_DATE: 'setCustomAttributeWithDate',
|
|
31
|
-
SET_CUSTOM_ATTRIBUTE_WITH_ARRAY: 'setCustomAttributeWithArray',
|
|
32
|
-
UNSET_CUSTOM_ATTRIBUTE: 'unsetCustomAttribute',
|
|
33
|
-
// User Identifier
|
|
34
|
-
ADD_EMAIL: 'addEmail',
|
|
35
|
-
ADD_PHONE_NUMBER: 'addPhoneNumber',
|
|
36
|
-
ADD_USER_ID: 'addUserID',
|
|
37
|
-
// Insider Functions
|
|
38
|
-
INIT_WITH_CUSTOM_ENDPOINT: 'initWithCustomEndpoint',
|
|
39
|
-
INIT_WITH_LAUNCH_OPTIONS: 'initWithLaunchOptions',
|
|
40
|
-
INIT: 'init',
|
|
41
|
-
ITEM_PURCHASED: 'itemPurchased',
|
|
42
|
-
ITEM_ADDED_TO_CART: 'itemAddedToCart',
|
|
43
|
-
ITEM_REMOVED_FROM_CART: 'itemRemovedFromCart',
|
|
44
|
-
CART_CLEARED: 'cartCleared',
|
|
45
|
-
GET_MESSAGE_CENTER_DATA: 'getMessageCenterData',
|
|
46
|
-
GET_SMART_RECOMMENDATION: 'getSmartRecommendation',
|
|
47
|
-
GET_SMART_RECOMMENDATION_WITH_PRODUCT: 'getSmartRecommendationWithProduct',
|
|
48
|
-
GET_SMART_RECOMMENDATION_WITH_PRODUCT_IDS: 'getSmartRecommendationWithProductIDs',
|
|
49
|
-
CLICK_SMART_RECOMMENDATION_PRODUCT: 'clickSmartRecommendationProduct',
|
|
50
|
-
GET_CONTENT_STRING_WITH_NAME: 'getContentStringWithName',
|
|
51
|
-
GET_CONTENT_BOOL_WITH_NAME: 'getContentBoolWithName',
|
|
52
|
-
GET_CONTENT_INT_WITH_NAME: 'getContentIntWithName',
|
|
53
|
-
GET_CONTENT_STRING_WITHOUT_CACHE: 'getContentStringWithoutCache',
|
|
54
|
-
GET_CONTENT_BOOL_WITHOUT_CACHE: 'getContentBoolWithoutCache',
|
|
55
|
-
GET_CONTENT_INT_WITHOUT_CACHE: 'getContentIntWithoutCache',
|
|
56
|
-
VISIT_HOME_PAGE: 'visitHomePage',
|
|
57
|
-
VISIT_LISTING_PAGE: 'visitListingPage',
|
|
58
|
-
VISIT_PRODUCT_DETAIL_PAGE: 'visitProductDetailPage',
|
|
59
|
-
VISIT_CART_PAGE: 'visitCartPage',
|
|
60
|
-
START_TRACKING_GEOFENCE: 'startTrackingGeofence',
|
|
61
|
-
SET_GDPR_CONSENT: 'setGDPRConsent',
|
|
62
|
-
SET_MOBILE_APP_ACCESS: 'setMobileAppAccess',
|
|
63
|
-
REMOVE_IN_APP: 'removeInapp',
|
|
64
|
-
REGISTER_WITH_QUIET_PERMISSION: 'registerWithQuietPermission',
|
|
65
|
-
SET_HYBRID_PUSH_TOKEN: 'setPushToken',
|
|
66
|
-
ENABLE_IDFA_COLLECTION: 'enableIDFACollection',
|
|
67
|
-
ENABLE_LOCATION_COLLECTION: 'enableLocationCollection',
|
|
68
|
-
ENABLE_IP_COLLECTION: 'enableIpCollection',
|
|
69
|
-
ENABLE_CARRIER_COLLECTION: 'enableCarrierCollection',
|
|
70
|
-
SIGN_UP_CONFIRMATION: 'signUpConfirmation',
|
|
71
|
-
SET_ACTIVE_FOREGROUND_PUSH_VIEW: 'setActiveForegroundPushView',
|
|
72
|
-
SET_FOREGROUND_PUSH_CALLBACK: 'setForegroundPushCallback',
|
|
73
|
-
HANDLE_NOTIFICATION: 'handleNotification',
|
|
74
|
-
GET_INSIDER_ID: 'getInsiderID',
|
|
75
|
-
REGISTER_INSIDER_ID_LISTENER: 'registerInsiderIDListener',
|
|
76
|
-
DISABLE_IN_APP_MESSAGES: 'disableInAppMessages',
|
|
77
|
-
ENABLE_IN_APP_MESSAGES: 'enableInAppMessages',
|
|
78
|
-
ITEM_ADDED_TO_WISHLIST: 'itemAddedToWishlist',
|
|
79
|
-
ITEM_REMOVED_FROM_WISHLIST: 'itemRemovedFromWishlist',
|
|
80
|
-
WISHLIST_CLEARED: 'wishlistCleared',
|
|
81
|
-
VISIT_WISHLIST_PAGE: 'visitWishlistPage',
|
|
82
|
-
// Event
|
|
83
|
-
TAG_EVENT: 'tagEvent',
|
|
84
|
-
// Product Attribute
|
|
85
|
-
SALE_PRICE: 'sale_price',
|
|
86
|
-
STOCK: 'stock',
|
|
87
|
-
COLOR: 'color',
|
|
88
|
-
SIZE: 'size',
|
|
89
|
-
QUANTITY: 'quantity',
|
|
90
|
-
SHIPPING_COST: 'shipping_cost',
|
|
91
|
-
VOUCHER_NAME: 'voucher_name',
|
|
92
|
-
VOUCHER_DISCOUNT: 'voucher_discount',
|
|
93
|
-
PROMOTION_NAME: 'promotion_name',
|
|
94
|
-
PROMOTION_DISCOUNT: 'promotion_discount',
|
|
95
|
-
GROUP_CODE: 'groupcode',
|
|
96
|
-
BRAND: "brnd",
|
|
97
|
-
SKU: "sku",
|
|
98
|
-
PRODUCT_GENDER: "ge",
|
|
99
|
-
MULTIPACK: "mlt",
|
|
100
|
-
PRODUCT_TYPE: "pt",
|
|
101
|
-
GTIN: "gt",
|
|
102
|
-
DESCRIPTION: "desc",
|
|
103
|
-
TAGS: "tags",
|
|
104
|
-
IS_IN_STOCK: "iis",
|
|
105
|
-
// Error
|
|
106
|
-
PUT_ERROR_LOG: 'putErrorLog',
|
|
107
|
-
// Platform
|
|
108
|
-
ANDROID: 'android',
|
|
109
|
-
IOS: 'ios',
|
|
110
|
-
// Reinit
|
|
111
|
-
REINIT_WITH_PARTNER_NAME: 'reinitWithPartnerName',
|
|
112
|
-
// SDK Version
|
|
113
|
-
SDK_VERSION: 'CDV-3.0.2'
|
|
114
|
-
};
|