react-native-netmera 1.6.1 → 1.6.2
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/RNNetmera.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmera.java +1 -1
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +20 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraUtil.java +29 -0
- package/ios/RNNetmera.m +25 -1
- package/ios/RNNetmeraUtils.h +1 -0
- package/ios/RNNetmeraUtils.m +14 -0
- package/package.json +1 -1
- package/src/Netmera.ts +8 -0
- package/src/models/NetmeraCouponObject.ts +11 -0
package/RNNetmera.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -15,7 +15,7 @@ android {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
dependencies {
|
|
18
|
-
implementation 'com.netmera:nmcore:3.10.
|
|
18
|
+
implementation 'com.netmera:nmcore:3.10.4'
|
|
19
19
|
implementation 'com.netmera:nmfcm:3.10.2'
|
|
20
20
|
implementation 'com.netmera:nmhms:3.10.1'
|
|
21
21
|
implementation 'com.facebook.react:react-native:+'
|
|
@@ -23,7 +23,7 @@ public class RNNetmera {
|
|
|
23
23
|
static void setNetmeraHeaders() {
|
|
24
24
|
ContentValues headerValues = new ContentValues();
|
|
25
25
|
headerValues.put("X-netmera-framework", "react");
|
|
26
|
-
headerValues.put("X-netmera-frameworkV", "1.6.
|
|
26
|
+
headerValues.put("X-netmera-frameworkV", "1.6.2");
|
|
27
27
|
Netmera.setNetmeraHeaders(headerValues);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -28,8 +28,10 @@ import com.netmera.NetmeraInteractiveAction;
|
|
|
28
28
|
import com.netmera.NetmeraPushObject;
|
|
29
29
|
import com.netmera.callbacks.NMCategoryPreferenceFetchCallback;
|
|
30
30
|
import com.netmera.callbacks.NMCategoryPreferenceSetCallback;
|
|
31
|
+
import com.netmera.callbacks.NMFetchCouponsResultListener;
|
|
31
32
|
import com.netmera.callbacks.NMInboxCountResultListener;
|
|
32
33
|
import com.netmera.data.NMCategoryPreference;
|
|
34
|
+
import com.netmera.data.NMCouponDetail;
|
|
33
35
|
import com.netmera.data.NMInboxStatusCount;
|
|
34
36
|
import com.netmera.data.NMInboxStatusCountFilter;
|
|
35
37
|
|
|
@@ -66,6 +68,8 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
66
68
|
private static final String ERROR_MESSAGE_CATEGORY_PREFERENCE = "Error occurred while fetching user category preference list.";
|
|
67
69
|
private static final String ERROR_CODE_SET_CATEGORY_PREFERENCE = "2025";
|
|
68
70
|
private static final String ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = "Error occurred while setting user category preference list.";
|
|
71
|
+
private static final String ERROR_CODE_COUPON_FETCH = "2026";
|
|
72
|
+
private static final String ERROR_MESSAGE_COUPON_FETCH = "Error occurred while fetching coupons.";
|
|
69
73
|
|
|
70
74
|
public static ReactApplicationContext reactContext;
|
|
71
75
|
private NetmeraInbox netmeraInbox;
|
|
@@ -142,6 +146,22 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
142
146
|
Netmera.turnOffSendingEventAndUserUpdate(turnOff);
|
|
143
147
|
}
|
|
144
148
|
|
|
149
|
+
@ReactMethod
|
|
150
|
+
public void fetchCoupons(final int page, final int max, final Promise promise) {
|
|
151
|
+
Netmera.fetchCoupons(page, max, new NMFetchCouponsResultListener() {
|
|
152
|
+
|
|
153
|
+
@Override
|
|
154
|
+
public void onSuccess(@Nullable List<NMCouponDetail> list) {
|
|
155
|
+
promise.resolve(RNNetmeraUtil.mapCouponObjects(list));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@Override
|
|
159
|
+
public void onFailure(@Nullable String s) {
|
|
160
|
+
promise.reject(ERROR_CODE_COUPON_FETCH, ERROR_MESSAGE_COUPON_FETCH);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
145
165
|
@ReactMethod
|
|
146
166
|
public void fetchInbox(ReadableMap readableMap, final Promise promise) {
|
|
147
167
|
NetmeraInboxFilter.Builder builder = new NetmeraInboxFilter.Builder();
|
|
@@ -26,6 +26,7 @@ import com.netmera.NetmeraCarouselObject;
|
|
|
26
26
|
import com.netmera.NetmeraPushObject;
|
|
27
27
|
import com.netmera.NetmeraPushStyle;
|
|
28
28
|
import com.netmera.data.NMCategoryPreference;
|
|
29
|
+
import com.netmera.data.NMCouponDetail;
|
|
29
30
|
import com.netmera.data.NMInboxStatus;
|
|
30
31
|
import com.netmera.data.NMInboxStatusCount;
|
|
31
32
|
|
|
@@ -191,6 +192,34 @@ class RNNetmeraUtil {
|
|
|
191
192
|
return array;
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
public static WritableArray mapCouponObjects(List<NMCouponDetail> couponObjects) {
|
|
196
|
+
WritableArray couponObjectList = Arguments.createArray();
|
|
197
|
+
for (NMCouponDetail netmeraCouponObject : couponObjects) {
|
|
198
|
+
couponObjectList.pushMap(mapCouponObject(netmeraCouponObject));
|
|
199
|
+
}
|
|
200
|
+
return couponObjectList;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public static WritableMap mapCouponObject(NMCouponDetail couponObject) {
|
|
204
|
+
WritableMap couponObjectMap = Arguments.createMap();
|
|
205
|
+
if (couponObject == null) {
|
|
206
|
+
return couponObjectMap;
|
|
207
|
+
}
|
|
208
|
+
couponObjectMap.putString("couponId", couponObject.getCouponId());
|
|
209
|
+
couponObjectMap.putString("name", couponObject.getName());
|
|
210
|
+
couponObjectMap.putString("code", couponObject.getCode());
|
|
211
|
+
|
|
212
|
+
if (couponObject.getAssignDate() != null) {
|
|
213
|
+
couponObjectMap.putString("assignDate", couponObject.getAssignDate().toString());
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (couponObject.getExpireDate() != null) {
|
|
217
|
+
couponObjectMap.putString("expireDate", couponObject.getExpireDate().toString());
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return couponObjectMap;
|
|
221
|
+
}
|
|
222
|
+
|
|
194
223
|
public static WritableArray mapPushObjects(List<NetmeraPushObject> pushObjects) {
|
|
195
224
|
WritableArray pushObjectList = Arguments.createArray();
|
|
196
225
|
for (NetmeraPushObject netmeraPushObject : pushObjects) {
|
package/ios/RNNetmera.m
CHANGED
|
@@ -31,6 +31,8 @@ NSString *const ERROR_CODE_GET_CATEGORY_PREFERENCE = @"2024";
|
|
|
31
31
|
NSString *const ERROR_MESSAGE_GET_CATEGORY_PREFERENCE = @"Error occurred while fetching user category preference list.";
|
|
32
32
|
NSString *const ERROR_CODE_SET_CATEGORY_PREFERENCE = @"2025";
|
|
33
33
|
NSString *const ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = @"Error occurred while setting user category preference list.";
|
|
34
|
+
NSString *const ERROR_CODE_COUPON_FETCH = @"2026";
|
|
35
|
+
NSString *const ERROR_MESSAGE_COUPON_FETCH = @"Error occurred while fetching coupons.";
|
|
34
36
|
|
|
35
37
|
@implementation RNNetmera
|
|
36
38
|
|
|
@@ -46,7 +48,7 @@ NSString *const ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = @"Error occurred while s
|
|
|
46
48
|
|
|
47
49
|
+ (void)setNetmeraHeaders {
|
|
48
50
|
[Netmera setFramework:@"react"];
|
|
49
|
-
[Netmera setFrameworkVersion:@"1.6.
|
|
51
|
+
[Netmera setFrameworkVersion:@"1.6.2"];
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
+ (void)setPushDelegate:(NSObject<NetmeraPushDelegate> *)delegate {
|
|
@@ -131,6 +133,28 @@ RCT_EXPORT_METHOD(stopDataTransfer) {
|
|
|
131
133
|
[Netmera stopDataTransfer];
|
|
132
134
|
}
|
|
133
135
|
|
|
136
|
+
RCT_EXPORT_METHOD(fetchCoupons:(int)page
|
|
137
|
+
max: (int)max
|
|
138
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
139
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
140
|
+
NetmeraCouponFilter *filter = [[NetmeraCouponFilter alloc] init];
|
|
141
|
+
|
|
142
|
+
filter.page = page;
|
|
143
|
+
filter.max = max;
|
|
144
|
+
|
|
145
|
+
[Netmera fetchCouponUsingFilter:filter completion:^(NSArray<NetmeraCouponObject *> *coupons, NSError *error) {
|
|
146
|
+
if (error) {
|
|
147
|
+
reject(ERROR_CODE_COUPON_FETCH, ERROR_MESSAGE_COUPON_FETCH, nil);
|
|
148
|
+
} else {
|
|
149
|
+
NSMutableArray *array = [[NSMutableArray alloc]init];
|
|
150
|
+
for(NetmeraCouponObject *object in coupons){
|
|
151
|
+
[array addObject:[[RNNetmeraUtils shared] dictionaryFromCouponObject:object]];
|
|
152
|
+
}
|
|
153
|
+
resolve(array);
|
|
154
|
+
}
|
|
155
|
+
}];
|
|
156
|
+
}
|
|
157
|
+
|
|
134
158
|
RCT_EXPORT_METHOD(fetchInbox:(NSDictionary *)inboxDictionary
|
|
135
159
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
136
160
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
package/ios/RNNetmeraUtils.h
CHANGED
|
@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
15
15
|
|
|
16
16
|
+(RNNetmeraUtils *)shared;
|
|
17
17
|
|
|
18
|
+
-(NSDictionary *)dictionaryFromCouponObject:(NetmeraCouponObject *)couponObject;
|
|
18
19
|
-(NSDictionary *)dictionaryFromPushObject:(NetmeraPushObject *)pushObject;
|
|
19
20
|
-(NetmeraInboxStatus)getInboxStatus:(NSUInteger) code;
|
|
20
21
|
-(NSDictionary *)parseInboxCountForStatusToMap:(NetmeraInboxCountResponse *) response;
|
package/ios/RNNetmeraUtils.m
CHANGED
|
@@ -20,6 +20,20 @@ static RNNetmeraUtils *utils;
|
|
|
20
20
|
return utils;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
-(NSDictionary *)dictionaryFromCouponObject:(NetmeraCouponObject *)couponObject{
|
|
24
|
+
NSTimeInterval assignDateTs = [[couponObject assignDate] timeIntervalSince1970];
|
|
25
|
+
NSTimeInterval expireDateTs = [[couponObject expireDate] timeIntervalSince1970];
|
|
26
|
+
|
|
27
|
+
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
28
|
+
data[@"couponId"] = [couponObject couponId];
|
|
29
|
+
data[@"name"] = [couponObject name];
|
|
30
|
+
data[@"code"] = [couponObject code];
|
|
31
|
+
data[@"assignDate"] = [NSString stringWithFormat:@"%f", assignDateTs];
|
|
32
|
+
data[@"expireDate"] = [NSString stringWithFormat:@"%f", expireDateTs];
|
|
33
|
+
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
-(NSDictionary *)dictionaryFromPushObject:(NetmeraPushObject *)pushObject{
|
|
24
38
|
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
25
39
|
data[@"pushType"] = [NSNumber numberWithInteger:[pushObject pushType]];
|
package/package.json
CHANGED
package/src/Netmera.ts
CHANGED
|
@@ -18,6 +18,7 @@ import NetmeraCategory from "./models/NetmeraCategory";
|
|
|
18
18
|
import NMInboxStatusCountFilter from "./models/NMInboxStatusCountFilter";
|
|
19
19
|
import NMCategoryPreference from "./models/NMCategoryPreference";
|
|
20
20
|
import { NMInboxStatus } from "./models/NMInboxStatus";
|
|
21
|
+
import NetmeraCouponObject from "./models/NetmeraCouponObject";
|
|
21
22
|
|
|
22
23
|
const { RNNetmera, RNNetmeraRCTEventEmitter }: NativeModulesStatic =
|
|
23
24
|
NativeModules;
|
|
@@ -141,6 +142,13 @@ export default class Netmera {
|
|
|
141
142
|
RNNetmera.stopDataTransfer();
|
|
142
143
|
};
|
|
143
144
|
|
|
145
|
+
static fetchCoupons = (
|
|
146
|
+
page: number,
|
|
147
|
+
max: number
|
|
148
|
+
): Promise<Array<NetmeraCouponObject>> => {
|
|
149
|
+
return RNNetmera.fetchCoupons(page, max);
|
|
150
|
+
};
|
|
151
|
+
|
|
144
152
|
static fetchInbox = (
|
|
145
153
|
netmeraInboxFilter: NetmeraInboxFilter
|
|
146
154
|
): Promise<Array<NetmeraPushInbox>> => {
|