Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-support-all-profile-property-types
Browse files Browse the repository at this point in the history
  • Loading branch information
comfrt1k committed Dec 25, 2024
2 parents 52870c8 + 27f4dac commit b568bb8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion personalization-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id 'kotlin-kapt'
}

version='2.0.48'
version='2.0.49'

android {
compileSdkVersion 34
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface SearchManager {
fun searchInstant(
query: String,
locations: String? = null,
excludedMerchants: List<String>? = null,
onSearchInstant: (SearchInstantResponse) -> Unit,
onError: (Int, String?) -> Unit = { _: Int, _: String? -> }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SearchParams : AbstractParams<SearchParams>() {
SORT_BY("sort_by"),
SORT_DIR("sort_dir"),
LOCATIONS("locations"),
EXCLUDED_MERCHANTS("excluded_merchants"),
BRANDS("brands"),
FILTERS("filters"),
PRICE_MIN("price_min"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import com.personalization.api.responses.search.SearchBlankResponse
import com.personalization.api.responses.search.SearchFullResponse
import com.personalization.api.responses.search.SearchInstantResponse
import com.personalization.sdk.domain.usecases.network.SendNetworkMethodUseCase
import javax.inject.Inject
import org.json.JSONObject
import javax.inject.Inject

private const val SEARCH_REQUEST = "search"
private const val BLANK_SEARCH_REQUEST = "search/blank"
private const val TYPE_PARAMETER = "type"
private const val QUERY_PARAMETER = "search_query"

internal class SearchManagerImpl @Inject constructor(
private val sendNetworkMethodUseCase: SendNetworkMethodUseCase
Expand Down Expand Up @@ -40,12 +45,18 @@ internal class SearchManagerImpl @Inject constructor(
override fun searchInstant(
query: String,
locations: String?,
excludedMerchants: List<String>?,
onSearchInstant: (SearchInstantResponse) -> Unit,
onError: (Int, String?) -> Unit
) {
val searchParams = SearchParams()

if (locations != null) searchParams.put(LOCATIONS_PARAMETER, locations)
locations?.let {
searchParams.put(SearchParams.Parameter.LOCATIONS, locations)
excludedMerchants?.let {
val excludeMerchantsString = excludedMerchants.joinToString(",")
searchParams.put(SearchParams.Parameter.EXCLUDED_MERCHANTS, excludeMerchantsString)
}
}

search(query, TYPE.INSTANT, searchParams, object : OnApiCallbackListener() {
override fun onSuccess(response: JSONObject?) {
Expand Down Expand Up @@ -97,15 +108,6 @@ internal class SearchManagerImpl @Inject constructor(
sendNetworkMethodUseCase.get(SEARCH_REQUEST, params.build(), listener)
}

companion object {
private const val SEARCH_REQUEST = "search"
private const val BLANK_SEARCH_REQUEST = "search/blank"

private const val TYPE_PARAMETER = "type"
private const val QUERY_PARAMETER = "search_query"
private const val LOCATIONS_PARAMETER = "locations"
}

private enum class TYPE(var value: String) {
INSTANT("instant_search"),
FULL("full_search")
Expand Down

0 comments on commit b568bb8

Please sign in to comment.