-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method of supportsReadersOfType #686
Conversation
ios/StripeTerminalReactNative.swift
Outdated
resolve(["readerSupportResult": false]) | ||
break | ||
} | ||
print("hhhh") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️
internal fun mapToDeviceType(type: String): DeviceType? { | ||
return when (type) { | ||
"chipper1X" -> DeviceType.CHIPPER_1X | ||
"chipper2X" -> DeviceType.CHIPPER_2X | ||
"cotsDevice" -> DeviceType.COTS_DEVICE | ||
"etna" -> DeviceType.ETNA | ||
"stripeM2" -> DeviceType.STRIPE_M2 | ||
"stripeS700" -> DeviceType.STRIPE_S700 | ||
"stripeS700Devkit" -> DeviceType.STRIPE_S700_DEVKIT | ||
"verifoneP400" -> DeviceType.VERIFONE_P400 | ||
"wiseCube" -> DeviceType.WISECUBE | ||
"wisePad3" -> DeviceType.WISEPAD_3 | ||
"wisePad3s" -> DeviceType.WISEPAD_3S | ||
"wisePosE" -> DeviceType.WISEPOS_E | ||
"wisePosEDevkit" -> DeviceType.WISEPOS_E_DEVKIT | ||
else -> null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we keep this list up to date; i.e when there is a new device type on the android sdk, can we have a two way map; i.e also have a mapFromDeviceType
if one does not exist already, because an exhaustive when with the android DeviceType
enum model would result in a compilation error when there is a new DeviceType
enum.
Also do we have tests for the Mappers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there has a mapFromDeviceType
, I think we need to sync manually when there is a new device type..
ios/StripeTerminalReactNative.swift
Outdated
guard invalidParams == nil else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide \(invalidParams!) parameters.")) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should try to avoid using !
. Flipping to an if let
gets around that:
guard invalidParams == nil else { | |
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide \(invalidParams!) parameters.")) | |
return | |
} | |
if let invalidParams { | |
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide \(invalidParams) parameters.")) | |
return | |
} |
ios/StripeTerminalReactNative.swift
Outdated
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide correct deviceType parameter.")) | ||
return | ||
} | ||
print("supportsReadersOfType") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm the print and a few others below
ios/StripeTerminalReactNative.swift
Outdated
guard deviceType != nil else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide correct deviceType parameter.")) | ||
return | ||
} | ||
print("supportsReadersOfType") | ||
let result = Terminal.shared.supportsReaders(of: deviceType!, discoveryMethod: Mappers.mapToDiscoveryMethod(discoveryMethod), simulated: simulated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to above, would be good to avoid the deviceType!
with a simple change to use guard let
guard deviceType != nil else { | |
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide correct deviceType parameter.")) | |
return | |
} | |
print("supportsReadersOfType") | |
let result = Terminal.shared.supportsReaders(of: deviceType!, discoveryMethod: Mappers.mapToDiscoveryMethod(discoveryMethod), simulated: simulated) | |
guard let deviceType else { | |
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide correct deviceType parameter.")) | |
return | |
} | |
let result = Terminal.shared.supportsReaders(of: deviceType, discoveryMethod: Mappers.mapToDiscoveryMethod(discoveryMethod), simulated: simulated) |
Summary
Add method of supportsReadersOfType
Motivation
Testing
Documentation
Select one: