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

Deprecated reject method with Reject enum and replace it with String #143

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading