diff --git a/WultraMobileTokenSDK/Operations/Model/Requests/WMTRejectionData.swift b/WultraMobileTokenSDK/Operations/Model/Requests/WMTRejectionData.swift index 8fab115..df5df5e 100644 --- a/WultraMobileTokenSDK/Operations/Model/Requests/WMTRejectionData.swift +++ b/WultraMobileTokenSDK/Operations/Model/Requests/WMTRejectionData.swift @@ -23,10 +23,10 @@ class WMTRejectionData: Codable { let id: String /// Rejection reason - let reason: WMTRejectionReason + let reason: String init(operationId: String, reason: WMTRejectionReason) { self.id = operationId - self.reason = reason + self.reason = reason.serialized } } diff --git a/WultraMobileTokenSDK/Operations/Model/WMTRejectionReason.swift b/WultraMobileTokenSDK/Operations/Model/WMTRejectionReason.swift index f18fe1a..8617869 100644 --- a/WultraMobileTokenSDK/Operations/Model/WMTRejectionReason.swift +++ b/WultraMobileTokenSDK/Operations/Model/WMTRejectionReason.swift @@ -17,11 +17,24 @@ import Foundation /// Reason why the operation will be rejected -public enum WMTRejectionReason: String, Codable { - /// User don't want to provide the reason. - case unknown = "UNKNOWN" +public enum WMTRejectionReason { + /// User doesn't want to provide the reason. + case unknown /// Operation data does not match (for example when user found a typo or other mistake) - case incorrectData = "INCORRECT_DATA" + case incorrectData /// User didn't started this operation - case unexpectedOperation = "UNEXPECTED_OPERATION" + case unexpectedOperation + /// Represents a custom reason for rejection, allowing for flexibility in specifying rejection reasons. + /// - Parameter reason: A string describing the custom rejection reason, e.g., `POSSIBLE_FRAUD`. + case custom(_ reason: String) + + /// Returns a string representation of the rejection reason suitable for serialization. + var serialized: String { + return switch self { + case .unknown: "UNKNOWN" + case .incorrectData: "INCORRECT_DATA" + case .unexpectedOperation: "UNEXPECTED_OPERATION" + case .custom(let reason): reason + } + } } diff --git a/WultraMobileTokenSDKTests/NetworkingObjectsTests.swift b/WultraMobileTokenSDKTests/NetworkingObjectsTests.swift index f02018e..3406c81 100644 --- a/WultraMobileTokenSDKTests/NetworkingObjectsTests.swift +++ b/WultraMobileTokenSDKTests/NetworkingObjectsTests.swift @@ -337,10 +337,10 @@ class NetworkingObjectsTests: XCTestCase { func testOperationRejectionRequest() { let expectation = """ - {"requestObject":{"id":"95e51995-fa60-4018-bd87-43a58f098570","reason":"UNEXPECTED_OPERATION"}} + {"requestObject":{"id":"95e51995-fa60-4018-bd87-43a58f098570","reason":"COMPLETELLY_CUSTOM_REJECT_REASON"}} """ - let request = WMTOperationEndpoints.Reject.EndpointType.RequestData(.init(operationId: "95e51995-fa60-4018-bd87-43a58f098570", reason: .unexpectedOperation)) + let request = WMTOperationEndpoints.Reject.EndpointType.RequestData(.init(operationId: "95e51995-fa60-4018-bd87-43a58f098570", reason: .custom("COMPLETELLY_CUSTOM_REJECT_REASON"))) request.testSerialization(expectation: expectation) } diff --git a/docs/Using-Operations-Service.md b/docs/Using-Operations-Service.md index 9740dc2..304f6be 100644 --- a/docs/Using-Operations-Service.md +++ b/docs/Using-Operations-Service.md @@ -194,7 +194,7 @@ func approveWithBiometry(operation: WMTOperation) { ## Reject an Operation -To reject an operation use `WMTOperations.reject`. Operation rejection is confirmed by possession factor so there is no need for creating `PowerAuthAuthentication` object. You can simply use it with the following example. +To reject an operation use `WMTOperations.reject`. Operation rejection is confirmed by a possession factor, so there is no need for creating a `PowerAuthAuthentication` object. You can simply use it with the following example. ```swift import WultraMobileTokenSDK