diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/managers/SearchManager.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/SearchManager.kt index 6b33718a..3d417842 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/managers/SearchManager.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/SearchManager.kt @@ -33,6 +33,7 @@ interface SearchManager { fun searchInstant( query: String, locations: String? = null, + excludedMerchants: List? = null, onSearchInstant: (SearchInstantResponse) -> Unit, onError: (Int, String?) -> Unit = { _: Int, _: String? -> } ) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/params/SearchParams.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/params/SearchParams.kt index a11a8701..915ae522 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/params/SearchParams.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/params/SearchParams.kt @@ -17,6 +17,7 @@ class SearchParams : AbstractParams() { SORT_BY("sort_by"), SORT_DIR("sort_dir"), LOCATIONS("locations"), + EXCLUDED_MERCHANTS("excluded_merchants"), BRANDS("brands"), FILTERS("filters"), PRICE_MIN("price_min"), diff --git a/personalization-sdk/src/main/kotlin/com/personalization/features/search/impl/SearchManagerImpl.kt b/personalization-sdk/src/main/kotlin/com/personalization/features/search/impl/SearchManagerImpl.kt index 6c0e6610..809c3851 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/features/search/impl/SearchManagerImpl.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/features/search/impl/SearchManagerImpl.kt @@ -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 @@ -40,12 +45,18 @@ internal class SearchManagerImpl @Inject constructor( override fun searchInstant( query: String, locations: String?, + excludedMerchants: List?, 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?) { @@ -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")