Skip to content

Commit

Permalink
Moved ui object from the mtoken to SDK (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
kober32 authored Jun 23, 2023
1 parent 1da06e9 commit 6876fa0
Show file tree
Hide file tree
Showing 12 changed files with 1,029 additions and 2 deletions.
40 changes: 40 additions & 0 deletions WultraMobileTokenSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
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 */; };
EA44366A29F9294600DDEC1C /* WMTPostApprovaScreenReview.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA44366929F9294600DDEC1C /* WMTPostApprovaScreenReview.swift */; };
EA44366C29F9297100DDEC1C /* WMTPostApprovaScreenRedirect.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA44366B29F9297100DDEC1C /* WMTPostApprovaScreenRedirect.swift */; };
EA44366E29F9298100DDEC1C /* WMTPostApprovaScreenGeneric.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA44366D29F9298100DDEC1C /* WMTPostApprovaScreenGeneric.swift */; };
EA6DDF0F29F8036B0011E234 /* WMTPreApprovalScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6DDF0E29F8036B0011E234 /* WMTPreApprovalScreen.swift */; };
EA6DDF1A29F804D60011E234 /* WMTPostApprovalScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6DDF1929F804D60011E234 /* WMTPostApprovalScreen.swift */; };
EA6DDF1C29F807230011E234 /* OperationUIDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6DDF1B29F807230011E234 /* OperationUIDataTests.swift */; };
EACAF7B02A126B7D0021CA54 /* WMTJsonValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = EACAF7AF2A126B7D0021CA54 /* WMTJsonValue.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -139,6 +147,14 @@
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>"; };
EA44366929F9294600DDEC1C /* WMTPostApprovaScreenReview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPostApprovaScreenReview.swift; sourceTree = "<group>"; };
EA44366B29F9297100DDEC1C /* WMTPostApprovaScreenRedirect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPostApprovaScreenRedirect.swift; sourceTree = "<group>"; };
EA44366D29F9298100DDEC1C /* WMTPostApprovaScreenGeneric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPostApprovaScreenGeneric.swift; sourceTree = "<group>"; };
EA6DDF0E29F8036B0011E234 /* WMTPreApprovalScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPreApprovalScreen.swift; sourceTree = "<group>"; };
EA6DDF1929F804D60011E234 /* WMTPostApprovalScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPostApprovalScreen.swift; sourceTree = "<group>"; };
EA6DDF1B29F807230011E234 /* OperationUIDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationUIDataTests.swift; sourceTree = "<group>"; };
EACAF7AF2A126B7D0021CA54 /* WMTJsonValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTJsonValue.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -200,11 +216,13 @@
DC3D0B352480F368000DC4D9 /* UserOperation */ = {
isa = PBXGroup;
children = (
EA6DDF0D29F8031F0011E234 /* Screens */,
DC059A3C244DD30900B24878 /* Attributes */,
DCC5CCAD2449F7AC004679AC /* WMTUserOperation.swift */,
DCC5CCB02449F81C004679AC /* WMTOperationFormData.swift */,
DC8CB205244DD007009DDAA3 /* WMTAllowedOperationSignature.swift */,
DCE5EAAF26BD81150061861A /* WMTOperationHistoryEntry.swift */,
EA294F3C29F6A07A00A0494E /* WMTOperationUIData.swift */,
);
path = UserOperation;
sourceTree = "<group>";
Expand Down Expand Up @@ -246,6 +264,7 @@
DC5F6DE724E14FA100D351D3 /* Configs */,
DC616237248508F8000DED17 /* Info.plist */,
DC61624124852B6D000DED17 /* NetworkingObjectsTests.swift */,
EA6DDF1B29F807230011E234 /* OperationUIDataTests.swift */,
DCE660D024CEBECA00870E53 /* IntegrationTests.swift */,
DCE660D224CEF56400870E53 /* IntegrationProxy.swift */,
DC395C0924E55B9B0007C36E /* PushParserTests.swift */,
Expand All @@ -269,6 +288,7 @@
isa = PBXGroup;
children = (
DC6E52D5259C964600FC25BE /* WMTOperationExpirationWatcher.swift */,
EACAF7AF2A126B7D0021CA54 /* WMTJsonValue.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -408,6 +428,18 @@
path = Requests;
sourceTree = "<group>";
};
EA6DDF0D29F8031F0011E234 /* Screens */ = {
isa = PBXGroup;
children = (
EA6DDF0E29F8036B0011E234 /* WMTPreApprovalScreen.swift */,
EA6DDF1929F804D60011E234 /* WMTPostApprovalScreen.swift */,
EA44366B29F9297100DDEC1C /* WMTPostApprovaScreenRedirect.swift */,
EA44366929F9294600DDEC1C /* WMTPostApprovaScreenReview.swift */,
EA44366D29F9298100DDEC1C /* WMTPostApprovaScreenGeneric.swift */,
);
path = Screens;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -545,6 +577,7 @@
DC395C0A24E55B9B0007C36E /* PushParserTests.swift in Sources */,
DC6EDB7925A49ED900A229E4 /* OperationExpirationTests.swift in Sources */,
DC616236248508F8000DED17 /* QROperationParserTests.swift in Sources */,
EA6DDF1C29F807230011E234 /* OperationUIDataTests.swift in Sources */,
DCE660D124CEBECA00870E53 /* IntegrationTests.swift in Sources */,
DCE660D324CEF56400870E53 /* IntegrationProxy.swift in Sources */,
);
Expand All @@ -571,14 +604,19 @@
DC6E52D6259C964600FC25BE /* WMTOperationExpirationWatcher.swift in Sources */,
DCC5CCDA244DBBE2004679AC /* WMTRejectionData.swift in Sources */,
DC48803F292282FF00DB844B /* WMTInboxMessageDetail.swift in Sources */,
EA6DDF0F29F8036B0011E234 /* WMTPreApprovalScreen.swift in Sources */,
DCAB7BC824580B4C0006989D /* WMTQROperationParser.swift in Sources */,
EA44366C29F9297100DDEC1C /* WMTPostApprovaScreenRedirect.swift in Sources */,
DCC5CCB12449F81C004679AC /* WMTOperationFormData.swift in Sources */,
DCC5CCD4244DBA1C004679AC /* WMTOperationEndpoints.swift in Sources */,
DC488031292282C900DB844B /* WMTService.swift in Sources */,
EA6DDF1A29F804D60011E234 /* WMTPostApprovalScreen.swift in Sources */,
DCC5CCB92449F93C004679AC /* WMTOperationAttributeKeyValue.swift in Sources */,
DCC5CCBB2449F952004679AC /* WMTOperationAttributeNote.swift in Sources */,
BFEEB2092937A2680047941D /* WMTInboxGetList.swift in Sources */,
BFEEB20729379F960047941D /* WMTInboxSetMessageRead.swift in Sources */,
EA44366A29F9294600DDEC1C /* WMTPostApprovaScreenReview.swift in Sources */,
EA294F3D29F6A07A00A0494E /* WMTOperationUIData.swift in Sources */,
DCC5CCB32449F8CD004679AC /* WMTOperationAttribute.swift in Sources */,
DCC5CCAC2449F765004679AC /* WMTOperationsImpl.swift in Sources */,
DC06D01F25AC74E400F2EA69 /* WMTLock.swift in Sources */,
Expand All @@ -590,12 +628,14 @@
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 */,
DC81D1CB244F451E00F80CD6 /* WMTPushImpl.swift in Sources */,
DC488041292282FF00DB844B /* WMTInboxEndpoints.swift in Sources */,
BF53DFC82971905600829814 /* WMTInboxContentType.swift in Sources */,
DCA43C6D2993F63E0059A163 /* WMTOperationAttributeImage.swift in Sources */,
EA44366E29F9298100DDEC1C /* WMTPostApprovaScreenGeneric.swift in Sources */,
DC48803D292282FF00DB844B /* WMTInbox.swift in Sources */,
DC488042292282FF00DB844B /* WMTInboxImpl.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Copyright 2023 Wultra s.r.o.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions
// and limitations under the License.
//

import Foundation

/// Generic screen may contain any object
public class WMTPostApprovalScreenGeneric: WMTPostApprovalScreen {

/// Heading of the post-approval screen
public let heading: String

/// Message to the user
public let message: String

/// Generic data defined on server
public let payload: WMTJSONValue

// MARK: Internals

private enum Keys: String, CodingKey {
case heading, message, payload
}

public required init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: Keys.self)
heading = try c.decode(String.self, forKey: .heading)
message = try c.decode(String.self, forKey: .message)
payload = try c.decode(WMTJSONValue.self, forKey: .payload)
try super.init(from: decoder)
}

public init(heading: String, message: String, payload: WMTJSONValue) {
self.heading = heading
self.message = message
self.payload = payload
super.init(type: .generic)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// Copyright 2023 Wultra s.r.o.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions
// and limitations under the License.
//

import Foundation

/// Redirect screen prepares for merchant redirect
public class WMTPostApprovalScreenRedirect: WMTPostApprovalScreen {

/// Heading of the post-approval screen
public let heading: String

/// Message to the user
public let message: String

/// Payload with data about action after the operation
public let payload: WMTRedirectPostApprovalScreenPayload

private enum Keys: String, CodingKey {
case heading, message, payload
}

public init(heading: String, message: String, payload: WMTRedirectPostApprovalScreenPayload, type: ScreenType) {
self.heading = heading
self.message = message
self.payload = payload
super.init(type: type)
}

public required init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: Keys.self)
heading = try c.decode(String.self, forKey: .heading)
message = try c.decode(String.self, forKey: .message)
payload = try c.decode(WMTRedirectPostApprovalScreenPayload.self, forKey: .payload)
try super.init(from: decoder)
}
}

/// Payload with data about redirecting after the operation
public class WMTRedirectPostApprovalScreenPayload: WMTPostApprovalScreenPayload {

/// Text for the button title
public let text: String

/// URL where to redirect
public let url: String

/// Countdown after which the redirect should happen in seconds
public let countdown: Int

// MARK: Internals

private enum Keys: String, CodingKey {
case text = "redirectText"
case url = "redirectUrl"
case countdown = "countdown"
}

public init(text: String, url: String, countdown: Int) {
self.text = text
self.url = url
self.countdown = countdown
super.init()
}

required init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: Keys.self)
text = try c.decode(String.self, forKey: .text)
url = try c.decode(String.self, forKey: .url)
countdown = try c.decode(Int.self, forKey: .countdown)
super.init()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// Copyright 2023 Wultra s.r.o.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions
// and limitations under the License.
//

import Foundation

/// Review screen shows the operation attributes
public class WMTPostApprovalScreenReview: WMTPostApprovalScreen {

/// Heading of the post-approval screen
public let heading: String

/// Message to the user
public let message: String

/// Payload with data about action after the operation
public let payload: WMTReviewPostApprovalScreenPayload
// MARK: Internals

private enum Keys: String, CodingKey {
case heading, message, payload
}

public init(heading: String, message: String, payload: WMTReviewPostApprovalScreenPayload, type: ScreenType) {
self.heading = heading
self.message = message
self.payload = payload
super.init(type: type)
}

public required init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: Keys.self)
heading = try c.decode(String.self, forKey: .heading)
message = try c.decode(String.self, forKey: .message)
payload = try c.decode(WMTReviewPostApprovalScreenPayload.self, forKey: .payload)
try super.init(from: decoder)
}
}

/// Payload of the review post-approval screen shows the operation attributes.
public class WMTReviewPostApprovalScreenPayload: WMTPostApprovalScreenPayload {

/// Attributes as in FormData but its data might be only a subset
public let attributes: [WMTOperationAttribute]

// MARK: Internals

public required init(from decoder: Decoder) throws {

let c = try decoder.container(keyedBy: Keys.self)
attributes = (try? c.decode([WMTOperationAttributeDecodable].self, forKey: .attributes).map {
$0.attrObject }) ?? []
super.init()
}

public init(attributes: [WMTOperationAttribute]) {
self.attributes = attributes
super.init()
}

private enum Keys: CodingKey {
case attributes
}
}
Loading

0 comments on commit 6876fa0

Please sign in to comment.