Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/exclude merchants from search #89

Merged
merged 3 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
looee1q marked this conversation as resolved.
Show resolved Hide resolved
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,8 @@ 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

internal class SearchManagerImpl @Inject constructor(
private val sendNetworkMethodUseCase: SendNetworkMethodUseCase
Expand Down Expand Up @@ -40,12 +40,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(LOCATIONS_PARAMETER, locations)
excludedMerchants?.let {
val excludeMerchantsString = excludedMerchants.joinToString(",")
searchParams.put(EXCLUDED_MERCHANTS_PARAMETER,excludeMerchantsString)
}
}

search(query, TYPE.INSTANT, searchParams, object : OnApiCallbackListener() {
override fun onSuccess(response: JSONObject?) {
Expand Down Expand Up @@ -104,6 +110,7 @@ internal class SearchManagerImpl @Inject constructor(
private const val TYPE_PARAMETER = "type"
private const val QUERY_PARAMETER = "search_query"
private const val LOCATIONS_PARAMETER = "locations"
private const val EXCLUDED_MERCHANTS_PARAMETER = "excluded_merchants"
looee1q marked this conversation as resolved.
Show resolved Hide resolved
looee1q marked this conversation as resolved.
Show resolved Hide resolved
}

private enum class TYPE(var value: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.personalization.sdk.data.repositories.network

import android.net.Uri
import android.util.Log
looee1q marked this conversation as resolved.
Show resolved Hide resolved
import com.personalization.SDK
import com.personalization.api.OnApiCallbackListener
import com.personalization.sdk.data.di.DataSourcesModule
Expand Down
Loading