diff --git a/Sources/Public/Events/ATTNAddToCartEvent.swift b/Sources/Public/Events/ATTNAddToCartEvent.swift index 4323338..7e02c09 100644 --- a/Sources/Public/Events/ATTNAddToCartEvent.swift +++ b/Sources/Public/Events/ATTNAddToCartEvent.swift @@ -12,9 +12,15 @@ public final class ATTNAddToCartEvent: NSObject, ATTNEvent { @objc public let items: [ATTNItem] @objc public var deeplink: String? - @objc - public init(items: [ATTNItem]) { + @objc(initWithItems:) + public convenience init(items: [ATTNItem]) { + self.init(items: items) + } + + @objc(initWithItems:deeplink:) + public init(items: [ATTNItem], deeplink: String?) { self.items = items + self.deeplink = deeplink super.init() } diff --git a/Sources/Public/Events/ATTNProductViewEvent.swift b/Sources/Public/Events/ATTNProductViewEvent.swift index 22b0cb6..7ac0176 100644 --- a/Sources/Public/Events/ATTNProductViewEvent.swift +++ b/Sources/Public/Events/ATTNProductViewEvent.swift @@ -13,8 +13,14 @@ public final class ATTNProductViewEvent: NSObject, ATTNEvent { @objc public var deeplink: String? @objc(initWithItems:) - public init(items: [ATTNItem]) { + public convenience init(items: [ATTNItem]) { + self.init(items: items, deeplink: nil) + } + + @objc(initWithItems:deeplink:) + public init(items: [ATTNItem], deeplink: String?) { self.items = items + self.deeplink = deeplink super.init() } diff --git a/Tests/TestCases/ATTNProductViewEventTests.swift b/Tests/TestCases/ATTNProductViewEventTests.swift index 3ba71e7..33ebf6b 100644 --- a/Tests/TestCases/ATTNProductViewEventTests.swift +++ b/Tests/TestCases/ATTNProductViewEventTests.swift @@ -20,8 +20,7 @@ final class ATTNProductViewEventTests: XCTestCase { func testProductView_GivenData_ShouldBuildURLWithRequestURL() { let item = ATTNTestEventUtils.buildItem() - let productView = ATTNProductViewEvent(items: [item]) - productView.deeplink = "https://www.clientapp.com/flow=payment" + let productView = ATTNProductViewEvent(items: [item], deeplink: "https://www.clientapp.com/flow=payment") XCTAssertFalse(productView.eventRequests.isEmpty) let requestURL = productView.eventRequests.first?.metadata["requestURL"] as? String XCTAssertNotNil(requestURL)