Skip to content

Commit

Permalink
updated events init signatures to accept deeplink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Espinola committed Jul 11, 2024
1 parent 4b119a3 commit 656b473
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions Sources/Public/Events/ATTNAddToCartEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
8 changes: 7 additions & 1 deletion Sources/Public/Events/ATTNProductViewEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
3 changes: 1 addition & 2 deletions Tests/TestCases/ATTNProductViewEventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 656b473

Please sign in to comment.