Skip to content

Commit

Permalink
Merge pull request #14 from bloomreach/dev
Browse files Browse the repository at this point in the history
Dev > main v1.0.11
  • Loading branch information
prashant-br authored Jan 16, 2024
2 parents 7fe7e27 + f368d14 commit ec85461
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdk 24
targetSdk 32
versionCode 1
versionName "1.0.9"
versionName "1.0.11"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
package com.bloomreach.discovery.api.model.core

import com.bloomreach.discovery.api.model.BaseResponse
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonProperty

data class Facet(
@JsonProperty("name")
var name: String? = null,
@JsonProperty("type")
var type: String? = null,
@JsonFormat(with = [JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY])
@JsonProperty("value")
var value: FacetValue? = null
var value: List<FacetValue>? = null
): BaseResponse()
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@ import com.bloomreach.discovery.api.model.BaseResponse
import com.fasterxml.jackson.annotation.JsonProperty

data class FacetCounts(

@Deprecated("Customers whose go-live date is after September 7, 2023 will be on V3 Facet response format by default. " +
"If you’re on the legacy format and would like to implement the new Facet response format, kindly contact your Bloomreach Services representative.")
@JsonProperty("facet_fields")
val facetFields: LinkedHashMap<String, List<FacetFields>>? = null,

@Deprecated("Customers whose go-live date is after September 7, 2023 will be on V3 Facet response format by default. " +
"If you’re on the legacy format and would like to implement the new Facet response format, kindly contact your Bloomreach Services representative.")
@JsonProperty("facet_queries")
val facetQueries: LinkedHashMap<String, Int>? = null,

@Deprecated("Customers whose go-live date is after September 7, 2023 will be on V3 Facet response format by default. " +
"If you’re on the legacy format and would like to implement the new Facet response format, kindly contact your Bloomreach Services representative.")
@JsonProperty("facet_ranges")
val facetRanges: LinkedHashMap<String, List<FacetRange>>? = null,

//facet v3
@JsonProperty("facets")
val facets: List<Facet>? = null
) : BaseResponse()
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright 2024 Bloomreach
*/

package com.bloomreach.discovery.api.model.core

import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.annotation.JsonDeserialize

@JsonDeserialize(using = JsonDeserializer.None::class)
class FacetField : FacetValue() {
val name: String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package com.bloomreach.discovery.api.model.core
import com.bloomreach.discovery.api.model.BaseResponse
import com.fasterxml.jackson.annotation.JsonProperty

@Deprecated("Customers whose go-live date is after September 7, 2023 will be on V3 Facet response format by default. " +
"If you’re on the legacy format and would like to implement the new Facet response format, kindly contact your Bloomreach Services representative.")
class FacetFields : BaseResponse() {
val name: String? = null

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2024 Bloomreach
*/

package com.bloomreach.discovery.api.model.core

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.annotation.JsonDeserialize

@JsonDeserialize(using = JsonDeserializer.None::class)
data class FacetFieldsCategory(
@JsonProperty("cat_id")
val catId: String? = null,

@JsonProperty("cat_name")
val catName: String? = null,

@JsonProperty("crumb")
val crumb: String? = null,

@JsonProperty("tree_path")
val treePath: String? = null,

@JsonProperty("parent")
val parent: String? = null,
) : FacetValue()
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package com.bloomreach.discovery.api.model.core

import com.bloomreach.discovery.api.model.BaseResponse

@Deprecated("Customers whose go-live date is after September 7, 2023 will be on V3 Facet response format by default. " +
"If you’re on the legacy format and would like to implement the new Facet response format, kindly contact your Bloomreach Services representative.")
data class FacetRange(
val start: Any? = null,
val end: Any? = null,
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/bloomreach/discovery/api/model/core/FacetRnge.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2024 Bloomreach
*/

package com.bloomreach.discovery.api.model.core

import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.annotation.JsonDeserialize

@JsonDeserialize(using = JsonDeserializer.None::class)
data class FacetRnge(
val start: Any? = null,
val end: Any? = null,
) : FacetValue()
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,9 @@ package com.bloomreach.discovery.api.model.core

import com.bloomreach.discovery.api.model.BaseResponse
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize

class FacetValue : BaseResponse() {

@JsonProperty("cat_id")
val catId: String? = null

@JsonProperty("cat_name")
val catName: String? = null

@JsonProperty("crumb")
val crumb: String? = null

@JsonProperty("tree_path")
val treePath: String? = null

@JsonProperty("parent")
val parent: String? = null

val start: Any? = null
val end: Any? = null
@JsonDeserialize(using = FacetValueDeserializer::class)
open class FacetValue : BaseResponse() {
val count: Int? = null
val name: String? = null

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 Bloomreach
*/

package com.bloomreach.discovery.api.model.core
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
import com.fasterxml.jackson.databind.node.ObjectNode
import java.io.IOException

class FacetValueDeserializer : StdDeserializer<FacetValue?>(FacetValue::class.java) {
@Throws(IOException::class, JsonProcessingException::class)
override fun deserialize(jsonParser: JsonParser, deserializationContext: DeserializationContext): FacetValue {
val mapper = jsonParser.codec as ObjectMapper
val root = mapper.readTree<ObjectNode>(jsonParser)
// Determine the type based on existence of certain fields
val type: Class<*> = when {
root.has("start") -> {
FacetRnge::class.java
}
root.has("cat_id") -> {
FacetFieldsCategory::class.java
}
else -> {
FacetField::class.java
}
}
return mapper.treeToValue(root, type) as FacetValue
}
}
36 changes: 36 additions & 0 deletions src/main/java/com/bloomreach/discovery/pixel/PixelTracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ object PixelTracker {
* @param searchTerm The value of the search query describing the page.
* @param catalogs List of CatalogItem that are shown in the page.
*/
@Deprecated("This method will be removed in future version. Instead use searchEventPixel(ref, title, searchTerm, catalogs)")
fun searchEventPixel(
ref: String,
title: String,
Expand Down Expand Up @@ -353,6 +354,41 @@ object PixelTracker {
}
}


/**
* Method for sending the Search Event Pixel
* @param ref Synthetic URL from referrer screen
* @param title Screen name of the app view.
* @param searchTerm The value of the search query describing the page.
* @param catalogs List of CatalogItem that are shown in the page.
*/
fun searchEventPixel(
ref: String,
title: String,
searchTerm: String,
catalogs: List<CatalogItem>? = null
) {
if (this::brPixel.isInitialized) {

// create pixel object based ob input
val pixelObject = PixelObject(
type = PixelType.EVENT,
pType = PageType.PRODUCT_PAGE,
group = GroupType.SUGGEST,
eType = "submit",
ref = ref,
title = title,
searchTerm = searchTerm,
catalogs = catalogs
)

// send pixel for further processing
pixelProcessor.processPixel(pixelObject)
} else {
Log.e(TAG, "Pixel Tracker not initialised")
}
}

/**
* Method for sending the Suggestion Event Pixel
* @param ref Synthetic URL from referrer screen
Expand Down

0 comments on commit ec85461

Please sign in to comment.