react-native-incognia 6.26.0 → 7.0.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/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
- package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/android/.gradle/config.properties +2 -0
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/android.iml +9 -0
- package/android/.idea/caches/deviceStreaming.xml +848 -0
- package/android/.idea/gradle.xml +13 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +4 -4
- package/android/local.properties +8 -0
- package/android/src/main/java/com/incognia/reactnative/IncogniaModule.java +292 -279
- package/ios/ICGIncogniaModule.m +26 -271
- package/ios/Incognia.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Incognia.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Incognia.xcodeproj/xcuserdata/mateus.loureiro.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/index.js +208 -43
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +203 -41
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +117 -72
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/react-native-incognia.podspec +3 -3
- package/src/index.tsx +334 -105
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- /package/android/.gradle/{8.9 → 9.0-milestone-1}/fileChanges/last-build.bin +0 -0
- /package/android/.gradle/{8.9/dependencies-accessors → 9.0-milestone-1}/gc.properties +0 -0
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
package com.incognia.reactnative;
|
|
2
2
|
|
|
3
3
|
import android.app.Application;
|
|
4
|
-
import android.location.Address;
|
|
5
4
|
import android.util.Log;
|
|
6
5
|
|
|
7
6
|
import androidx.annotation.NonNull;
|
|
8
7
|
|
|
9
|
-
import com.facebook.react.bridge.Arguments;
|
|
10
8
|
import com.facebook.react.bridge.Promise;
|
|
11
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
10
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
13
11
|
import com.facebook.react.bridge.ReactMethod;
|
|
14
12
|
import com.facebook.react.bridge.ReadableArray;
|
|
15
13
|
import com.facebook.react.bridge.ReadableMap;
|
|
16
|
-
import com.facebook.react.bridge.WritableMap;
|
|
17
14
|
import com.facebook.react.module.annotations.ReactModule;
|
|
18
|
-
import com.incognia.
|
|
19
|
-
import com.incognia.
|
|
20
|
-
import com.incognia.
|
|
21
|
-
import com.incognia.
|
|
15
|
+
import com.incognia.CardInfo;
|
|
16
|
+
import com.incognia.CustomEvent;
|
|
17
|
+
import com.incognia.EventAddress;
|
|
18
|
+
import com.incognia.EventLocation;
|
|
22
19
|
import com.incognia.EventProperties;
|
|
23
20
|
import com.incognia.Incognia;
|
|
24
|
-
import com.incognia.IncogniaListener;
|
|
25
21
|
import com.incognia.IncogniaOptions;
|
|
26
|
-
import com.incognia.
|
|
27
|
-
import com.incognia.
|
|
28
|
-
import com.incognia.
|
|
29
|
-
|
|
30
|
-
import
|
|
31
|
-
import
|
|
22
|
+
import com.incognia.LoginEvent;
|
|
23
|
+
import com.incognia.OnboardingEvent;
|
|
24
|
+
import com.incognia.PaymentAddress;
|
|
25
|
+
import com.incognia.PaymentCoupon;
|
|
26
|
+
import com.incognia.PaymentEvent;
|
|
27
|
+
import com.incognia.PaymentMethod;
|
|
28
|
+
import com.incognia.PaymentValue;
|
|
29
|
+
|
|
30
|
+
import java.util.ArrayList;
|
|
31
|
+
import java.util.List;
|
|
32
32
|
import java.util.Locale;
|
|
33
33
|
import java.util.Map;
|
|
34
|
-
import java.util.Set;
|
|
35
34
|
|
|
36
35
|
@SuppressWarnings({"unused",
|
|
37
36
|
"Convert2Lambda"})
|
|
@@ -39,47 +38,65 @@ import java.util.Set;
|
|
|
39
38
|
public class IncogniaModule extends ReactContextBaseJavaModule {
|
|
40
39
|
public static final String NAME = "IncogniaModule";
|
|
41
40
|
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
private static final String
|
|
45
|
-
private static final String
|
|
46
|
-
private static final String
|
|
41
|
+
private ReactApplicationContext reactContext;
|
|
42
|
+
|
|
43
|
+
private static final String OPTIONS_APP_ID_KEY = "appId";
|
|
44
|
+
private static final String OPTIONS_LOG_ENABLED_KEY = "logEnabled";
|
|
45
|
+
private static final String OPTIONS_LOCATION_ENABLED_KEY = "locationEnabled";
|
|
46
|
+
private static final String OPTIONS_INSTALLED_APPS_COLLECTION_ENABLED_KEY = "installedAppsCollectionEnabled";
|
|
47
47
|
|
|
48
|
-
private static final String
|
|
49
|
-
private static final String
|
|
48
|
+
private static final String EVENT_ACCOUNT_ID = "accountId";
|
|
49
|
+
private static final String EVENT_EXTERNAL_ID = "externalId";
|
|
50
|
+
private static final String EVENT_ADDRESS = "address";
|
|
51
|
+
private static final String EVENT_LOCATION = "location";
|
|
52
|
+
private static final String EVENT_TAG = "tag";
|
|
53
|
+
private static final String EVENT_PROPERTIES = "properties";
|
|
54
|
+
private static final String EVENT_STATUS = "status";
|
|
55
|
+
private static final String EVENT_STORE_ID = "storeId";
|
|
50
56
|
|
|
51
57
|
private static final String ADDRESS_LOCALE_KEY = "locale";
|
|
52
|
-
private static final String ADDRESS_COUNTRY_NAME_KEY = "countryName";
|
|
53
58
|
private static final String ADDRESS_COUNTRY_CODE_KEY = "countryCode";
|
|
54
|
-
private static final String
|
|
55
|
-
private static final String
|
|
56
|
-
private static final String
|
|
57
|
-
private static final String
|
|
58
|
-
private static final String
|
|
59
|
-
private static final String
|
|
59
|
+
private static final String ADDRESS_COUNTRY_NAME_KEY = "countryName";
|
|
60
|
+
private static final String ADDRESS_STATE_KEY = "state";
|
|
61
|
+
private static final String ADDRESS_CITY_KEY = "city";
|
|
62
|
+
private static final String ADDRESS_NEIGHBORHOOD_KEY = "neighborhood";
|
|
63
|
+
private static final String ADDRESS_NUMBER_KEY = "number";
|
|
64
|
+
private static final String ADDRESS_STREET_KEY = "street";
|
|
60
65
|
private static final String ADDRESS_POSTAL_CODE_KEY = "postalCode";
|
|
66
|
+
private static final String ADDRESS_LINE_KEY = "addressLine";
|
|
61
67
|
private static final String ADDRESS_LATITUDE_KEY = "latitude";
|
|
62
68
|
private static final String ADDRESS_LONGITUDE_KEY = "longitude";
|
|
63
|
-
private static final String ADDRESS_LINE = "addressLine";
|
|
64
69
|
|
|
65
|
-
private static final String
|
|
66
|
-
private static final String
|
|
67
|
-
private static final String
|
|
68
|
-
|
|
69
|
-
private static final String
|
|
70
|
-
private static final String
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
private static final String
|
|
74
|
-
private static final String
|
|
75
|
-
private static final String
|
|
76
|
-
private static final String
|
|
77
|
-
|
|
78
|
-
private static final String
|
|
79
|
-
private static final String
|
|
80
|
-
private static final String
|
|
81
|
-
private static final String
|
|
82
|
-
private static final String
|
|
70
|
+
private static final String LOCATION_LATITUDE_KEY = "latitude";
|
|
71
|
+
private static final String LOCATION_LONGITUDE_KEY = "longitude";
|
|
72
|
+
private static final String LOCATION_TIMESTAMP_KEY = "timestamp";
|
|
73
|
+
|
|
74
|
+
private static final String PAYMENT_ADDRESSES = "addresses";
|
|
75
|
+
private static final String PAYMENT_ADDRESS_TYPE = "type";
|
|
76
|
+
|
|
77
|
+
private static final String PAYMENT_VALUE = "paymentValue";
|
|
78
|
+
private static final String PAYMENT_VALUE_AMOUNT = "amount";
|
|
79
|
+
private static final String PAYMENT_VALUE_CURRENCY = "currency";
|
|
80
|
+
private static final String PAYMENT_VALUE_INSTALLMENTS = "installments";
|
|
81
|
+
private static final String PAYMENT_VALUE_DISCOUNT_AMOUNT = "discountAmount";
|
|
82
|
+
|
|
83
|
+
private static final String PAYMENT_COUPON = "paymentCoupon";
|
|
84
|
+
private static final String PAYMENT_COUPON_TYPE = "type";
|
|
85
|
+
private static final String PAYMENT_COUPON_VALUE = "value";
|
|
86
|
+
private static final String PAYMENT_COUPON_MAX_DISCOUNT = "maxDiscount";
|
|
87
|
+
private static final String PAYMENT_COUPON_ID = "id";
|
|
88
|
+
private static final String PAYMENT_COUPON_NAME = "name";
|
|
89
|
+
|
|
90
|
+
private static final String PAYMENT_METHODS = "paymentMethods";
|
|
91
|
+
private static final String PAYMENT_METHOD_TYPE = "type";
|
|
92
|
+
private static final String PAYMENT_METHOD_IDENTIFIER = "identifier";
|
|
93
|
+
private static final String PAYMENT_METHOD_BRAND = "brand";
|
|
94
|
+
private static final String PAYMENT_METHOD_CREDIT_CARD_INFO = "creditCardInfo";
|
|
95
|
+
private static final String PAYMENT_METHOD_DEBIT_CARD_INFO = "debitCardInfo";
|
|
96
|
+
private static final String PAYMENT_METHOD_CARD_INFO_BIN = "bin";
|
|
97
|
+
private static final String PAYMENT_METHOD_CARD_INFO_LAST_FOUR_DIGITS = "lastFourDigits";
|
|
98
|
+
private static final String PAYMENT_METHOD_CARD_INFO_EXPIRY_MONTH = "expiryMonth";
|
|
99
|
+
private static final String PAYMENT_METHOD_CARD_INFO_EXPIRY_YEAR = "expiryYear";
|
|
83
100
|
|
|
84
101
|
public IncogniaModule(ReactApplicationContext reactContext) {
|
|
85
102
|
super(reactContext);
|
|
@@ -107,19 +124,15 @@ public class IncogniaModule extends ReactContextBaseJavaModule {
|
|
|
107
124
|
Application application = (Application) getReactApplicationContext().getApplicationContext();
|
|
108
125
|
|
|
109
126
|
String appId = optionsParameters.hasKey(OPTIONS_APP_ID_KEY) ? optionsParameters.getString(OPTIONS_APP_ID_KEY) : null;
|
|
110
|
-
boolean logEnabled = optionsParameters.hasKey(OPTIONS_LOG_ENABLED_KEY)
|
|
111
|
-
boolean locationEnabled =
|
|
112
|
-
boolean installedAppsCollectionEnabled = optionsParameters.hasKey(OPTIONS_INSTALLED_APPS_COLLECTION_ENABLED_KEY)
|
|
113
|
-
optionsParameters.getBoolean(OPTIONS_INSTALLED_APPS_COLLECTION_ENABLED_KEY);
|
|
114
|
-
boolean backgroundWakeupEnabled = optionsParameters.hasKey(OPTIONS_BACKGROUND_WAKEUP_ENABLED_KEY) && optionsParameters.getBoolean(
|
|
115
|
-
OPTIONS_BACKGROUND_WAKEUP_ENABLED_KEY);
|
|
127
|
+
boolean logEnabled = optionsParameters.hasKey(OPTIONS_LOG_ENABLED_KEY) ? optionsParameters.getBoolean(OPTIONS_LOG_ENABLED_KEY) : false;
|
|
128
|
+
boolean locationEnabled = optionsParameters.hasKey(OPTIONS_LOCATION_ENABLED_KEY) ? optionsParameters.getBoolean(OPTIONS_LOCATION_ENABLED_KEY) : true;
|
|
129
|
+
boolean installedAppsCollectionEnabled = optionsParameters.hasKey(OPTIONS_INSTALLED_APPS_COLLECTION_ENABLED_KEY) ? optionsParameters.getBoolean(OPTIONS_INSTALLED_APPS_COLLECTION_ENABLED_KEY) : false;
|
|
116
130
|
|
|
117
131
|
IncogniaOptions options = new IncogniaOptions.Builder()
|
|
118
132
|
.appId(appId)
|
|
119
133
|
.logEnabled(logEnabled)
|
|
120
|
-
.
|
|
134
|
+
.locationEnabled(locationEnabled)
|
|
121
135
|
.installedAppsCollectionEnabled(installedAppsCollectionEnabled)
|
|
122
|
-
.backgroundWakeupEnabled(backgroundWakeupEnabled)
|
|
123
136
|
.build();
|
|
124
137
|
|
|
125
138
|
Incognia.init(application, options);
|
|
@@ -138,194 +151,110 @@ public class IncogniaModule extends ReactContextBaseJavaModule {
|
|
|
138
151
|
Incognia.clearAccountId();
|
|
139
152
|
}
|
|
140
153
|
|
|
141
|
-
@ReactMethod
|
|
142
|
-
public void allowConsentTypes(final ReadableArray consentTypesArray) {
|
|
143
|
-
Set<String> consentTypes = convertStringReadableArrayToSet(consentTypesArray);
|
|
144
|
-
Incognia.allowConsentTypes(consentTypes);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@ReactMethod
|
|
148
|
-
public void denyConsentTypes(final ReadableArray consentTypesArray) {
|
|
149
|
-
Set<String> consentTypes = convertStringReadableArrayToSet(consentTypesArray);
|
|
150
|
-
Incognia.denyConsentTypes(consentTypes);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
154
|
@ReactMethod
|
|
154
155
|
public void setLocationEnabled(final boolean enabled) {
|
|
155
156
|
Incognia.setLocationEnabled(enabled);
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
@ReactMethod
|
|
159
|
-
public void fetchInstallationId(final Promise promise) {
|
|
160
|
-
Incognia.fetchInstallationId(new IncogniaListener<String>() {
|
|
161
|
-
@Override
|
|
162
|
-
public void onResult(Result<String> result) {
|
|
163
|
-
if (result.isSuccessful()) {
|
|
164
|
-
String installationId = result.getResult();
|
|
165
|
-
promise.resolve(installationId);
|
|
166
|
-
} else {
|
|
167
|
-
promise.reject(new Exception("Error while getting installation id."));
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
159
|
@ReactMethod
|
|
174
160
|
public void generateRequestToken(final Promise promise) {
|
|
175
|
-
Incognia.generateRequestToken(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
promise.resolve(requestToken);
|
|
181
|
-
} else {
|
|
182
|
-
promise.reject(new Exception("Error while generating a request token."));
|
|
183
|
-
}
|
|
161
|
+
Incognia.generateRequestToken( requestToken -> {
|
|
162
|
+
if (requestToken != null) {
|
|
163
|
+
promise.resolve(requestToken);
|
|
164
|
+
} else {
|
|
165
|
+
promise.reject(new Exception("Error while generating a request token."));
|
|
184
166
|
}
|
|
185
167
|
});
|
|
186
168
|
}
|
|
187
169
|
|
|
188
170
|
@ReactMethod
|
|
189
|
-
public void
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
String requestToken = result.getResult();
|
|
195
|
-
promise.resolve(requestToken);
|
|
196
|
-
} else {
|
|
197
|
-
promise.reject(new Exception("Error while generating a unique request token."));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@ReactMethod
|
|
204
|
-
public void requestPrivacyConsent(final ReadableMap consentDialogOptionsMap, final Promise promise) {
|
|
205
|
-
ConsentDialogOptions.Builder consentDialogOptions = new ConsentDialogOptions.Builder(getCurrentActivity());
|
|
206
|
-
|
|
207
|
-
String dialogTitle = consentDialogOptionsMap.hasKey(CONSENT_DIALOG_TITLE) ? consentDialogOptionsMap.getString(CONSENT_DIALOG_TITLE) : null;
|
|
208
|
-
if (dialogTitle != null) {
|
|
209
|
-
consentDialogOptions.title(dialogTitle);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
String dialogMessage = consentDialogOptionsMap.hasKey(CONSENT_DIALOG_MESSAGE) ? consentDialogOptionsMap.getString(CONSENT_DIALOG_MESSAGE) : null;
|
|
213
|
-
if (dialogMessage != null) {
|
|
214
|
-
consentDialogOptions.message(dialogMessage);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
String dialogAccept = consentDialogOptionsMap.hasKey(CONSENT_DIALOG_ACCEPT_TEXT) ? consentDialogOptionsMap.getString(CONSENT_DIALOG_ACCEPT_TEXT) : null;
|
|
218
|
-
if (dialogAccept != null) {
|
|
219
|
-
consentDialogOptions.acceptText(dialogAccept);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
String dialogDeny = consentDialogOptionsMap.hasKey(CONSENT_DIALOG_DENY_TEXT) ? consentDialogOptionsMap.getString(CONSENT_DIALOG_DENY_TEXT) : null;
|
|
223
|
-
if (dialogDeny != null) {
|
|
224
|
-
consentDialogOptions.denyText(dialogDeny);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
ReadableArray consentTypesArray = consentDialogOptionsMap.hasKey(CONSENT_DIALOG_TYPES) ? consentDialogOptionsMap.getArray(CONSENT_DIALOG_TYPES) : null;
|
|
228
|
-
if (consentTypesArray != null) {
|
|
229
|
-
consentDialogOptions.consentTypes(convertStringReadableArrayToSet(consentTypesArray));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
Incognia.requestPrivacyConsent(consentDialogOptions.build(), new ConsentListener() {
|
|
233
|
-
@Override
|
|
234
|
-
public void onConsentResult(final ConsentResult consentResult) {
|
|
235
|
-
boolean hasFinished = consentResult.hasFinished();
|
|
236
|
-
boolean isWaitingConsent = consentResult.isWaitingConsent();
|
|
237
|
-
boolean areAllConsentTypesGiven = consentResult.areAllConsentTypesGiven();
|
|
238
|
-
WritableMap result = Arguments.createMap();
|
|
239
|
-
result.putBoolean("hasFinished", hasFinished);
|
|
240
|
-
result.putBoolean("isWaitingConsent", isWaitingConsent);
|
|
241
|
-
result.putBoolean("areAllConsentTypesGiven", areAllConsentTypesGiven);
|
|
242
|
-
promise.resolve(result);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
@ReactMethod
|
|
248
|
-
public void checkConsent(final ReadableArray consentTypesArray, final Promise promise) {
|
|
249
|
-
Set<String> consentTypes = convertStringReadableArrayToSet(consentTypesArray);
|
|
250
|
-
Incognia.checkConsent(new ConsentListener() {
|
|
251
|
-
@Override
|
|
252
|
-
public void onConsentResult(final ConsentResult consentResult) {
|
|
253
|
-
boolean hasFinished = consentResult.hasFinished();
|
|
254
|
-
boolean isWaitingConsent = consentResult.isWaitingConsent();
|
|
255
|
-
boolean areAllConsentTypesGiven = consentResult.areAllConsentTypesGiven();
|
|
256
|
-
WritableMap result = Arguments.createMap();
|
|
257
|
-
result.putBoolean("hasFinished", hasFinished);
|
|
258
|
-
result.putBoolean("isWaitingConsent", isWaitingConsent);
|
|
259
|
-
result.putBoolean("areAllConsentTypesGiven", areAllConsentTypesGiven);
|
|
260
|
-
promise.resolve(result);
|
|
261
|
-
}
|
|
262
|
-
}, consentTypes);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
@ReactMethod
|
|
266
|
-
public void trackEvent(final ReadableMap parameters) {
|
|
267
|
-
String eventName = parameters.hasKey(EVENT_NAME) ? parameters.getString(EVENT_NAME) : null;
|
|
171
|
+
public void sendCustomEvent(final ReadableMap parameters) {
|
|
172
|
+
String eventAccountId = parameters.hasKey(EVENT_ACCOUNT_ID) ? parameters.getString(EVENT_ACCOUNT_ID) : null;
|
|
173
|
+
String eventExternalId = parameters.hasKey(EVENT_EXTERNAL_ID) ? parameters.getString(EVENT_EXTERNAL_ID) : null;
|
|
174
|
+
String eventTag = parameters.hasKey(EVENT_TAG) ? parameters.getString(EVENT_TAG) : null;
|
|
175
|
+
String eventStatus = parameters.hasKey(EVENT_STATUS) ? parameters.getString(EVENT_STATUS) : null;
|
|
268
176
|
EventProperties eventProperties = parameters.hasKey(EVENT_PROPERTIES) ? convertToEventProperties(parameters.getMap(EVENT_PROPERTIES)) : null;
|
|
269
|
-
|
|
177
|
+
EventAddress eventAddress = parameters.hasKey(EVENT_ADDRESS) ? convertToEventAddress(parameters.getMap(EVENT_ADDRESS)) : null;
|
|
178
|
+
|
|
179
|
+
CustomEvent customEvent = new CustomEvent.Builder()
|
|
180
|
+
.accountId(eventAccountId)
|
|
181
|
+
.externalId(eventExternalId)
|
|
182
|
+
.address(eventAddress)
|
|
183
|
+
.tag(eventTag)
|
|
184
|
+
.properties(eventProperties)
|
|
185
|
+
.status(eventStatus)
|
|
186
|
+
.build();
|
|
187
|
+
Incognia.sendCustomEvent(customEvent);
|
|
270
188
|
}
|
|
271
189
|
|
|
272
190
|
@ReactMethod
|
|
273
|
-
public void
|
|
274
|
-
String
|
|
191
|
+
public void sendOnboardingEvent(ReadableMap parameters) {
|
|
192
|
+
String eventAccountId = parameters.hasKey(EVENT_ACCOUNT_ID) ? parameters.getString(EVENT_ACCOUNT_ID) : null;
|
|
193
|
+
String eventExternalId = parameters.hasKey(EVENT_EXTERNAL_ID) ? parameters.getString(EVENT_EXTERNAL_ID) : null;
|
|
194
|
+
String eventTag = parameters.hasKey(EVENT_TAG) ? parameters.getString(EVENT_TAG) : null;
|
|
195
|
+
String eventStatus = parameters.hasKey(EVENT_STATUS) ? parameters.getString(EVENT_STATUS) : null;
|
|
275
196
|
EventProperties eventProperties = parameters.hasKey(EVENT_PROPERTIES) ? convertToEventProperties(parameters.getMap(EVENT_PROPERTIES)) : null;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
197
|
+
EventAddress eventAddress = parameters.hasKey(EVENT_ADDRESS) ? convertToEventAddress(parameters.getMap(EVENT_ADDRESS)) : null;
|
|
198
|
+
|
|
199
|
+
OnboardingEvent onboardingEvent = new OnboardingEvent.Builder()
|
|
200
|
+
.accountId(eventAccountId)
|
|
201
|
+
.externalId(eventExternalId)
|
|
202
|
+
.address(eventAddress)
|
|
203
|
+
.tag(eventTag)
|
|
204
|
+
.properties(eventProperties)
|
|
205
|
+
.status(eventStatus)
|
|
206
|
+
.build();
|
|
207
|
+
Incognia.sendOnboardingEvent(onboardingEvent);
|
|
286
208
|
}
|
|
287
209
|
|
|
288
|
-
@SuppressWarnings("ConstantConditions")
|
|
289
210
|
@ReactMethod
|
|
290
|
-
public void
|
|
291
|
-
String
|
|
292
|
-
String
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
@ReactMethod
|
|
308
|
-
public void notifyAppInForeground() {
|
|
309
|
-
Incognia.notifyAppInForeground();
|
|
211
|
+
public void sendLoginEvent(ReadableMap parameters) {
|
|
212
|
+
String eventAccountId = parameters.hasKey(EVENT_ACCOUNT_ID) ? parameters.getString(EVENT_ACCOUNT_ID) : null;
|
|
213
|
+
String eventExternalId = parameters.hasKey(EVENT_EXTERNAL_ID) ? parameters.getString(EVENT_EXTERNAL_ID) : null;
|
|
214
|
+
String eventTag = parameters.hasKey(EVENT_TAG) ? parameters.getString(EVENT_TAG) : null;
|
|
215
|
+
String eventStatus = parameters.hasKey(EVENT_STATUS) ? parameters.getString(EVENT_STATUS) : null;
|
|
216
|
+
EventProperties eventProperties = parameters.hasKey(EVENT_PROPERTIES) ? convertToEventProperties(parameters.getMap(EVENT_PROPERTIES)) : null;
|
|
217
|
+
EventLocation eventLocation = parameters.hasKey(EVENT_LOCATION) ? convertToEventLocation(parameters.getMap(EVENT_LOCATION)) : null;
|
|
218
|
+
|
|
219
|
+
LoginEvent loginEvent = new LoginEvent.Builder()
|
|
220
|
+
.accountId(eventAccountId)
|
|
221
|
+
.externalId(eventExternalId)
|
|
222
|
+
.location(eventLocation)
|
|
223
|
+
.tag(eventTag)
|
|
224
|
+
.properties(eventProperties)
|
|
225
|
+
.status(eventStatus)
|
|
226
|
+
.build();
|
|
227
|
+
Incognia.sendLoginEvent(loginEvent);
|
|
310
228
|
}
|
|
311
229
|
|
|
312
230
|
@ReactMethod
|
|
313
|
-
public void
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
231
|
+
public void sendPaymentEvent(ReadableMap parameters) {
|
|
232
|
+
String eventAccountId = parameters.hasKey(EVENT_ACCOUNT_ID) ? parameters.getString(EVENT_ACCOUNT_ID) : null;
|
|
233
|
+
String eventExternalId = parameters.hasKey(EVENT_EXTERNAL_ID) ? parameters.getString(EVENT_EXTERNAL_ID) : null;
|
|
234
|
+
String eventTag = parameters.hasKey(EVENT_TAG) ? parameters.getString(EVENT_TAG) : null;
|
|
235
|
+
String eventStatus = parameters.hasKey(EVENT_STATUS) ? parameters.getString(EVENT_STATUS) : null;
|
|
236
|
+
String eventStoreId = parameters.hasKey(EVENT_STORE_ID) ? parameters.getString(EVENT_STORE_ID) : null;
|
|
237
|
+
EventProperties eventProperties = parameters.hasKey(EVENT_PROPERTIES) ? convertToEventProperties(parameters.getMap(EVENT_PROPERTIES)) : null;
|
|
238
|
+
EventLocation eventLocation = parameters.hasKey(EVENT_LOCATION) ? convertToEventLocation(parameters.getMap(EVENT_LOCATION)) : null;
|
|
239
|
+
List<PaymentAddress> eventAddresses = parameters.hasKey(PAYMENT_ADDRESSES) ? convertPaymentAddressesReadableArrayToList(parameters.getArray(PAYMENT_ADDRESSES)) : null;
|
|
240
|
+
PaymentValue eventPaymentValue = parameters.hasKey(PAYMENT_VALUE) ? convertToPaymentValue(parameters.getMap(PAYMENT_VALUE)) : null;
|
|
241
|
+
PaymentCoupon eventPaymentCoupon = parameters.hasKey(PAYMENT_COUPON) ? convertToPaymentCoupon(parameters.getMap(PAYMENT_COUPON)) : null;
|
|
242
|
+
List<PaymentMethod> eventPaymentMethods = parameters.hasKey(PAYMENT_METHODS) ? convertPaymentMethodsReadableArrayToList(parameters.getArray(PAYMENT_METHODS)) : null;
|
|
243
|
+
|
|
244
|
+
PaymentEvent paymentEvent = new PaymentEvent.Builder()
|
|
245
|
+
.accountId(eventAccountId)
|
|
246
|
+
.externalId(eventExternalId)
|
|
247
|
+
.location(eventLocation)
|
|
248
|
+
.addresses(eventAddresses)
|
|
249
|
+
.paymentValue(eventPaymentValue)
|
|
250
|
+
.paymentCoupon(eventPaymentCoupon)
|
|
251
|
+
.paymentMethods(eventPaymentMethods)
|
|
252
|
+
.storeId(eventStoreId)
|
|
253
|
+
.tag(eventTag)
|
|
254
|
+
.properties(eventProperties)
|
|
255
|
+
.status(eventStatus)
|
|
256
|
+
.build();
|
|
257
|
+
Incognia.sendPaymentEvent(paymentEvent);
|
|
329
258
|
}
|
|
330
259
|
|
|
331
260
|
private static EventProperties convertToEventProperties(ReadableMap readableMap) {
|
|
@@ -334,106 +263,190 @@ public class IncogniaModule extends ReactContextBaseJavaModule {
|
|
|
334
263
|
}
|
|
335
264
|
|
|
336
265
|
Map<String, Object> map = readableMap.toHashMap();
|
|
337
|
-
EventProperties eventProperties = EventProperties
|
|
266
|
+
EventProperties eventProperties = new EventProperties();
|
|
338
267
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
339
268
|
if (entry.getValue() instanceof String) {
|
|
340
|
-
eventProperties.
|
|
269
|
+
eventProperties.set(entry.getKey(), (String) entry.getValue());
|
|
341
270
|
} else if (entry.getValue() instanceof Integer) {
|
|
342
|
-
eventProperties.
|
|
271
|
+
eventProperties.set(entry.getKey(), (Integer) entry.getValue());
|
|
343
272
|
} else if (entry.getValue() instanceof Float) {
|
|
344
|
-
eventProperties.
|
|
273
|
+
eventProperties.set(entry.getKey(), (Float) entry.getValue());
|
|
345
274
|
} else if (entry.getValue() instanceof Double) {
|
|
346
|
-
eventProperties.
|
|
275
|
+
eventProperties.set(entry.getKey(), (Double) entry.getValue());
|
|
347
276
|
} else if (entry.getValue() instanceof Boolean) {
|
|
348
|
-
eventProperties.
|
|
277
|
+
eventProperties.set(entry.getKey(), (Boolean) entry.getValue());
|
|
349
278
|
}
|
|
350
279
|
}
|
|
351
280
|
return eventProperties;
|
|
352
281
|
}
|
|
353
282
|
|
|
354
|
-
private static
|
|
355
|
-
if (
|
|
283
|
+
private static EventLocation convertToEventLocation(ReadableMap map) {
|
|
284
|
+
if (map == null) {
|
|
356
285
|
return null;
|
|
357
286
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
287
|
+
|
|
288
|
+
Double latitude = map.hasKey(LOCATION_LATITUDE_KEY) ? map.getDouble(LOCATION_LATITUDE_KEY) : null;
|
|
289
|
+
Double longitude = map.hasKey(LOCATION_LONGITUDE_KEY) ? map.getDouble(LOCATION_LONGITUDE_KEY) : null;
|
|
290
|
+
Long timestamp = map.hasKey(LOCATION_TIMESTAMP_KEY) ? (long) map.getDouble(LOCATION_TIMESTAMP_KEY) : null;
|
|
291
|
+
|
|
292
|
+
return new EventLocation(latitude, longitude, timestamp);
|
|
363
293
|
}
|
|
364
294
|
|
|
365
|
-
private static
|
|
295
|
+
private static PaymentValue convertToPaymentValue(ReadableMap map) {
|
|
366
296
|
if (map == null) {
|
|
367
297
|
return null;
|
|
368
298
|
}
|
|
369
299
|
|
|
370
|
-
|
|
371
|
-
|
|
300
|
+
Double amount = map.hasKey(PAYMENT_VALUE_AMOUNT) ? map.getDouble(PAYMENT_VALUE_AMOUNT) : null;
|
|
301
|
+
String currency = map.hasKey(PAYMENT_VALUE_CURRENCY) ? map.getString(PAYMENT_VALUE_CURRENCY) : null;
|
|
302
|
+
Integer installments = map.hasKey(PAYMENT_VALUE_INSTALLMENTS) ? (int) map.getDouble(PAYMENT_VALUE_INSTALLMENTS) : null;
|
|
303
|
+
Double discountAmount = map.hasKey(PAYMENT_VALUE_DISCOUNT_AMOUNT) ? map.getDouble(PAYMENT_VALUE_DISCOUNT_AMOUNT) : null;
|
|
372
304
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
address.setSubAdminArea(map.getString(ADDRESS_SUB_ADMIN_AREA_KEY));
|
|
384
|
-
}
|
|
385
|
-
if (map.hasKey(ADDRESS_LOCALITY_KEY)) {
|
|
386
|
-
address.setLocality(map.getString(ADDRESS_LOCALITY_KEY));
|
|
387
|
-
}
|
|
388
|
-
if (map.hasKey(ADDRESS_SUB_LOCALITY_KEY)) {
|
|
389
|
-
address.setSubLocality(map.getString(ADDRESS_SUB_LOCALITY_KEY));
|
|
390
|
-
}
|
|
391
|
-
if (map.hasKey(ADDRESS_THOROUGHFARE_KEY)) {
|
|
392
|
-
address.setThoroughfare(map.getString(ADDRESS_THOROUGHFARE_KEY));
|
|
393
|
-
}
|
|
394
|
-
if (map.hasKey(ADDRESS_SUB_THOROUGHFARE_KEY)) {
|
|
395
|
-
address.setSubThoroughfare(map.getString(ADDRESS_SUB_THOROUGHFARE_KEY));
|
|
305
|
+
return new PaymentValue.Builder(amount)
|
|
306
|
+
.currency(currency)
|
|
307
|
+
.installments(installments)
|
|
308
|
+
.discountAmount(discountAmount)
|
|
309
|
+
.build();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private static PaymentCoupon convertToPaymentCoupon(ReadableMap map) {
|
|
313
|
+
if (map == null) {
|
|
314
|
+
return null;
|
|
396
315
|
}
|
|
397
|
-
|
|
398
|
-
|
|
316
|
+
|
|
317
|
+
String type = map.hasKey(PAYMENT_COUPON_TYPE) ? map.getString(PAYMENT_COUPON_TYPE) : null;
|
|
318
|
+
Double value = map.hasKey(PAYMENT_COUPON_VALUE) ? map.getDouble(PAYMENT_COUPON_VALUE) : null;
|
|
319
|
+
Double maxDiscount = map.hasKey(PAYMENT_COUPON_MAX_DISCOUNT) ? map.getDouble(PAYMENT_COUPON_MAX_DISCOUNT) : null;
|
|
320
|
+
String id = map.hasKey(PAYMENT_COUPON_ID) ? map.getString(PAYMENT_COUPON_ID) : null;
|
|
321
|
+
String name = map.hasKey(PAYMENT_COUPON_NAME) ? map.getString(PAYMENT_COUPON_NAME) : null;
|
|
322
|
+
|
|
323
|
+
return new PaymentCoupon.Builder()
|
|
324
|
+
.type(type)
|
|
325
|
+
.value(value)
|
|
326
|
+
.maxDiscount(maxDiscount)
|
|
327
|
+
.id(id)
|
|
328
|
+
.name(name)
|
|
329
|
+
.build();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
private static List<PaymentMethod> convertPaymentMethodsReadableArrayToList(final ReadableArray array) {
|
|
333
|
+
if (array == null) {
|
|
334
|
+
return null;
|
|
399
335
|
}
|
|
400
|
-
|
|
401
|
-
|
|
336
|
+
|
|
337
|
+
List<PaymentMethod> list = new ArrayList<>();
|
|
338
|
+
for (int i = 0; i < array.size(); i++) {
|
|
339
|
+
PaymentMethod paymentMethod = convertMapToPaymentMethod(array.getMap(i));
|
|
340
|
+
if (paymentMethod != null) {
|
|
341
|
+
list.add(paymentMethod);
|
|
342
|
+
}
|
|
402
343
|
}
|
|
403
|
-
|
|
404
|
-
|
|
344
|
+
return list;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
@SuppressWarnings("ConstantConditions")
|
|
348
|
+
private static PaymentMethod convertMapToPaymentMethod(ReadableMap map) {
|
|
349
|
+
if (map == null) {
|
|
350
|
+
return null;
|
|
405
351
|
}
|
|
406
|
-
|
|
407
|
-
|
|
352
|
+
|
|
353
|
+
String type = map.hasKey(PAYMENT_METHOD_TYPE) ? map.getString(PAYMENT_METHOD_TYPE) : null;
|
|
354
|
+
String identifier = map.hasKey(PAYMENT_METHOD_IDENTIFIER) ? map.getString(PAYMENT_METHOD_IDENTIFIER) : null;
|
|
355
|
+
String brand = map.hasKey(PAYMENT_METHOD_BRAND) ? map.getString(PAYMENT_METHOD_BRAND) : null;
|
|
356
|
+
CardInfo creditCardInfo = map.hasKey(PAYMENT_METHOD_CREDIT_CARD_INFO) ? convertMapToCardInfo(map.getMap(PAYMENT_METHOD_CREDIT_CARD_INFO)) : null;
|
|
357
|
+
CardInfo debitCardInfo = map.hasKey(PAYMENT_METHOD_DEBIT_CARD_INFO) ? convertMapToCardInfo(map.getMap(PAYMENT_METHOD_DEBIT_CARD_INFO)) : null;
|
|
358
|
+
|
|
359
|
+
return new PaymentMethod.Builder()
|
|
360
|
+
.type(type)
|
|
361
|
+
.identifier(identifier)
|
|
362
|
+
.brand(brand)
|
|
363
|
+
.creditCardInfo(creditCardInfo)
|
|
364
|
+
.debitCardInfo(debitCardInfo)
|
|
365
|
+
.build();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
@SuppressWarnings("ConstantConditions")
|
|
369
|
+
private static CardInfo convertMapToCardInfo(ReadableMap map) {
|
|
370
|
+
if (map == null) {
|
|
371
|
+
return null;
|
|
408
372
|
}
|
|
409
373
|
|
|
410
|
-
|
|
374
|
+
String bin = map.hasKey(PAYMENT_METHOD_CARD_INFO_BIN) ? map.getString(PAYMENT_METHOD_CARD_INFO_BIN) : null;
|
|
375
|
+
String lastFourDigits = map.hasKey(PAYMENT_METHOD_CARD_INFO_LAST_FOUR_DIGITS) ? map.getString(PAYMENT_METHOD_CARD_INFO_LAST_FOUR_DIGITS) : null;
|
|
376
|
+
String expiryMonth = map.hasKey(PAYMENT_METHOD_CARD_INFO_EXPIRY_MONTH) ? map.getString(PAYMENT_METHOD_CARD_INFO_EXPIRY_MONTH) : null;
|
|
377
|
+
String expiryYear = map.hasKey(PAYMENT_METHOD_CARD_INFO_EXPIRY_YEAR) ? map.getString(PAYMENT_METHOD_CARD_INFO_EXPIRY_YEAR) : null;
|
|
378
|
+
|
|
379
|
+
return new CardInfo.Builder()
|
|
380
|
+
.bin(bin)
|
|
381
|
+
.lastFourDigits(lastFourDigits)
|
|
382
|
+
.expiryMonth(expiryMonth)
|
|
383
|
+
.expiryYear(expiryYear)
|
|
384
|
+
.build();
|
|
411
385
|
}
|
|
412
386
|
|
|
413
|
-
private static
|
|
387
|
+
private static List<PaymentAddress> convertPaymentAddressesReadableArrayToList(final ReadableArray array) {
|
|
414
388
|
if (array == null) {
|
|
415
389
|
return null;
|
|
416
390
|
}
|
|
417
391
|
|
|
418
|
-
|
|
392
|
+
List<PaymentAddress> list = new ArrayList<>();
|
|
419
393
|
for (int i = 0; i < array.size(); i++) {
|
|
420
|
-
|
|
421
|
-
if (
|
|
422
|
-
|
|
394
|
+
PaymentAddress paymentAddress = convertMapToPaymentAddress(array.getMap(i));
|
|
395
|
+
if (paymentAddress != null) {
|
|
396
|
+
list.add(paymentAddress);
|
|
423
397
|
}
|
|
424
398
|
}
|
|
425
|
-
return
|
|
399
|
+
return list;
|
|
426
400
|
}
|
|
427
401
|
|
|
428
402
|
@SuppressWarnings("ConstantConditions")
|
|
429
|
-
private static
|
|
403
|
+
private static PaymentAddress convertMapToPaymentAddress(ReadableMap map) {
|
|
404
|
+
if (map == null) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
EventAddress eventAddress = convertToEventAddress(map);
|
|
409
|
+
String addressType = map.hasKey(PAYMENT_ADDRESS_TYPE) ? map.getString(PAYMENT_ADDRESS_TYPE) : null;
|
|
410
|
+
|
|
411
|
+
return new PaymentAddress(addressType, eventAddress);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private static EventAddress convertToEventAddress(ReadableMap map) {
|
|
430
415
|
if (map == null) {
|
|
431
416
|
return null;
|
|
432
417
|
}
|
|
433
418
|
|
|
434
|
-
|
|
435
|
-
String
|
|
436
|
-
|
|
419
|
+
String countryCode = map.hasKey(ADDRESS_COUNTRY_CODE_KEY) ? map.getString(ADDRESS_COUNTRY_CODE_KEY) : null;
|
|
420
|
+
String countryName = map.hasKey(ADDRESS_COUNTRY_NAME_KEY) ? map.getString(ADDRESS_COUNTRY_NAME_KEY) : null;
|
|
421
|
+
String state = map.hasKey(ADDRESS_STATE_KEY) ? map.getString(ADDRESS_STATE_KEY) : null;
|
|
422
|
+
String city = map.hasKey(ADDRESS_CITY_KEY) ? map.getString(ADDRESS_CITY_KEY) : null;
|
|
423
|
+
String neighborhood = map.hasKey(ADDRESS_NEIGHBORHOOD_KEY) ? map.getString(ADDRESS_NEIGHBORHOOD_KEY) : null;
|
|
424
|
+
String number = map.hasKey(ADDRESS_NUMBER_KEY) ? map.getString(ADDRESS_NUMBER_KEY) : null;
|
|
425
|
+
String street = map.hasKey(ADDRESS_STREET_KEY) ? map.getString(ADDRESS_STREET_KEY) : null;
|
|
426
|
+
String postalCode = map.hasKey(ADDRESS_POSTAL_CODE_KEY) ? map.getString(ADDRESS_POSTAL_CODE_KEY) : null;
|
|
427
|
+
String addressLine = map.hasKey(ADDRESS_LINE_KEY) ? map.getString(ADDRESS_LINE_KEY) : null;
|
|
428
|
+
Double latitude = map.hasKey(ADDRESS_LATITUDE_KEY) ? map.getDouble(ADDRESS_LATITUDE_KEY) : null;
|
|
429
|
+
Double longitude = map.hasKey(ADDRESS_LONGITUDE_KEY) ? map.getDouble(ADDRESS_LONGITUDE_KEY) : null;
|
|
430
|
+
|
|
431
|
+
Locale locale = map.hasKey(ADDRESS_LOCALE_KEY) ? localeFromString(map.getString(ADDRESS_LOCALE_KEY)) : null;
|
|
432
|
+
if(locale == null && (street != null || addressLine != null)) {
|
|
433
|
+
locale = Locale.getDefault();
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return new EventAddress.Builder()
|
|
437
|
+
.locale(locale)
|
|
438
|
+
.countryCode(countryCode)
|
|
439
|
+
.countryName(countryName)
|
|
440
|
+
.state(state)
|
|
441
|
+
.city(city)
|
|
442
|
+
.neighborhood(neighborhood)
|
|
443
|
+
.number(number)
|
|
444
|
+
.street(street)
|
|
445
|
+
.postalCode(postalCode)
|
|
446
|
+
.addressLine(addressLine)
|
|
447
|
+
.latitude(latitude)
|
|
448
|
+
.longitude(longitude)
|
|
449
|
+
.build();
|
|
437
450
|
}
|
|
438
451
|
|
|
439
452
|
private static Locale localeFromString(String locale) {
|