() {
diff --git a/fme-android/src/main/java/com/vwo/enums/EventEnum.kt b/fme-android/src/main/java/com/vwo/enums/EventEnum.kt
index b0a6583..a839428 100644
--- a/fme-android/src/main/java/com/vwo/enums/EventEnum.kt
+++ b/fme-android/src/main/java/com/vwo/enums/EventEnum.kt
@@ -30,5 +30,7 @@ enum class EventEnum(val value: String) {
/**
* Event triggered when a user attribute is set.
*/
- VWO_SYNC_VISITOR_PROP("vwo_syncVisitorProp")
+ VWO_SYNC_VISITOR_PROP("vwo_syncVisitorProp"),
+
+ VWO_RECOMMENDATION_SHOWN("vwo_recommendation_block_shown");
}
diff --git a/fme-android/src/main/java/com/vwo/enums/UrlEnum.kt b/fme-android/src/main/java/com/vwo/enums/UrlEnum.kt
index 55bec37..d2aab6f 100644
--- a/fme-android/src/main/java/com/vwo/enums/UrlEnum.kt
+++ b/fme-android/src/main/java/com/vwo/enums/UrlEnum.kt
@@ -33,5 +33,9 @@ enum class UrlEnum(val url: String) {
/**
* URL for retrieving user data.
*/
- GET_USER_DATA("/get-user-details")
+ GET_USER_DATA("/get-user-details"),
+
+ GENERATE_RECOMMENDATION("/internalcall/generate-recommendation"), // TODO -- Change this to actual URL
+
+ EVALUATE_DSL("/evaluate-event-dsl")
}
diff --git a/fme-android/src/main/java/com/vwo/enums/VariableTypeEnum.kt b/fme-android/src/main/java/com/vwo/enums/VariableTypeEnum.kt
new file mode 100644
index 0000000..0129cf8
--- /dev/null
+++ b/fme-android/src/main/java/com/vwo/enums/VariableTypeEnum.kt
@@ -0,0 +1,21 @@
+/**
+ * Copyright 2024 Wingify Software Pvt. Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.vwo.enums
+
+enum class VariableTypeEnum(val value: String) {
+ /** Recommendation type*/
+ RECOMMENDATION("recommendation")
+}
diff --git a/fme-android/src/main/java/com/vwo/interfaces/IVwoListener.java b/fme-android/src/main/java/com/vwo/interfaces/IVwoListener.java
new file mode 100644
index 0000000..dd0fde9
--- /dev/null
+++ b/fme-android/src/main/java/com/vwo/interfaces/IVwoListener.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2024 Wingify Software Pvt. Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.vwo.interfaces;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Callback interface to receive notifications about the operation in VWO.
+ */
+public interface IVwoListener {
+ /**
+ * Called when VWO action is successful.
+ * @param data Additional data
+ */
+ void onSuccess(Object data);
+
+ /**
+ * Called when VWO action is failed.
+ *
+ * Most common reason for failure is device unable to connect to Internet.
+ *
+ * @param message String message
+ */
+ void onFailure(@NotNull String message);
+}
\ No newline at end of file
diff --git a/fme-android/src/main/java/com/vwo/models/Campaign.kt b/fme-android/src/main/java/com/vwo/models/Campaign.kt
index f86afd0..7e82474 100644
--- a/fme-android/src/main/java/com/vwo/models/Campaign.kt
+++ b/fme-android/src/main/java/com/vwo/models/Campaign.kt
@@ -42,6 +42,11 @@ class Campaign {
@JsonProperty("segments")
var segments: Map? = null
+ @get:JsonProperty("segments_events")
+ @set:JsonProperty("segments_events")
+ @JsonProperty("segments_events")
+ var segments_events: List? = null
+
@JsonProperty("ruleKey")
var ruleKey: String? = null
@@ -94,6 +99,8 @@ class Campaign {
@JsonProperty("weight")
var weight: Double = 0.0
+ var isEventsDsl: Boolean = false
+
/**
* Sets the properties of this campaign from another campaign object.
*
@@ -153,6 +160,10 @@ class Campaign {
if (model.endRangeVariation != 0) {
this.endRangeVariation = model.endRangeVariation
}
+
+ if (model.segments_events != null) {
+ this.segments_events = model.segments_events
+ }
}
}
diff --git a/fme-android/src/main/java/com/vwo/models/Groups.kt b/fme-android/src/main/java/com/vwo/models/Groups.kt
index 164e648..0548261 100644
--- a/fme-android/src/main/java/com/vwo/models/Groups.kt
+++ b/fme-android/src/main/java/com/vwo/models/Groups.kt
@@ -18,6 +18,7 @@ package com.vwo.models
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonProperty
+
/**
* Represents a group of campaigns in VWO.
*
@@ -33,7 +34,7 @@ class Groups {
@get:JsonProperty("campaigns")
@set:JsonProperty("campaigns")
@JsonProperty("campaigns")
- var campaigns: List? = null
+ var campaigns: List? = null
// this is where algo, priority, weight go
@JsonProperty("et")
@@ -42,12 +43,12 @@ class Groups {
@get:JsonProperty("p")
@set:JsonProperty("p")
@JsonProperty("p")
- var p: List? = null
+ var p: MutableList? = ArrayList()
@get:JsonProperty("wt")
@set:JsonProperty("wt")
@JsonProperty("wt")
- var wt: Map? = null
+ var wt: Map? = mutableMapOf()
/**
* Sets the experiment type for the group.
diff --git a/fme-android/src/main/java/com/vwo/models/RecommendedProduct.kt b/fme-android/src/main/java/com/vwo/models/RecommendedProduct.kt
new file mode 100644
index 0000000..55967f1
--- /dev/null
+++ b/fme-android/src/main/java/com/vwo/models/RecommendedProduct.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2024 Wingify Software Pvt. Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vwo.models
+
+
+import com.google.gson.annotations.SerializedName
+import androidx.annotation.Keep
+
+@Keep
+data class RecommendedProduct(
+ @SerializedName("id")
+ val id: String = "",
+)
\ No newline at end of file
diff --git a/fme-android/src/main/java/com/vwo/models/Variable.kt b/fme-android/src/main/java/com/vwo/models/Variable.kt
index 6bd2242..1f160dc 100644
--- a/fme-android/src/main/java/com/vwo/models/Variable.kt
+++ b/fme-android/src/main/java/com/vwo/models/Variable.kt
@@ -36,4 +36,7 @@ class Variable {
@JsonProperty("id")
var id: Int? = null
+
+ @JsonProperty("displayConfiguration")
+ var displayConfiguration: Any? = null
}
diff --git a/fme-android/src/main/java/com/vwo/models/Variation.kt b/fme-android/src/main/java/com/vwo/models/Variation.kt
index 94036a7..99699cf 100644
--- a/fme-android/src/main/java/com/vwo/models/Variation.kt
+++ b/fme-android/src/main/java/com/vwo/models/Variation.kt
@@ -35,6 +35,12 @@ class Variation {
@JsonProperty("name")
var name: String? = null
+ @JsonProperty("ruleKey")
+ var ruleKey: String? = null
+
+ @JsonProperty("type")
+ var type: String? = null
+
@JsonProperty("weight")
var weight: Double = 0.0
@@ -52,4 +58,9 @@ class Variation {
@JsonProperty("segments")
var segments: Map = HashMap()
+
+ @get:JsonProperty("segments_events")
+ @set:JsonProperty("segments_events")
+ @JsonProperty("segments_events")
+ var segments_events: List? = null
}
diff --git a/fme-android/src/main/java/com/vwo/models/user/GetFlag.kt b/fme-android/src/main/java/com/vwo/models/user/GetFlag.kt
index 9fd1775..2e2a346 100644
--- a/fme-android/src/main/java/com/vwo/models/user/GetFlag.kt
+++ b/fme-android/src/main/java/com/vwo/models/user/GetFlag.kt
@@ -15,8 +15,11 @@
*/
package com.vwo.models.user
+import com.vwo.constants.Constants
import com.vwo.constants.Constants.defaultString
+import com.vwo.enums.VariableTypeEnum
import com.vwo.models.Variable
+import org.json.JSONObject
/**
* Represents a feature flag and its associated variables.
@@ -24,10 +27,17 @@ import com.vwo.models.Variable
* This class encapsulates information about a feature flag, including its enabled status and a
* list of variables with their values.
*/
-class GetFlag {
- var isEnabled: Boolean = false
+class GetFlag(val context: VWOContext) {
+ private var isEnabled: Boolean = false
+
private var variables: List = ArrayList()
+ fun isEnabled() = isEnabled
+
+ fun setIsEnabled(value: Boolean) {
+ isEnabled = value
+ }
+
/**
* Sets the variables for the feature flag.
*
@@ -50,11 +60,30 @@ class GetFlag {
fun getVariable(key: String?, defaultValue: Any): Any {
for (variable in variablesValue) {
if (variable.key.equals(key)) {
+ if (variable.type.equals(VariableTypeEnum.RECOMMENDATION.value,true)) {
+ // Return a Recommendation Object if type is RECOMMENDATION
+ val value = variable.value.toString().toIntOrNull()?:0
+ return Recommendation(value, context)
+ }
+
return variable.value?:defaultValue
}
}
return defaultValue
}
+
+ fun getRecommendationDisplayConfig(key: String?): Map? {
+ for (variable in variablesValue) {
+ if (variable.key.equals(key)) {
+ if (variable.type.equals(VariableTypeEnum.RECOMMENDATION.value, true)) {
+ // Return a Recommendation Object if type is RECOMMENDATION
+ return variable.displayConfiguration as? Map
+ }
+ }
+ }
+ return null
+ }
+
/**
* Retrieves the list of variables as a list of maps.
*
@@ -63,7 +92,10 @@ class GetFlag {
fun getVariables(): List