@@ -12,7 +12,20 @@ import kotlinx.coroutines.flow.Flow
1212import kotlinx.coroutines.flow.flowOf
1313import java.lang.ref.WeakReference
1414
15+ /* *
16+ * Public facade for interacting with the Rokt Kit through mParticle.
17+ */
1518class Rokt internal constructor(private val mKitManager : KitManager ) {
19+ /* *
20+ * Display a Rokt placement with the specified parameters.
21+ *
22+ * @param identifier The placement identifier
23+ * @param attributes User attributes to pass to Rokt
24+ * @param callbacks Optional callback for Rokt events
25+ * @param embeddedViews Optional map of embedded view placeholders
26+ * @param fontTypefaces Optional map of font typefaces
27+ * @param config Optional Rokt configuration
28+ */
1629 @JvmOverloads
1730 fun selectPlacements (
1831 identifier : String ,
@@ -43,37 +56,73 @@ class Rokt internal constructor(private val mKitManager: KitManager) {
4356 }
4457 }
4558
59+ /* *
60+ * Get a Flow of Rokt events for the specified identifier.
61+ *
62+ * @param identifier The placement identifier to listen for events
63+ * @return A Flow emitting RoktEvent objects
64+ */
4665 fun events (identifier : String ): Flow <RoktEvent > = if (isEnabled()) {
4766 resolveRoktKit()?.second?.events(identifier) ? : flowOf()
4867 } else {
4968 flowOf()
5069 }
5170
71+ /* *
72+ * Notify Rokt that a purchase has been finalized.
73+ *
74+ * @param placementId The placement identifier
75+ * @param catalogItemId The catalog item identifier
76+ * @param status Whether the purchase was successful
77+ */
5278 fun purchaseFinalized (placementId : String , catalogItemId : String , status : Boolean ) {
5379 if (isEnabled()) {
5480 resolveRoktKit()?.second?.purchaseFinalized(placementId, catalogItemId, status)
5581 }
5682 }
5783
84+ /* *
85+ * Close any active Rokt placements.
86+ */
5887 fun close () {
5988 if (isEnabled()) {
6089 resolveRoktKit()?.second?.close()
6190 }
6291 }
6392
93+ /* *
94+ * Set the session id to use for the next execute call.
95+ *
96+ * This is useful for cases where you have a session id from a non-native integration,
97+ * e.g. WebView, and you want the session to be consistent across integrations.
98+ *
99+ * **Note:** Empty strings are ignored and will not update the session.
100+ *
101+ * @param sessionId The session id to be set. Must be a non-empty string.
102+ */
64103 fun setSessionId (sessionId : String ) {
65104 if (isEnabled()) {
66105 resolveRoktKit()?.second?.setSessionId(sessionId)
67106 }
68107 }
69108
109+ /* *
110+ * Get the session id to use within a non-native integration e.g. WebView.
111+ *
112+ * @return The session id or null if no session is present or SDK is not initialized.
113+ */
70114 fun getSessionId (): String? = if (isEnabled()) {
71115 resolveRoktKit()?.second?.getSessionId()
72116 } else {
73117 null
74118 }
75119
76- fun prepareAttributesAsync (attributes : Map <String , String >) {
120+ /* *
121+ * Prepare attributes asynchronously before executing a placement.
122+ *
123+ * @param attributes The attributes to prepare
124+ */
125+ internal fun prepareAttributesAsync (attributes : Map <String , String >) {
77126 if (isEnabled()) {
78127 val resolved = resolveRoktKit()
79128 if (resolved != null ) {
0 commit comments