fidel-react-native 2.4.0 → 3.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/build.gradle +1 -1
- package/android/src/main/java/com/fidelreactlibrary/FidelModule.java +2 -28
- package/android/src/main/java/com/fidelreactlibrary/FidelPackage.java +1 -19
- package/android/src/main/java/com/fidelreactlibrary/adapters/FidelProgramTypeAdapter.java +0 -1
- package/android/src/main/java/com/fidelreactlibrary/adapters/FidelSetupAdapter.java +0 -4
- package/android/src/main/java/com/fidelreactlibrary/adapters/FidelSetupProperties.java +0 -1
- package/android/src/main/java/com/fidelreactlibrary/adapters/ResultsAdapter.java +0 -65
- package/android/src/main/java/com/fidelreactlibrary/events/BridgeLibraryEvent.java +0 -2
- package/android/src/main/java/com/fidelreactlibrary/events/ResultsObserver.java +0 -8
- package/android/src/test/java/com/fidelreactlibrary/FidelModuleTests.java +0 -21
- package/android/src/test/java/com/fidelreactlibrary/adapters/FidelProgramTypeAdapterTests.java +0 -5
- package/android/src/test/java/com/fidelreactlibrary/adapters/FidelSetupAdapterTests.java +0 -76
- package/android/src/test/java/com/fidelreactlibrary/events/BridgeLibraryEventEmitterTests.java +0 -11
- package/android/src/test/java/com/fidelreactlibrary/events/BridgeLibraryEventTests.java +0 -5
- package/android/src/test/java/com/fidelreactlibrary/fakes/ReadableMapStub.java +0 -23
- package/index.js +0 -43
- package/ios/Adapters/ErrorResultAdapter.swift +1 -15
- package/ios/Adapters/FidelSetupAdapter.swift +5 -8
- package/ios/Constants/ErrorTypeConstants.swift +4 -7
- package/ios/Constants/ExportedConstantsProvider.swift +1 -3
- package/ios/Constants/ProgramTypeConstants.swift +4 -8
- package/ios/Constants/ResultTypeConstants.swift +3 -5
- package/ios/Events/BridgeLibraryEvent.swift +0 -2
- package/ios/Events/JSResultProperties.swift +0 -1
- package/ios/Events/JSResultTypes.swift +0 -1
- package/ios/Events/ResultsObserver.swift +2 -5
- package/ios/FidelSetupProperties.swift +2 -3
- package/ios/NativeFidelBridge.m +0 -2
- package/ios/NativeFidelBridge.swift +13 -25
- package/package.json +1 -1
- package/android/src/main/java/com/fidelreactlibrary/adapters/CardVerificationConfigurationProperties.java +0 -22
- package/android/src/main/java/com/fidelreactlibrary/adapters/FidelCardVerificationChoiceAdapter.java +0 -57
- package/android/src/main/java/com/fidelreactlibrary/adapters/FidelVerificationConfigurationAdapter.java +0 -35
- package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/CardVerificationChoiceAdapter.java +0 -11
- package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/VerificationConfigurationAdapter.java +0 -9
- package/android/src/main/java/com/fidelreactlibrary/events/CardVerificationChoiceObserver.java +0 -29
- package/android/src/main/java/com/fidelreactlibrary/events/CardVerificationStartedObserver.java +0 -31
- package/android/src/test/java/com/fidelreactlibrary/adapters/FidelCardVerificationChoiceAdapterTest.java +0 -70
- package/android/src/test/java/com/fidelreactlibrary/adapters/FidelVerificationConfigurationAdapterTest.java +0 -51
- package/android/src/test/java/com/fidelreactlibrary/events/CardVerificationStartedObserverTests.java +0 -49
- package/android/src/test/java/com/fidelreactlibrary/fakes/VerificationConfigurationAdapterStub.java +0 -13
- package/ios/Adapters/FidelVerificationConfigurationAdapter.swift +0 -19
- package/ios/Adapters/VerificationResultAdapter.swift +0 -17
- package/ios/Constants/CardVerificationChoiceConstants.swift +0 -24
- package/ios/Constants/VerificationErrorTypeConstants.swift +0 -29
- package/ios/Events/CardVerificationChoiceSelectedObserver.swift +0 -23
- package/ios/Events/CardVerificationStartedObserver.swift +0 -21
|
@@ -26,14 +26,13 @@ extension FidelErrorType {
|
|
|
26
26
|
var jsTypeValue: String {
|
|
27
27
|
switch self {
|
|
28
28
|
case .enrollmentError: return "enrollmentError"
|
|
29
|
-
case .verificationError: return "verificationError"
|
|
30
29
|
case .userCanceled: return "userCanceled"
|
|
31
30
|
case .sdkConfigurationError: return "sdkConfigurationError"
|
|
32
31
|
case .deviceNotSecure: return "deviceNotSecure"
|
|
33
32
|
@unknown default: return "unknown"
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
|
|
35
|
+
|
|
37
36
|
var jsErrorSubtype: String? {
|
|
38
37
|
switch self {
|
|
39
38
|
case let .enrollmentError(enrollmentError):
|
|
@@ -52,19 +51,6 @@ extension FidelErrorType {
|
|
|
52
51
|
case .cardLimitExceededError: return "cardLimitExceededError"
|
|
53
52
|
@unknown default: return "unexpected"
|
|
54
53
|
}
|
|
55
|
-
case let .verificationError(verificationError):
|
|
56
|
-
switch verificationError {
|
|
57
|
-
case .cardAlreadyVerified: return "cardAlreadyVerified"
|
|
58
|
-
case .cardNotFound: return "cardNotFound"
|
|
59
|
-
case .verificationNotFound: return "verificationNotFound"
|
|
60
|
-
case .genericError: return "genericError"
|
|
61
|
-
case .maximumAttemptsReached: return "maximumAttemptsReached"
|
|
62
|
-
case .incorrectAmount, .incorrectAmountCode: return "incorrectAmount"
|
|
63
|
-
case .unauthorized: return "unauthorized"
|
|
64
|
-
case .unexpected: return "unexpected"
|
|
65
|
-
case .invalidSDKKey: return "invalidSdkKey"
|
|
66
|
-
@unknown default: return "unexpected"
|
|
67
|
-
}
|
|
68
54
|
default: return nil
|
|
69
55
|
}
|
|
70
56
|
}
|
|
@@ -9,14 +9,14 @@ import Foundation
|
|
|
9
9
|
import Fidel
|
|
10
10
|
|
|
11
11
|
class FidelSetupAdapter: NSObject {
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
private let imageAdapter: FLRNImageFromRNAdapter
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
init(imageAdapter: FLRNImageFromRNAdapter) {
|
|
16
16
|
self.imageAdapter = imageAdapter
|
|
17
17
|
super.init()
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
func setup(with parameters: NSDictionary) {
|
|
21
21
|
guard let parameters = parameters as? [String: Any?] else {
|
|
22
22
|
return
|
|
@@ -40,7 +40,7 @@ class FidelSetupAdapter: NSObject {
|
|
|
40
40
|
setConsentTextValues(consentTextValues)
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
func setOptions(_ options: [String: Any?]) {
|
|
45
45
|
if options.keys.contains(FidelSetupProperties.Options.bannerImage.rawValue),
|
|
46
46
|
let rawImageObject = options[FidelSetupProperties.Options.bannerImage.rawValue] as? NSObject {
|
|
@@ -59,14 +59,11 @@ class FidelSetupAdapter: NSObject {
|
|
|
59
59
|
let supportedCardSchemeJSKeys = options[FidelSetupProperties.Options.supportedCardSchemes.rawValue] as? [String] {
|
|
60
60
|
Fidel.supportedCardSchemes = CardScheme.cardSchemesSet(from: supportedCardSchemeJSKeys)
|
|
61
61
|
}
|
|
62
|
-
if options.keys.contains(FidelSetupProperties.Options.thirdPartyVerificationChoice.rawValue) {
|
|
63
|
-
Fidel.thirdPartyVerificationChoice = options[FidelSetupProperties.Options.thirdPartyVerificationChoice.rawValue] as? Bool ?? false
|
|
64
|
-
}
|
|
65
62
|
if options.keys.contains(FidelSetupProperties.Options.metaData.rawValue) {
|
|
66
63
|
Fidel.metaData = options[FidelSetupProperties.Options.metaData.rawValue] as? [String: Any]
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
|
-
|
|
66
|
+
|
|
70
67
|
private func setConsentTextValues(_ consentTextValues: [String: Any?]) {
|
|
71
68
|
if consentTextValues.keys.contains(FidelSetupProperties.ConsentText.companyName.rawValue) {
|
|
72
69
|
Fidel.companyName = consentTextValues[FidelSetupProperties.ConsentText.companyName.rawValue] as? String
|
|
@@ -9,28 +9,25 @@ import Foundation
|
|
|
9
9
|
import Fidel
|
|
10
10
|
|
|
11
11
|
extension FidelErrorType: ConstantsProvider {
|
|
12
|
-
|
|
13
|
-
static var allCases: Set<FidelErrorType> = [FidelErrorType.userCanceled, .enrollmentError(EnrollmentError.unexpected), .
|
|
12
|
+
|
|
13
|
+
static var allCases: Set<FidelErrorType> = [FidelErrorType.userCanceled, .enrollmentError(EnrollmentError.unexpected), .sdkConfigurationError]
|
|
14
14
|
static var parentKeyName: String = "ErrorType"
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
var constantKey: String {
|
|
17
17
|
switch self {
|
|
18
18
|
case .enrollmentError: return "enrollmentError"
|
|
19
|
-
case .verificationError: return "verificationError"
|
|
20
19
|
case .sdkConfigurationError: return "sdkConfigurationError"
|
|
21
20
|
case .userCanceled: return "userCanceled"
|
|
22
21
|
case .deviceNotSecure: return "deviceNotSecure"
|
|
23
22
|
@unknown default: return "unexpected"
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
|
|
27
26
|
public func hash(into hasher: inout Hasher) {
|
|
28
27
|
hasher.combine(self.constantKey)
|
|
29
28
|
switch self {
|
|
30
29
|
case let .enrollmentError(enrollmentError):
|
|
31
30
|
hasher.combine(enrollmentError)
|
|
32
|
-
case let .verificationError(verificationError):
|
|
33
|
-
hasher.combine(verificationError)
|
|
34
31
|
default: break;
|
|
35
32
|
}
|
|
36
33
|
}
|
|
@@ -9,17 +9,15 @@ import Foundation
|
|
|
9
9
|
import Fidel
|
|
10
10
|
|
|
11
11
|
class ExportedConstantsProvider: NSObject {
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
var constants: [AnyHashable: Any] {
|
|
14
14
|
var constants = [String: [String: String]]()
|
|
15
15
|
constants.merge(CardScheme.constantsToExport) { (current, _) in current }
|
|
16
16
|
constants.merge(Country.constantsToExport) { (current, _) in current }
|
|
17
17
|
constants.merge(ProgramType.constantsToExport) { (current, _) in current }
|
|
18
18
|
constants.merge(EnrollmentError.constantsToExport) { (current, _) in current }
|
|
19
|
-
constants.merge(VerificationError.constantsToExport) { (current, _) in current }
|
|
20
19
|
constants.merge(FidelErrorType.constantsToExport) { (current, _) in current }
|
|
21
20
|
constants.merge(FidelResult.constantsToExport) { (current, _) in current }
|
|
22
|
-
constants.merge(CardVerificationChoice.constantsToExport) { (current, _) in current }
|
|
23
21
|
return constants
|
|
24
22
|
}
|
|
25
23
|
}
|
|
@@ -9,22 +9,18 @@ import Foundation
|
|
|
9
9
|
import Fidel
|
|
10
10
|
|
|
11
11
|
extension ProgramType: ConstantsProvider {
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
var constantKey: String {
|
|
14
14
|
switch self {
|
|
15
15
|
case .transactionSelect: return "transactionSelect"
|
|
16
|
-
case .transactionStream: return "transactionStream"
|
|
17
16
|
@unknown default: return "unexpected"
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
public static var allCases: Set<ProgramType> = [ProgramType.transactionSelect
|
|
19
|
+
|
|
20
|
+
public static var allCases: Set<ProgramType> = [ProgramType.transactionSelect]
|
|
22
21
|
static var parentKeyName: String = String(describing: Self.self)
|
|
23
|
-
|
|
22
|
+
|
|
24
23
|
static func programType(from constantKey: String?) -> ProgramType {
|
|
25
|
-
if constantKey == "transactionStream" {
|
|
26
|
-
return .transactionStream
|
|
27
|
-
}
|
|
28
24
|
return .transactionSelect
|
|
29
25
|
}
|
|
30
26
|
}
|
|
@@ -11,24 +11,22 @@ import Fidel
|
|
|
11
11
|
extension FidelResult: ConstantsProvider {
|
|
12
12
|
static var allCases: Set<FidelResult> = []
|
|
13
13
|
static var parentKeyName: String = "ResultType"
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
var constantKey: String {
|
|
16
16
|
switch self {
|
|
17
17
|
case .enrollmentResult: return "EnrollmentResult"
|
|
18
18
|
case .error: return "Error"
|
|
19
|
-
case .verificationResult: return "VerificationResult"
|
|
20
19
|
@unknown default: return "unexpected"
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
|
|
24
23
|
static var constantsToExport: [String : [String : String]] {
|
|
25
24
|
var casesConstants = [String: String]()
|
|
26
25
|
casesConstants["EnrollmentResult"] = "EnrollmentResult"
|
|
27
|
-
casesConstants["VerificationResult"] = "VerificationResult"
|
|
28
26
|
casesConstants["Error"] = "Error"
|
|
29
27
|
return [Self.parentKeyName: casesConstants]
|
|
30
28
|
}
|
|
31
|
-
|
|
29
|
+
|
|
32
30
|
public func hash(into hasher: inout Hasher) {
|
|
33
31
|
hasher.combine(self.constantKey)
|
|
34
32
|
}
|
|
@@ -9,7 +9,7 @@ import Foundation
|
|
|
9
9
|
import Fidel
|
|
10
10
|
|
|
11
11
|
struct ResultsObserver: EventObserver {
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
func startObserving(_ onEvent: @escaping (NSDictionary) -> Void) {
|
|
14
14
|
Fidel.onResult = { result in
|
|
15
15
|
var resultDictionary = [String: Any?]()
|
|
@@ -17,9 +17,6 @@ struct ResultsObserver: EventObserver {
|
|
|
17
17
|
case .enrollmentResult(let enrollmentResult):
|
|
18
18
|
resultDictionary[JSResultProperties.type.rawValue] = JSResultTypes.enrollmentResult.rawValue
|
|
19
19
|
resultDictionary[JSResultProperties.enrollmentResult.rawValue] = enrollmentResult.dictionary
|
|
20
|
-
case .verificationResult(let verificationResult):
|
|
21
|
-
resultDictionary[JSResultProperties.type.rawValue] = JSResultTypes.verificationResult.rawValue
|
|
22
|
-
resultDictionary[JSResultProperties.verificationResult.rawValue] = verificationResult.dictionary
|
|
23
20
|
case .error(let fidelError):
|
|
24
21
|
resultDictionary[JSResultProperties.type.rawValue] = JSResultTypes.error.rawValue
|
|
25
22
|
resultDictionary[JSResultProperties.error.rawValue] = fidelError.dictionary
|
|
@@ -30,7 +27,7 @@ struct ResultsObserver: EventObserver {
|
|
|
30
27
|
onEvent(resultNSDictionary)
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
|
-
|
|
30
|
+
|
|
34
31
|
func stopObserving() {
|
|
35
32
|
Fidel.onResult = nil
|
|
36
33
|
}
|
|
@@ -13,16 +13,15 @@ enum FidelSetupProperties: String {
|
|
|
13
13
|
case programType
|
|
14
14
|
case options
|
|
15
15
|
case consentText
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
enum Options: String {
|
|
18
18
|
case bannerImage
|
|
19
19
|
case allowedCountries
|
|
20
20
|
case defaultSelectedCountry
|
|
21
21
|
case supportedCardSchemes
|
|
22
|
-
case thirdPartyVerificationChoice
|
|
23
22
|
case metaData
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
|
|
26
25
|
enum ConsentText: String {
|
|
27
26
|
case termsAndConditionsURL = "termsAndConditionsUrl"
|
|
28
27
|
case privacyPolicyURL = "privacyPolicyUrl"
|
package/ios/NativeFidelBridge.m
CHANGED
|
@@ -6,8 +6,6 @@ RCT_EXTERN_METHOD(setup:(NSDictionary *)setupInfo)
|
|
|
6
6
|
|
|
7
7
|
RCT_EXTERN_METHOD(start)
|
|
8
8
|
|
|
9
|
-
RCT_EXTERN_METHOD(verifyCard:(NSDictionary *)cardVerificationConfiguration)
|
|
10
|
-
|
|
11
9
|
RCT_EXTERN_METHOD(identifyMetricsDataSource:(NSString *)name version:(NSString *)version)
|
|
12
10
|
|
|
13
11
|
@end
|
|
@@ -12,23 +12,22 @@ import analytics
|
|
|
12
12
|
|
|
13
13
|
@objc(NativeFidelBridge)
|
|
14
14
|
class NativeFidelBridge: RCTEventEmitter {
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
private var eventObservers = [BridgeLibraryEvent: EventObserver]()
|
|
17
17
|
private let imageAdapter = FLRNImageFromRNAdapter()
|
|
18
18
|
private let setupAdapter: FidelSetupAdapter
|
|
19
19
|
private let constantsProvider = ExportedConstantsProvider()
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
22
21
|
override init() {
|
|
23
22
|
setupAdapter = FidelSetupAdapter(imageAdapter: imageAdapter)
|
|
24
23
|
super.init()
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
|
|
27
26
|
@objc(setup:)
|
|
28
27
|
func setup(with jsSetupInfo: NSDictionary) {
|
|
29
28
|
setupAdapter.setup(with: jsSetupInfo)
|
|
30
29
|
}
|
|
31
|
-
|
|
30
|
+
|
|
32
31
|
@objc(start)
|
|
33
32
|
func start() {
|
|
34
33
|
guard let startViewController = UIApplication.shared.delegate?.window??.rootViewController else {
|
|
@@ -36,16 +35,7 @@ class NativeFidelBridge: RCTEventEmitter {
|
|
|
36
35
|
}
|
|
37
36
|
Fidel.start(from: startViewController)
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
@objc(verifyCard:)
|
|
41
|
-
func verifyCard(with parameters: NSDictionary) {
|
|
42
|
-
guard let startViewController = UIApplication.shared.delegate?.window??.rootViewController else {
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
let cardVerificationConfig = verificationConfigAdapter.adapt(parameters)
|
|
46
|
-
Fidel.verifyCard(from: startViewController, cardVerificationConfiguration: cardVerificationConfig)
|
|
47
|
-
}
|
|
48
|
-
|
|
38
|
+
|
|
49
39
|
@objc(identifyMetricsDataSource:version:)
|
|
50
40
|
func identifyMetricsDataSource(name: String, version: String) {
|
|
51
41
|
let reactNativeSdkDetails = SdkDetails(name: name, version: version)
|
|
@@ -55,7 +45,7 @@ class NativeFidelBridge: RCTEventEmitter {
|
|
|
55
45
|
override func supportedEvents() -> [String]! {
|
|
56
46
|
return BridgeLibraryEvent.allCases.map { $0.rawValue }
|
|
57
47
|
}
|
|
58
|
-
|
|
48
|
+
|
|
59
49
|
override func addListener(_ eventName: String!) {
|
|
60
50
|
super.addListener(eventName)
|
|
61
51
|
guard let event = BridgeLibraryEvent(rawValue: eventName) else {
|
|
@@ -63,7 +53,7 @@ class NativeFidelBridge: RCTEventEmitter {
|
|
|
63
53
|
}
|
|
64
54
|
startObserving(event: event)
|
|
65
55
|
}
|
|
66
|
-
|
|
56
|
+
|
|
67
57
|
private func startObserving(event: BridgeLibraryEvent) {
|
|
68
58
|
let observer = self.makeObserver(for: event)
|
|
69
59
|
eventObservers[event] = observer
|
|
@@ -71,30 +61,28 @@ class NativeFidelBridge: RCTEventEmitter {
|
|
|
71
61
|
self?.sendEvent(withName: event.rawValue, body: $0)
|
|
72
62
|
}
|
|
73
63
|
}
|
|
74
|
-
|
|
64
|
+
|
|
75
65
|
private func makeObserver(for event: BridgeLibraryEvent) -> EventObserver {
|
|
76
66
|
switch event {
|
|
77
|
-
case .cardVerificationStarted: return CardVerificationStartedObserver()
|
|
78
67
|
case .resultAvailable: return ResultsObserver()
|
|
79
|
-
case .cardVerificationChoiceSelected: return CardVerificationChoiceSelectedObserver()
|
|
80
68
|
}
|
|
81
69
|
}
|
|
82
|
-
|
|
70
|
+
|
|
83
71
|
override func removeListeners(_ count: Double) {
|
|
84
72
|
super.removeListeners(count)
|
|
85
73
|
eventObservers[.resultAvailable]?.stopObserving()
|
|
86
74
|
}
|
|
87
|
-
|
|
75
|
+
|
|
88
76
|
override func constantsToExport() -> [AnyHashable : Any]! {
|
|
89
77
|
return constantsProvider.constants
|
|
90
78
|
}
|
|
91
|
-
|
|
79
|
+
|
|
92
80
|
override class func requiresMainQueueSetup() -> Bool {
|
|
93
81
|
return true
|
|
94
82
|
}
|
|
95
|
-
|
|
83
|
+
|
|
96
84
|
override var methodQueue: DispatchQueue! {
|
|
97
85
|
DispatchQueue.main
|
|
98
86
|
}
|
|
99
|
-
|
|
87
|
+
|
|
100
88
|
}
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.adapters;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
public enum CardVerificationConfigurationProperties {
|
|
6
|
-
ID("id"),
|
|
7
|
-
CONSENT_ID("consentId"),
|
|
8
|
-
LAST_4_DIGITS("last4Digits");
|
|
9
|
-
|
|
10
|
-
private final @NonNull String jsName;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param jsName The name of the key that will be available in JavaScript
|
|
14
|
-
*/
|
|
15
|
-
CardVerificationConfigurationProperties(final @NonNull String jsName) {
|
|
16
|
-
this.jsName = jsName;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public String jsName() {
|
|
20
|
-
return jsName;
|
|
21
|
-
}
|
|
22
|
-
}
|
package/android/src/main/java/com/fidelreactlibrary/adapters/FidelCardVerificationChoiceAdapter.java
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.adapters;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
import androidx.annotation.OptIn;
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
-
import com.facebook.react.bridge.WritableMap;
|
|
8
|
-
import com.fidelapi.entities.CardVerificationChoice;
|
|
9
|
-
import com.fidelapi.utils.FidelExperimental;
|
|
10
|
-
import com.fidelreactlibrary.adapters.abstraction.CardVerificationChoiceAdapter;
|
|
11
|
-
import com.fidelreactlibrary.adapters.abstraction.ConstantsProvider;
|
|
12
|
-
import com.fidelreactlibrary.adapters.abstraction.ObjectFactory;
|
|
13
|
-
|
|
14
|
-
import java.util.HashMap;
|
|
15
|
-
import java.util.Map;
|
|
16
|
-
|
|
17
|
-
@OptIn(markerClass = FidelExperimental.class)
|
|
18
|
-
public class FidelCardVerificationChoiceAdapter implements CardVerificationChoiceAdapter, ConstantsProvider {
|
|
19
|
-
protected static final String CARD_VERIFICATION_ON_THE_SPOT = "onTheSpot";
|
|
20
|
-
protected static final String CARD_VERIFICATION_DELEGATED_TO_THIRD_PARTY = "delegatedToThirdParty";
|
|
21
|
-
public static final String CARD_VERIFICATION_CHOICE = "CardVerificationChoice";
|
|
22
|
-
private final ObjectFactory<WritableMap> writableMapFactory;
|
|
23
|
-
|
|
24
|
-
public FidelCardVerificationChoiceAdapter(ObjectFactory<WritableMap> writableMapFactory) {
|
|
25
|
-
this.writableMapFactory = writableMapFactory;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Override
|
|
29
|
-
public ReadableMap adapt(@NonNull CardVerificationChoice cardVerificationChoice) {
|
|
30
|
-
WritableMap map = writableMapFactory.create();
|
|
31
|
-
map.putString(CARD_VERIFICATION_CHOICE, jsValue(cardVerificationChoice));
|
|
32
|
-
return map;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@NonNull
|
|
36
|
-
@Override
|
|
37
|
-
public Map<String, Object> getConstants() {
|
|
38
|
-
final Map<String, Object> constants = new HashMap<>();
|
|
39
|
-
final Map<String, String> verificationChoicesMap = new HashMap<>();
|
|
40
|
-
for (CardVerificationChoice choice : CardVerificationChoice.values()) {
|
|
41
|
-
String verificationChoiceKeyAndValue = jsValue(choice);
|
|
42
|
-
verificationChoicesMap.put(verificationChoiceKeyAndValue, verificationChoiceKeyAndValue);
|
|
43
|
-
}
|
|
44
|
-
constants.put(CARD_VERIFICATION_CHOICE, verificationChoicesMap);
|
|
45
|
-
return constants;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private String jsValue(@NonNull CardVerificationChoice cardVerificationChoice) {
|
|
49
|
-
switch (cardVerificationChoice) {
|
|
50
|
-
case DELEGATED_TO_THIRD_PARTY:
|
|
51
|
-
return CARD_VERIFICATION_DELEGATED_TO_THIRD_PARTY;
|
|
52
|
-
case ON_THE_SPOT:
|
|
53
|
-
return CARD_VERIFICATION_ON_THE_SPOT;
|
|
54
|
-
}
|
|
55
|
-
return "notFound";
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.adapters;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.Nullable;
|
|
4
|
-
|
|
5
|
-
import com.fidelapi.entities.CardVerificationConfiguration;
|
|
6
|
-
import com.fidelreactlibrary.adapters.abstraction.VerificationConfigurationAdapter;
|
|
7
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
8
|
-
|
|
9
|
-
public class FidelVerificationConfigurationAdapter implements VerificationConfigurationAdapter {
|
|
10
|
-
|
|
11
|
-
@Override
|
|
12
|
-
public CardVerificationConfiguration adapt(ReadableMap data) {
|
|
13
|
-
String id = "";
|
|
14
|
-
String consentId = "";
|
|
15
|
-
String last4Digits = null;
|
|
16
|
-
if (data != null) {
|
|
17
|
-
id = getStringParam(data, CardVerificationConfigurationProperties.ID, "");
|
|
18
|
-
consentId = getStringParam(data, CardVerificationConfigurationProperties.CONSENT_ID, "");
|
|
19
|
-
last4Digits = getStringParam(data, CardVerificationConfigurationProperties.LAST_4_DIGITS, null);
|
|
20
|
-
}
|
|
21
|
-
return new CardVerificationConfiguration(id, consentId, last4Digits);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private static String getStringParam(ReadableMap data, CardVerificationConfigurationProperties key,
|
|
25
|
-
@Nullable String defaultValue) {
|
|
26
|
-
String value = defaultValue;
|
|
27
|
-
if (data.hasKey(key.jsName())) {
|
|
28
|
-
value = data.getString(key.jsName());
|
|
29
|
-
if (value == null) {
|
|
30
|
-
value = defaultValue;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.adapters.abstraction;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
-
import com.fidelapi.entities.CardVerificationChoice;
|
|
7
|
-
|
|
8
|
-
public interface CardVerificationChoiceAdapter {
|
|
9
|
-
|
|
10
|
-
ReadableMap adapt(@NonNull CardVerificationChoice cardVerificationChoice);
|
|
11
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.adapters.abstraction;
|
|
2
|
-
|
|
3
|
-
import com.fidelapi.entities.CardVerificationConfiguration;
|
|
4
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
5
|
-
|
|
6
|
-
public interface VerificationConfigurationAdapter {
|
|
7
|
-
|
|
8
|
-
CardVerificationConfiguration adapt(ReadableMap data);
|
|
9
|
-
}
|
package/android/src/main/java/com/fidelreactlibrary/events/CardVerificationChoiceObserver.java
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.events;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
-
import com.facebook.react.bridge.WritableMap;
|
|
7
|
-
import com.fidelapi.entities.CardVerificationChoice;
|
|
8
|
-
import com.fidelapi.entities.abstraction.OnCardVerificationChoiceSelectedObserver;
|
|
9
|
-
import com.fidelapi.utils.FidelExperimental;
|
|
10
|
-
import com.fidelreactlibrary.adapters.abstraction.CardVerificationChoiceAdapter;
|
|
11
|
-
import com.fidelreactlibrary.adapters.abstraction.DataProcessor;
|
|
12
|
-
import com.fidelreactlibrary.adapters.abstraction.ObjectFactory;
|
|
13
|
-
|
|
14
|
-
@FidelExperimental
|
|
15
|
-
public class CardVerificationChoiceObserver implements OnCardVerificationChoiceSelectedObserver {
|
|
16
|
-
private final DataProcessor<ReadableMap> adaptedVerificationChoiceDetailsProcessor;
|
|
17
|
-
private final CardVerificationChoiceAdapter cardVerificationChoiceAdapter;
|
|
18
|
-
|
|
19
|
-
public CardVerificationChoiceObserver(DataProcessor<ReadableMap> adaptedVerificationChoiceDetailsProcessor,
|
|
20
|
-
CardVerificationChoiceAdapter cardVerificationChoiceAdapter) {
|
|
21
|
-
this.adaptedVerificationChoiceDetailsProcessor = adaptedVerificationChoiceDetailsProcessor;
|
|
22
|
-
this.cardVerificationChoiceAdapter = cardVerificationChoiceAdapter;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Override
|
|
26
|
-
public void onCardVerificationChoiceSelected(@NonNull CardVerificationChoice cardVerificationChoice) {
|
|
27
|
-
adaptedVerificationChoiceDetailsProcessor.process(cardVerificationChoiceAdapter.adapt(cardVerificationChoice));
|
|
28
|
-
}
|
|
29
|
-
}
|
package/android/src/main/java/com/fidelreactlibrary/events/CardVerificationStartedObserver.java
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.events;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
-
import com.facebook.react.bridge.WritableMap;
|
|
7
|
-
import com.fidelapi.entities.ConsentDetails;
|
|
8
|
-
import com.fidelapi.entities.abstraction.OnCardVerificationStartedObserver;
|
|
9
|
-
import com.fidelreactlibrary.adapters.abstraction.DataProcessor;
|
|
10
|
-
import com.fidelreactlibrary.adapters.abstraction.ObjectFactory;
|
|
11
|
-
|
|
12
|
-
public class CardVerificationStartedObserver implements OnCardVerificationStartedObserver {
|
|
13
|
-
|
|
14
|
-
private final DataProcessor<ReadableMap> adaptedConsentDetailsProcessor;
|
|
15
|
-
private final ObjectFactory<WritableMap> writableMapFactory;
|
|
16
|
-
|
|
17
|
-
public CardVerificationStartedObserver(DataProcessor<ReadableMap> adaptedConsentDetailsProcessor,
|
|
18
|
-
ObjectFactory<WritableMap> writableMapFactory) {
|
|
19
|
-
this.adaptedConsentDetailsProcessor = adaptedConsentDetailsProcessor;
|
|
20
|
-
this.writableMapFactory = writableMapFactory;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Override
|
|
24
|
-
public void onCardVerificationStarted(@NonNull ConsentDetails consentDetails) {
|
|
25
|
-
WritableMap map = writableMapFactory.create();
|
|
26
|
-
map.putString("cardId", consentDetails.getCardId());
|
|
27
|
-
map.putString("consentId", consentDetails.getConsentId());
|
|
28
|
-
map.putString("programId", consentDetails.getProgramId());
|
|
29
|
-
adaptedConsentDetailsProcessor.process(map);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
package com.fidelreactlibrary.adapters;
|
|
2
|
-
|
|
3
|
-
import static com.fidelreactlibrary.adapters.FidelCardVerificationChoiceAdapter.CARD_VERIFICATION_CHOICE;
|
|
4
|
-
import static com.fidelreactlibrary.adapters.FidelCardVerificationChoiceAdapter.CARD_VERIFICATION_DELEGATED_TO_THIRD_PARTY;
|
|
5
|
-
import static com.fidelreactlibrary.adapters.FidelCardVerificationChoiceAdapter.CARD_VERIFICATION_ON_THE_SPOT;
|
|
6
|
-
|
|
7
|
-
import static org.junit.Assert.assertEquals;
|
|
8
|
-
import static org.junit.Assert.assertTrue;
|
|
9
|
-
|
|
10
|
-
import com.facebook.react.bridge.JavaOnlyMap;
|
|
11
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
12
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
13
|
-
import com.fidelapi.entities.CardVerificationChoice;
|
|
14
|
-
|
|
15
|
-
import org.junit.Test;
|
|
16
|
-
|
|
17
|
-
import java.util.HashMap;
|
|
18
|
-
import java.util.Map;
|
|
19
|
-
|
|
20
|
-
public class FidelCardVerificationChoiceAdapterTest {
|
|
21
|
-
|
|
22
|
-
@Test
|
|
23
|
-
public void test_ShouldExposeConstantsWithCorrectKey() {
|
|
24
|
-
FidelCardVerificationChoiceAdapter sut = new FidelCardVerificationChoiceAdapter(null);
|
|
25
|
-
|
|
26
|
-
Map<String, Object> constants = sut.getConstants();
|
|
27
|
-
|
|
28
|
-
assertTrue(constants.containsKey(CARD_VERIFICATION_CHOICE));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@Test
|
|
32
|
-
public void test_ShouldExposeConstantsThatContainDelegatedToThirdParty() {
|
|
33
|
-
FidelCardVerificationChoiceAdapter sut = new FidelCardVerificationChoiceAdapter(null);
|
|
34
|
-
|
|
35
|
-
Map<String, Object> constants = sut.getConstants();
|
|
36
|
-
|
|
37
|
-
Map<String, String> verificationChoicesMap = (HashMap) constants.get(CARD_VERIFICATION_CHOICE);
|
|
38
|
-
assertEquals(CARD_VERIFICATION_DELEGATED_TO_THIRD_PARTY, verificationChoicesMap.get(CARD_VERIFICATION_DELEGATED_TO_THIRD_PARTY));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Test
|
|
42
|
-
public void test_ShouldExposeConstantsThatContainOnTheSpot() {
|
|
43
|
-
FidelCardVerificationChoiceAdapter sut = new FidelCardVerificationChoiceAdapter(null);
|
|
44
|
-
|
|
45
|
-
Map<String, Object> constants = sut.getConstants();
|
|
46
|
-
|
|
47
|
-
Map<String, String> verificationChoicesMap = (HashMap) constants.get(CARD_VERIFICATION_CHOICE);
|
|
48
|
-
assertEquals(CARD_VERIFICATION_ON_THE_SPOT, verificationChoicesMap.get(CARD_VERIFICATION_ON_THE_SPOT));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@Test
|
|
52
|
-
public void test_ShouldAdaptOnTheSpotVerificationChoiceCorrectly() {
|
|
53
|
-
FidelCardVerificationChoiceAdapter sut = new FidelCardVerificationChoiceAdapter(JavaOnlyMap::new);
|
|
54
|
-
|
|
55
|
-
ReadableMap map = sut.adapt(CardVerificationChoice.ON_THE_SPOT);
|
|
56
|
-
|
|
57
|
-
assertEquals(CARD_VERIFICATION_ON_THE_SPOT, map.getString(CARD_VERIFICATION_CHOICE));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@Test
|
|
61
|
-
public void test_ShouldAdaptDelegatedToThirdPartyCorrectly() {
|
|
62
|
-
FidelCardVerificationChoiceAdapter sut = new FidelCardVerificationChoiceAdapter(JavaOnlyMap::new);
|
|
63
|
-
|
|
64
|
-
ReadableMap map = sut.adapt(CardVerificationChoice.DELEGATED_TO_THIRD_PARTY);
|
|
65
|
-
|
|
66
|
-
assertEquals(CARD_VERIFICATION_DELEGATED_TO_THIRD_PARTY, map.getString(CARD_VERIFICATION_CHOICE));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|