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

[MOB-1373] - Replace iterableResult #327

Merged
merged 1 commit into from
May 27, 2020
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
2 changes: 1 addition & 1 deletion swift-sdk/Internal/InAppHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct InAppHelper {
}

// process each parseResult and consumes failed message, if messageId is present
private static func process(parseResult: IterableResult<IterableInAppMessage, InAppMessageParser.ParseError>, apiClient: ApiClientProtocol) -> IterableInAppMessage? {
private static func process(parseResult: Result<IterableInAppMessage, InAppMessageParser.ParseError>, apiClient: ApiClientProtocol) -> IterableInAppMessage? {
switch parseResult {
case let .failure(parseError):
switch parseError {
Expand Down
4 changes: 2 additions & 2 deletions swift-sdk/Internal/InAppMessageParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct InAppMessageParser {

/// Given json payload, It will construct array of IterableInAppMessage or ParseError
/// The caller needs to make sure to consume errored out messages
static func parse(payload: [AnyHashable: Any]) -> [IterableResult<IterableInAppMessage, ParseError>] {
static func parse(payload: [AnyHashable: Any]) -> [Result<IterableInAppMessage, ParseError>] {
return getInAppDicts(fromPayload: payload).map {
let oneJson = preProcessOneJson(fromJson: $0)

Expand Down Expand Up @@ -77,7 +77,7 @@ struct InAppMessageParser {
}
}

private static func parseOneMessage(fromJson json: [AnyHashable: Any]) -> IterableResult<IterableInAppMessage, ParseError> {
private static func parseOneMessage(fromJson json: [AnyHashable: Any]) -> Result<IterableInAppMessage, ParseError> {
guard let messageId = json[JsonKey.messageId.jsonKey] as? String else {
return .failure(.parseFailed(reason: "no messageId", messageId: nil))
}
Expand Down
6 changes: 0 additions & 6 deletions swift-sdk/Internal/IterableUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import Foundation
import os
import UIKit

/// Functionality such as this will be built in for Swift 5.0. This will help with the transition
enum IterableResult<T, E> {
case success(T)
case failure(E)
}

@objc final class IterableUtil: NSObject {
static var rootViewController: UIViewController? {
if let rootViewController = UIApplication.shared.delegate?.window??.rootViewController {
Expand Down
2 changes: 1 addition & 1 deletion tests/common/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct InAppTestHelper {
return InAppMessageParser.parse(payload: payload).compactMap(parseResultToOptionalMessage)
}

private static func parseResultToOptionalMessage(result: IterableResult<IterableInAppMessage, InAppMessageParser.ParseError>) -> IterableInAppMessage? {
private static func parseResultToOptionalMessage(result: Result<IterableInAppMessage, InAppMessageParser.ParseError>) -> IterableInAppMessage? {
switch result {
case .failure:
return nil
Expand Down