Skip to content

Commit

Permalink
Merge pull request #327 from Iterable/feature/mob-1373-replace-iterab…
Browse files Browse the repository at this point in the history
…leresult

[MOB-1373] - Replace iterableResult
  • Loading branch information
tapashmajumder committed May 27, 2020
2 parents cbb29ce + eae97e6 commit 3394b0a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
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

0 comments on commit 3394b0a

Please sign in to comment.