-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved ui object from the mtoken to SDK (#118)
- Loading branch information
Showing
12 changed files
with
1,029 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...raMobileTokenSDK/Operations/Model/UserOperation/Screens/WMTPostApprovaScreenGeneric.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...aMobileTokenSDK/Operations/Model/UserOperation/Screens/WMTPostApprovaScreenRedirect.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
WultraMobileTokenSDK/Operations/Model/UserOperation/Screens/WMTPostApprovaScreenReview.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.