fidel-react-native 1.6.0 → 1.6.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Fidel React Native bridge library change log
2
2
 
3
+ ## 1.6.2
4
+ - Update Fidel API logo
5
+
6
+ ## 1.6.1
7
+ - Always provide the `scheme` field in Android, after successful card enrollments.
8
+ - Provide support for `resConfigs` optimization parameter in Android.
9
+
3
10
  ## 1.6.0
4
11
  - Added the `defaultSelectedCountry` property which sets the country that will be selected by default, when opening the card enrollment screen.
5
12
 
@@ -1,11 +1,12 @@
1
1
 
2
2
  buildscript {
3
3
  repositories {
4
- jcenter()
4
+ google()
5
+ mavenCentral()
5
6
  }
6
7
 
7
8
  dependencies {
8
- classpath 'com.android.tools.build:gradle:1.3.1'
9
+ classpath 'com.android.tools.build:gradle:7.2.1'
9
10
  }
10
11
  }
11
12
 
@@ -20,7 +21,7 @@ android {
20
21
  minSdkVersion 21
21
22
  targetSdkVersion 30
22
23
  versionCode 1
23
- versionName "1.6.0"
24
+ versionName "1.6.3"
24
25
  }
25
26
  lintOptions {
26
27
  abortOnError false
@@ -39,10 +40,10 @@ repositories {
39
40
 
40
41
  dependencies {
41
42
  implementation 'com.facebook.react:react-native:+'
42
- implementation 'com.github.FidelLimited:android-sdk:1.7.0'
43
+ implementation 'com.github.FidelLimited:android-sdk:1.7.4'
43
44
 
44
45
  testImplementation 'junit:junit:4.13.2'
45
- testImplementation 'androidx.test.ext:junit:1.1.2'
46
+ testImplementation 'androidx.test.ext:junit:1.1.3'
46
47
  testImplementation 'org.assertj:assertj-core:3.13.2'
47
48
  testImplementation 'org.robolectric:robolectric:4.5.1'
48
49
  }
@@ -1,7 +1,6 @@
1
1
  package com.fidelreactlibrary.adapters;
2
2
 
3
3
  import com.facebook.react.bridge.WritableMap;
4
- import com.fidel.sdk.LinkResultError;
5
4
  import com.fidel.sdk.LinkResultErrorCode;
6
5
  import com.fidelreactlibrary.adapters.abstraction.DataConverter;
7
6
  import com.fidelreactlibrary.adapters.abstraction.ObjectFactory;
@@ -14,7 +13,7 @@ import java.util.Iterator;
14
13
 
15
14
  public final class WritableMapDataConverter implements DataConverter<Object, WritableMap> {
16
15
 
17
- private ObjectFactory<WritableMap> writableMapFactory;
16
+ private final ObjectFactory<WritableMap> writableMapFactory;
18
17
  public WritableMapDataConverter(ObjectFactory<WritableMap> writableMapFactory) {
19
18
  this.writableMapFactory = writableMapFactory;
20
19
  }
@@ -24,32 +23,44 @@ public final class WritableMapDataConverter implements DataConverter<Object, Wri
24
23
  return null;
25
24
  }
26
25
  WritableMap map = writableMapFactory.create();
27
- try {
28
- for (Field field: data.getClass().getDeclaredFields()) {
29
- if (field.getType() == String.class) {
30
- map.putString(field.getName(), (String)field.get(data));
26
+
27
+ for (Field field: data.getClass().getDeclaredFields()) {
28
+ if (field.getType() == String.class) {
29
+ try {
30
+ map.putString(field.getName(), (String) field.get(data));
31
+ } catch (Exception e) {
32
+ map.putNull(field.getName());
31
33
  }
32
- else if (field.getType() == boolean.class || field.getType() == Boolean.class) {
33
- map.putBoolean(field.getName(), (boolean)field.get(data));
34
+ } else if (field.getType() == boolean.class || field.getType() == Boolean.class) {
35
+ try {
36
+ map.putBoolean(field.getName(), field.getBoolean(data));
37
+ } catch (Exception e) {
38
+ map.putBoolean(field.getName(), false);
34
39
  }
35
- else if (field.getType() == int.class) {
36
- map.putInt(field.getName(), (int)field.get(data));
40
+ } else if (field.getType() == int.class) {
41
+ try {
42
+ map.putInt(field.getName(), field.getInt(data));
43
+ } catch (Exception e) {
44
+ map.putInt(field.getName(), -1);
37
45
  }
38
- else if (field.getType() == LinkResultErrorCode.class) {
46
+ } else if (field.getType() == LinkResultErrorCode.class) {
47
+ String displayFieldName = field.getName().equals("errorCode") ? "code" : field.getName();
48
+ try {
39
49
  LinkResultErrorCode errorCode = (LinkResultErrorCode)field.get(data);
40
- String displayFieldName = field.getName() == "errorCode" ? "code" : field.getName();
41
50
  map.putString(displayFieldName, errorCode.toString().toLowerCase());
51
+ } catch (Exception e) {
52
+ map.putNull(displayFieldName);
42
53
  }
43
- else if (field.getType() == JSONObject.class) {
54
+ } else if (field.getType() == JSONObject.class) {
55
+ try {
44
56
  WritableMap mapToPut = this.getMapFor((JSONObject)field.get(data));
45
57
  map.putMap(field.getName(), mapToPut);
58
+ } catch (Exception e) {
59
+ map.putNull(field.getName());
46
60
  }
47
61
  }
48
- return map;
49
- }
50
- catch (Exception e) {
51
- return map;
52
62
  }
63
+ return map;
53
64
  }
54
65
 
55
66
  private WritableMap getMapFor(JSONObject json) {
@@ -59,14 +70,14 @@ public final class WritableMapDataConverter implements DataConverter<Object, Wri
59
70
  String key = jsonKeyIterator.next();
60
71
  try {
61
72
  Object value = json.get(key);
62
- Class valueClass = value.getClass();
73
+ Class<?> valueClass = value.getClass();
63
74
  if (valueClass == String.class) {
64
75
  map.putString(key, (String)value);
65
76
  }
66
- else if (valueClass == boolean.class || valueClass == Boolean.class) {
77
+ else if (valueClass == Boolean.class) {
67
78
  map.putBoolean(key, (boolean)value);
68
79
  }
69
- else if (valueClass == int.class || valueClass == Integer.class) {
80
+ else if (valueClass == Integer.class) {
70
81
  map.putInt(key, (int)value);
71
82
  }
72
83
  else if (valueClass == JSONObject.class) {
@@ -53,6 +53,43 @@ public class WritableMapDataConverterTests {
53
53
  assertNull(sut.getConvertedDataFor(null));
54
54
  }
55
55
 
56
+ @Test
57
+ public void test_WhenExpectedNonNullStringFieldContainsNullValueInLinkResult_ReturnMapWithNullValueForIt() {
58
+ LinkResult linkResult = new LinkResult(TEST_CARD_ID);
59
+ setFieldsFor(linkResult);
60
+ linkResult.accountId = null;
61
+ WritableMap receivedMap = sut.getConvertedDataFor(linkResult);
62
+ assertNull(receivedMap.getString("accountId"));
63
+ }
64
+
65
+ @Test
66
+ public void test_WhenExpectedNonNullBooleanFieldContainsNullValueInLinkResult_ReturnMapWithFalseValueForIt() {
67
+ LinkResult linkResult = new LinkResult(TEST_CARD_ID);
68
+ setFieldsFor(linkResult);
69
+ linkResult.live = null;
70
+ WritableMap receivedMap = sut.getConvertedDataFor(linkResult);
71
+ assertFalse(receivedMap.getBoolean("live"));
72
+ }
73
+
74
+ @Test
75
+ public void test_WhenExpectedLinkResultWithNullMetaData_ReturnMapWithNullMetaData() {
76
+ LinkResult linkResult = new LinkResult(TEST_CARD_ID);
77
+ setFieldsFor(linkResult);
78
+ linkResult.metaData = null;
79
+ WritableMap receivedMap = sut.getConvertedDataFor(linkResult);
80
+ assertNull(receivedMap.getMap("metaData"));
81
+ }
82
+
83
+ @Test
84
+ public void test_WhenConvertingLinkResultWithError_AndErrorCodeIsUnknown_SetNullErrorCodeField() {
85
+ LinkResult linkResult = new LinkResult(null, TEST_ERROR_MESSAGE, "2021-05-19T12:37:55.278Z");
86
+ Object objectToConvert = linkResult.getError();
87
+
88
+ WritableMap receivedMap = sut.getConvertedDataFor(objectToConvert);
89
+ assertNotNull(receivedMap);
90
+ assertNull(receivedMap.getString("code"));
91
+ }
92
+
56
93
  @Test
57
94
  public void test_WhenConvertingValidLinkResult_IncludeAllObjectFields() throws IllegalAccessException {
58
95
  LinkResult linkResult = new LinkResult(TEST_CARD_ID);
@@ -98,7 +135,7 @@ public class WritableMapDataConverterTests {
98
135
  assertEquals(receivedString, field.get(objectToConvert));
99
136
  }
100
137
  else if (field.getType() == LinkResultErrorCode.class) {
101
- String displayFieldName = field.getName() == "errorCode" ? "code" : field.getName();
138
+ String displayFieldName = field.getName().equals("errorCode") ? "code" : field.getName();
102
139
  String receivedErrorCodeString = receivedMap.getString(displayFieldName);
103
140
  LinkResultErrorCode expectedErrorCode = (LinkResultErrorCode) field.get(objectToConvert);
104
141
  String expectedErrorCodeString = expectedErrorCode.toString().toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fidel-react-native",
3
- "version": "1.6.0",
3
+ "version": "1.6.3",
4
4
  "description": "Fidel's React Native bridge library for iOS and Android.",
5
5
  "main": "index.js",
6
6
  "nativePackage": true,
@@ -45,7 +45,8 @@
45
45
  },
46
46
  "homepage": "https://github.com/FidelLimited/rn-sdk#readme",
47
47
  "peerDependencies": {
48
- "react-native": "^0.41.2"
48
+ "react": "*",
49
+ "react-native": "*"
49
50
  },
50
51
  "dependencies": {}
51
52
  }