Skip to content
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

Merged
merged 3 commits into from
May 14, 2024

Conversation

ianlin-bbpos
Copy link
Collaborator

Summary

Add method of supportsReadersOfType

Motivation

Testing

  • I tested this manually
  • I added automated tests

Documentation

Select one:

  • I have added relevant documentation for my changes.
  • This PR does not result in any developer-facing changes.

resolve(["readerSupportResult": false])
break
}
print("hhhh")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️

Comment on lines +152 to +168
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
}

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?

Copy link
Collaborator Author

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..

Comment on lines 1147 to 1150
guard invalidParams == nil else {
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide \(invalidParams!) parameters."))
return
}
Copy link
Collaborator

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:

Suggested change
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
}

resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide correct deviceType parameter."))
return
}
print("supportsReadersOfType")
Copy link
Collaborator

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

Comment on lines 1156 to 1161
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)
Copy link
Collaborator

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

Suggested change
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)

@nazli-stripe nazli-stripe merged commit 858724b into main May 14, 2024
2 checks passed
@nazli-stripe nazli-stripe deleted the bbpos/supports-readers-of-type branch September 6, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants