Skip to content

Commit

Permalink
Deprecated reject method with Reject enum and replace it with String (#…
Browse files Browse the repository at this point in the history
…143)

* Deprecate reject method with Reject enum and replace it with String instead

* Remove RejectV2 and extend current solution for custom reject reason

* Implement remarks
  • Loading branch information
Hopsaheysa authored Jan 24, 2024
1 parent 4397eef commit 895103c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
23 changes: 18 additions & 5 deletions WultraMobileTokenSDK/Operations/Model/WMTRejectionReason.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
4 changes: 2 additions & 2 deletions WultraMobileTokenSDKTests/NetworkingObjectsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion docs/Using-Operations-Service.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 895103c

Please sign in to comment.