Skip to content

Commit

Permalink
Fixes #169: Replace WMTOperationHistoryEntry with regular `WMTUserO…
Browse files Browse the repository at this point in the history
…peration` and enrich it with status
  • Loading branch information
Hopsaheysa committed Sep 23, 2024
1 parent b945560 commit d7031cd
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 72 deletions.
4 changes: 0 additions & 4 deletions WultraMobileTokenSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
DCC5CCD8244DBBBD004679AC /* WMTAuthorizationData.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC5CCD7244DBBBD004679AC /* WMTAuthorizationData.swift */; };
DCC5CCDA244DBBE2004679AC /* WMTRejectionData.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC5CCD9244DBBE2004679AC /* WMTRejectionData.swift */; };
DCD8B336246C1BAF00385F02 /* WMTRejectionReason.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD8B335246C1BAF00385F02 /* WMTRejectionReason.swift */; };
DCE5EAB026BD81150061861A /* WMTOperationHistoryEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE5EAAF26BD81150061861A /* WMTOperationHistoryEntry.swift */; };
DCE660D124CEBECA00870E53 /* IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE660D024CEBECA00870E53 /* IntegrationTests.swift */; };
DCE660D324CEF56400870E53 /* IntegrationProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE660D224CEF56400870E53 /* IntegrationProxy.swift */; };
EA294F3D29F6A07A00A0494E /* WMTOperationUIData.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA294F3C29F6A07A00A0494E /* WMTOperationUIData.swift */; };
Expand Down Expand Up @@ -149,7 +148,6 @@
DCC5CCD7244DBBBD004679AC /* WMTAuthorizationData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTAuthorizationData.swift; sourceTree = "<group>"; };
DCC5CCD9244DBBE2004679AC /* WMTRejectionData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTRejectionData.swift; sourceTree = "<group>"; };
DCD8B335246C1BAF00385F02 /* WMTRejectionReason.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTRejectionReason.swift; sourceTree = "<group>"; };
DCE5EAAF26BD81150061861A /* WMTOperationHistoryEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTOperationHistoryEntry.swift; sourceTree = "<group>"; };
DCE660D024CEBECA00870E53 /* IntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntegrationTests.swift; sourceTree = "<group>"; };
DCE660D224CEF56400870E53 /* IntegrationProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntegrationProxy.swift; sourceTree = "<group>"; };
EA294F3C29F6A07A00A0494E /* WMTOperationUIData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTOperationUIData.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -231,7 +229,6 @@
DCC5CCAD2449F7AC004679AC /* WMTUserOperation.swift */,
DCC5CCB02449F81C004679AC /* WMTOperationFormData.swift */,
DC8CB205244DD007009DDAA3 /* WMTAllowedOperationSignature.swift */,
DCE5EAAF26BD81150061861A /* WMTOperationHistoryEntry.swift */,
EA294F3C29F6A07A00A0494E /* WMTOperationUIData.swift */,
EA9CE2BD2AEAA9FD00FE4E35 /* WMTProximityCheck.swift */,
EA74F7B22C2561BB004340B9 /* WMTResultTexts.swift */,
Expand Down Expand Up @@ -646,7 +643,6 @@
DC8CB206244DD007009DDAA3 /* WMTAllowedOperationSignature.swift in Sources */,
DCC3420424E3DB310045D27D /* WMTPushParser.swift in Sources */,
BFEEB20529379C700047941D /* WMTInboxGetMessageDetail.swift in Sources */,
DCE5EAB026BD81150061861A /* WMTOperationHistoryEntry.swift in Sources */,
EACAF7B02A126B7D0021CA54 /* WMTJsonValue.swift in Sources */,
DCAB7BCA24580BAC0006989D /* WMTQROperation.swift in Sources */,
DCC5CCBF2449F981004679AC /* WMTOperationAttributePartyInfo.swift in Sources */,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,23 @@ open class WMTUserOperation: WMTOperation, Codable {
///
/// Max 32 characters are expected. Possible values depend on the backend implementation and configuration.
public let statusReason: String?

/// Processing status of the operation
public let status: Status

/// Processing status of the operation
public enum Status: String, Codable, CaseIterable {
/// Operation was approved
case approved = "APPROVED"
/// Operation was rejected
case rejected = "REJECTED"
/// Operation is pending its resolution
case pending = "PENDING"
/// Operation was canceled
case canceled = "CANCELED"
/// Operation expired
case expired = "EXPIRED"
/// Operation failed
case failed = "FAILED"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum WMTOperationEndpoints {
}

enum History {
typealias EndpointType = WPNEndpointSigned<WPNRequestBase, WPNResponseArray<WMTOperationHistoryEntry>>
typealias EndpointType = WPNEndpointSigned<WPNRequestBase, WPNResponseArray<WMTUserOperation>>
static let endpoint: EndpointType = WPNEndpointSigned(endpointURLPath: "/api/auth/token/app/operation/history", uriId: "/operation/history")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class WMTOperationsImpl<T: WMTUserOperation>: WMTOperations, WMTService {
return task
}

func getHistory(authentication: PowerAuthAuthentication, completion: @escaping (Result<[WMTOperationHistoryEntry], WMTError>) -> Void) -> Operation? {
func getHistory(authentication: PowerAuthAuthentication, completion: @escaping (Result<[WMTUserOperation], WMTError>) -> Void) -> Operation? {

guard validateActivation(completion) else {
return nil
Expand Down
2 changes: 1 addition & 1 deletion WultraMobileTokenSDK/Operations/WMTOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public protocol WMTOperations: AnyObject {
/// This completion is always called on the main thread.
/// - Returns: Operation object for its state observation.
@discardableResult
func getHistory(authentication: PowerAuthAuthentication, completion: @escaping(Result<[WMTOperationHistoryEntry], WMTError>) -> Void) -> Operation?
func getHistory(authentication: PowerAuthAuthentication, completion: @escaping(Result<[WMTUserOperation], WMTError>) -> Void) -> Operation?

/// Retrieves operation detail based on operation ID
/// - Parameters:
Expand Down
6 changes: 3 additions & 3 deletions WultraMobileTokenSDKTests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ class IntegrationTests: XCTestCase {
_ = self.ops.getHistory(authentication: auth) { result in
switch result {
case .success(let ops):
if let opFromList = ops.first(where: { $0.operation.id == op.operationId }) {
XCTAssertEqual(opFromList.operation.statusReason, cancelReason, "statusReason and cancelReason must be the same")
if let opFromList = ops.first(where: { $0.id == op.operationId }) {
XCTAssertEqual(opFromList.statusReason, cancelReason, "statusReason and cancelReason must be the same")
} else {
XCTFail("Created operation was not in the history")
}
Expand Down Expand Up @@ -475,7 +475,7 @@ class IntegrationTests: XCTestCase {
self.ops.getHistory(authentication: auth) { result in
switch result {
case .success(let ops):
if let opFromList = ops.first(where: { $0.operation.id == op.operationId }) {
if let opFromList = ops.first(where: { $0.id == op.operationId }) {
XCTAssertEqual(opFromList.status, .pending)
} else {
XCTFail("Created operation was not in the history")
Expand Down
Loading

0 comments on commit d7031cd

Please sign in to comment.