-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(predict): created implemeteation for predict track methods
SUITEDEV-35484 Co-authored-by: LasOri <[email protected]>
- Loading branch information
1 parent
4e772fb
commit f7c32bd
Showing
9 changed files
with
390 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// | ||
// Copyright © 2024 Emarsys-Technologies Kft. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
struct GathererPredict: PredictInstance { | ||
func trackCart(items: [any CartItem]) { | ||
|
||
} | ||
|
||
func trackPurchase(orderId: String, items: [any CartItem]) { | ||
|
||
} | ||
|
||
func trackItemView(itemId: String) { | ||
|
||
} | ||
|
||
func trackCategoryView(categoryPath: String) { | ||
|
||
} | ||
|
||
func trackSearchTerm(_ searchTerm: String) { | ||
|
||
} | ||
|
||
func trackTag(_ tag: String, attributes: [String : String]?) { | ||
|
||
} | ||
|
||
func trackRecommendationClick(product: any Product) { | ||
|
||
} | ||
|
||
func recommendProducts(logic: Logic, filters: [Filter]?, limit: Int?, availabilityZone: String?) async -> [any Product] { | ||
return [] | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// | ||
// Copyright © 2024 Emarsys-Technologies Kft. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct LoggingPredict: PredictInstance { | ||
let sdkLogger: SdkLogger | ||
|
||
func trackCart(items: [any CartItem]) { | ||
|
||
} | ||
|
||
func trackPurchase(orderId: String, items: [any CartItem]) { | ||
|
||
} | ||
|
||
func trackItemView(itemId: String) { | ||
|
||
} | ||
|
||
func trackCategoryView(categoryPath: String) { | ||
|
||
} | ||
|
||
func trackSearchTerm(_ searchTerm: String) { | ||
|
||
} | ||
|
||
func trackTag(_ tag: String, attributes: [String : String]?) { | ||
|
||
} | ||
|
||
func trackRecommendationClick(product: any Product) { | ||
|
||
} | ||
|
||
func recommendProducts(logic: Logic, filters: [Filter]?, limit: Int?, availabilityZone: String?) async -> [any Product] { | ||
return [] | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// | ||
// Copyright © 2024 Emarsys-Technologies Kft. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias PredictInstance = ActivationAware & PredictApi | ||
|
||
class Predict<LoggingInstance: PredictInstance, GathererInstance: PredictInstance, InternalInstance: PredictInstance>: GenericApi<LoggingInstance, GathererInstance, InternalInstance>, PredictInstance { | ||
|
||
func trackCart(items: [any CartItem]) { | ||
guard let active = self.active as? PredictApi else { | ||
return | ||
} | ||
active.trackCart(items: items) | ||
} | ||
|
||
func trackPurchase(orderId: String, items: [any CartItem]) { | ||
guard let active = self.active as? PredictApi else { | ||
return | ||
} | ||
active.trackPurchase(orderId: orderId, items: items) | ||
} | ||
|
||
func trackItemView(itemId: String) { | ||
guard let active = self.active as? PredictApi else { | ||
return | ||
} | ||
active.trackItemView(itemId: itemId) | ||
} | ||
|
||
func trackCategoryView(categoryPath: String) { | ||
guard let active = self.active as? PredictApi else { | ||
return | ||
} | ||
active.trackCategoryView(categoryPath: categoryPath) | ||
} | ||
|
||
func trackSearchTerm(_ searchTerm: String) { | ||
guard let active = self.active as? PredictApi else { | ||
return | ||
} | ||
active.trackSearchTerm(searchTerm) | ||
} | ||
|
||
func trackTag(_ tag: String, attributes: [String : String]?) { | ||
guard let active = self.active as? PredictApi else { | ||
return | ||
} | ||
active.trackTag(tag, attributes: attributes) | ||
} | ||
|
||
func trackRecommendationClick(product: any Product) { | ||
guard let active = self.active as? PredictApi else { | ||
return | ||
} | ||
active.trackRecommendationClick(product: product) | ||
} | ||
|
||
func recommendProducts(logic: Logic, filters: [Filter]?, limit: Int?, availabilityZone: String?) async -> [any Product] { | ||
return [] | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// | ||
// Copyright © 2024 Emarsys-Technologies Kft. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class PredictInternal: PredictInstance { | ||
func trackCart(items: [any CartItem]) { | ||
|
||
} | ||
|
||
func trackPurchase(orderId: String, items: [any CartItem]) { | ||
|
||
} | ||
|
||
func trackItemView(itemId: String) { | ||
|
||
} | ||
|
||
func trackCategoryView(categoryPath: String) { | ||
|
||
} | ||
|
||
func trackSearchTerm(_ searchTerm: String) { | ||
|
||
} | ||
|
||
func trackTag(_ tag: String, attributes: [String : String]?) { | ||
|
||
} | ||
|
||
func trackRecommendationClick(product: any Product) { | ||
|
||
} | ||
|
||
func recommendProducts(logic: Logic, filters: [Filter]?, limit: Int?, availabilityZone: String?) async -> [any Product] { | ||
return [] | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// | ||
// Copyright © 2024 Emarsys-Technologies Kft. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import Foundation | ||
import mimic | ||
@testable import EmarsysSDK | ||
|
||
|
||
struct FakePredictApi: PredictInstance, Mimic { | ||
let fnTrackCartItems = Fn<()>() | ||
let fnTrackPurchase = Fn<()>() | ||
let fnTrackItemView = Fn<()>() | ||
let fnTrackCategoryView = Fn<()>() | ||
let fnTrackSearchTerm = Fn<()>() | ||
let fnTrackTag = Fn<()>() | ||
let fnTrackRecommendationClick = Fn<()>() | ||
let fnRecommendProducts = Fn<([Product])>() | ||
|
||
func trackCart(items: [any CartItem]) { | ||
return try! self.fnTrackCartItems.invoke(params: items) | ||
} | ||
|
||
func trackPurchase(orderId: String, items: [CartItem]) { | ||
return try! self.fnTrackPurchase.invoke(params: orderId, items) | ||
} | ||
|
||
func trackItemView(itemId: String) { | ||
return try! self.fnTrackItemView.invoke(params: itemId) | ||
} | ||
|
||
func trackCategoryView(categoryPath: String) { | ||
return try! self.fnTrackCategoryView.invoke(params: categoryPath) | ||
} | ||
|
||
func trackSearchTerm(_ searchTerm: String) { | ||
return try! self.fnTrackSearchTerm.invoke(params: searchTerm) | ||
} | ||
|
||
func trackTag(_ tag: String, attributes: [String: String]?) { | ||
return try! self.fnTrackTag.invoke(params: tag, attributes) | ||
} | ||
|
||
func trackRecommendationClick(product: Product) { | ||
return try! self.fnTrackRecommendationClick.invoke(params: product) | ||
} | ||
|
||
func recommendProducts(logic: Logic, filters: [Filter]?, limit: Int?, availabilityZone: String?) async -> [any Product] { | ||
return try! self.fnRecommendProducts.invoke(params: logic, filters, limit, availabilityZone) | ||
} | ||
} |
Oops, something went wrong.