Skip to content

Commit

Permalink
order device type
Browse files Browse the repository at this point in the history
  • Loading branch information
nazli-stripe committed Mar 28, 2024
1 parent d55fd20 commit 104e7c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
11 changes: 5 additions & 6 deletions android/src/main/java/com/stripeterminalreactnative/Mappers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,16 @@ internal fun mapFromDeviceType(type: DeviceType): String {
DeviceType.COTS_DEVICE -> "cotsDevice"
DeviceType.ETNA -> "etna"
DeviceType.STRIPE_M2 -> "stripeM2"
DeviceType.STRIPE_S700 -> "stripeS700"
DeviceType.STRIPE_S700_DEVKIT -> "stripeS700Devkit"
DeviceType.UNKNOWN -> "unknown"
DeviceType.VERIFONE_P400 -> "verifoneP400"
DeviceType.WISEPAD_3 -> "wisePad3"
DeviceType.WISEPOS_E -> "wisePosE"
DeviceType.WISECUBE -> "wisecube"
DeviceType.STRIPE_S700 -> "stripeS700"
DeviceType.WISEPAD_3 -> "wisePad3"
DeviceType.WISEPAD_3S -> "wisePad3s"
DeviceType.WISEPOS_E -> "wisePosE"
DeviceType.WISEPOS_E_DEVKIT -> "wisePosEDevkit"
DeviceType.STRIPE_S700_DEVKIT -> "stripeS700Devkit"
DeviceType.STRIPE_S700 -> "stripeS700"
DeviceType.ETNA -> "etna"

}
}

Expand Down
42 changes: 21 additions & 21 deletions ios/Mappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ class Mappers {

class func mapFromDeviceType(_ type: DeviceType) -> String {
switch type {
case DeviceType.appleBuiltIn: return "appleBuiltIn"
case DeviceType.chipper1X: return "chipper1X"
case DeviceType.chipper2X: return "chipper2X"
case DeviceType.etna: return "etna"
case DeviceType.stripeM2: return "stripeM2"
case DeviceType.stripeS700: return "stripeS700"
case DeviceType.stripeS700DevKit: return "stripeS700Devkit"
case DeviceType.verifoneP400: return "verifoneP400"
case DeviceType.wiseCube: return "wiseCube"
case DeviceType.wisePad3: return "wisePad3"
case DeviceType.wisePosE: return "wisePosE"
case DeviceType.wisePosEDevKit: return "wisePosEDevkit"
case DeviceType.stripeS700DevKit: return "stripeS700Devkit"
case DeviceType.stripeS700: return "stripeS700"
case DeviceType.appleBuiltIn: return "appleBuiltIn"
case DeviceType.etna: return "etna"
default: return "unknown"
}
}
Expand Down Expand Up @@ -427,46 +427,46 @@ class Mappers {
]
return result
}

class func mapFromOfflineDetails(_ offlineDetails: OfflineDetails) -> NSDictionary {
var offlineCardPresentDetails: NSDictionary?
if let cardPresentDetails = offlineDetails.cardPresentDetails {
offlineCardPresentDetails = mapFromOfflineCardPresentDetails(cardPresentDetails)
}

var amountDetails: NSDictionary?
if let offlineAmountDetails = offlineDetails.amountDetails {
amountDetails = mapFromAmountDetails(offlineAmountDetails)
}

let result: NSDictionary = [
"storedAt": convertDateToUnixTimestamp(date: offlineDetails.collectedAt) ?? NSNull(),
"requiresUpload": offlineDetails.requiresUpload,
"cardPresentDetails": offlineCardPresentDetails ?? NSNull(),
"amountDetails": amountDetails ?? NSNull()
]

return result
}

class func mapFromAmountDetails(_ amountDetails: SCPAmountDetails?) -> NSDictionary {
let amount: NSDictionary = [
"amount": amountDetails?.tip ?? NSNull(),
]

let result: NSDictionary = [
"tip": amount
]

return result
}

class func mapFromOfflineCardPresentDetails(_ offlineCardPresentDetails: OfflineCardPresentDetails) -> NSDictionary {
var receiptDetailsMap: NSDictionary?
if let receiptDetails = offlineCardPresentDetails.receiptDetails {
receiptDetailsMap = mapFromReceiptDetails(receiptDetails)
}

let result: NSDictionary = [
"brand": offlineCardPresentDetails.brand,
"cardholderName": offlineCardPresentDetails.cardholderName ?? NSNull(),
Expand All @@ -476,7 +476,7 @@ class Mappers {
"readMethod": mapFromReadMethod(offlineCardPresentDetails.readMethod),
"receiptDetails": receiptDetailsMap ?? NSNull()
]

return result
}

Expand Down Expand Up @@ -659,7 +659,7 @@ class Mappers {

return(["sdk": sdkDict, "reader": readerDict])
}

class func mapFromReaderTextToSpeechStatus(_ status: ReaderTextToSpeechStatus) -> String {
switch status {
case ReaderTextToSpeechStatus.off: return "off"
Expand All @@ -668,12 +668,12 @@ class Mappers {
default: return "unknown"
}
}

class func mapFromReaderSettings(_ readerSettings: ReaderSettings) -> NSDictionary {
var accessibility: [String : Any] = [
"textToSpeechStatus": mapFromReaderTextToSpeechStatus(readerSettings.accessibility.textToSpeechStatus),
]

let errorDic: NSDictionary
if let error = readerSettings.accessibility.error as NSError? {
errorDic = [
Expand All @@ -685,7 +685,7 @@ class Mappers {

return(["accessibility": accessibility])
}

class func mapFromReaderDisconnectReason(_ reason: DisconnectReason) -> String {
switch reason {
case DisconnectReason.disconnectRequested: return "disconnectRequested"
Expand All @@ -697,7 +697,7 @@ class Mappers {
default: return "unknown"
}
}

class func mapFromReadMethod(_ readMethod: SCPReadMethod) -> String {
switch readMethod {
case SCPReadMethod.contactEMV: return "contactEMV"
Expand All @@ -708,7 +708,7 @@ class Mappers {
default: return "unknown"
}
}

class func mapFromCollectInputs(_ results: [CollectInputsResult]) -> NSDictionary {
var collectInputResults: [String : Any] = [:]
for result in results {
Expand Down Expand Up @@ -738,7 +738,7 @@ class Mappers {
collectInputResults["selectionResult"] = selectionResult
}
}

return (["collectInputResults": collectInputResults])
}
}
Expand Down

0 comments on commit 104e7c6

Please sign in to comment.