This file contains hidden or 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
| struct PromotionViewControllerStyle { | |
| let contentView: String | |
| } |
This file contains hidden or 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
| class EBookPromotionSplitTest: SplitTestProtocol { | |
| typealias ValueType = PromotionViewControllerStyle | |
| static var identifier: String = "ebookPromotionTest" | |
| var value: PromotionViewControllerStyle | |
| required init(group: String) { | |
| self.value = | |
| group == "social" ? | |
| PromotionViewControllerStyle.init(contentView: "\(TwitterView.self)") |
This file contains hidden or 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
| class SplitTestingManager { | |
| static func getSplitValue<Value: SplitTestProtocol>(for split: Value.Type) -> Value.ValueType { | |
| let group = UserDefaults.standard.value(forKey: split.self.identifier) as! String | |
| return Value(group: group).value | |
| } | |
| } |
This file contains hidden or 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
| protocol SplitTestProtocol { | |
| associatedtype ValueType: Any | |
| static var identifier: String {get} | |
| var value: ValueType {get} | |
| init(group: String) | |
| } |
This file contains hidden or 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
| protocol ICouponManager { | |
| func getAtiveCoupon() -> Coupon? | |
| } | |
| class CouponManager: ICouponManager { | |
| //Same Implementation as from above | |
| } | |
| class MockCouponManager: ICouponManager { | |
| func getAtiveCoupon() -> Coupon? { |
This file contains hidden or 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
| PaymentManager(couponManager: MockCouponManager()) | |
| PaymentManager(couponManager: CouponManager()) |
This file contains hidden or 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
| init(paymentManager: PaymentManager) { | |
| self.paymentManager = paymentManager | |
| super.init(nibName: nil, bundle: nil) | |
| } | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| paymentManager.loadProductPrice(completion: configureWithPrice) | |
| } |
This file contains hidden or 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
| class CouponManager { | |
| func logEvent(_ event: Event) { | |
| //Code for saving the ocurrign event | |
| } | |
| func deleteUsedCoupon(_ coupon: Coupon) { | |
| //Code that erases the coupon after user has redemed it | |
| } | |
| func getAtiveCoupon() -> Coupon? { |
This file contains hidden or 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
| class PaymentManager { | |
| private let dataLoader: PaymentDataLoader | |
| private let priceManager: PriceCalculator | |
| private let couponManager: CouponManager | |
| init(dataLoader: PaymentDataLoader, priceManager: PriceCalculator, couponManager: CouponManager) { | |
| self.dataLoader = dataLoader | |
| self.priceManager = priceManager | |
| self.couponManager = couponManager | |
| } |
This file contains hidden or 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
| /* | |
| We offer discount if user cancelled the payment half-way through, | |
| and if user canceled our payment screen multiple times | |
| */ | |
| func getPriceDiscountPercentage() -> Double { | |
| if UserDefaults.standard.bool(forKey: "kPaymentCancelledHalfWay") { | |
| return 0.5 | |
| } | |
| let timesScreenOpened = UserDefaults.standard.integer(forKey: "knumberOfTimesPaymentScreenOpened") | |
| if timesScreenOpened > 3 { |