Created
November 12, 2024 19:07
-
-
Save jordanbeck/6accd9d93d976ead994f5c839983f5a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Etsy/src/main/java/com/etsy/android/ui/listing/ui/recommendations/RecommendationsRepository.kt b/Etsy/src/main/java/com/etsy/android/ui/listing/ui/recommendations/RecommendationsRepository.kt | |
| index e4400970cac..41dc31de124 100644 | |
| --- a/Etsy/src/main/java/com/etsy/android/ui/listing/ui/recommendations/RecommendationsRepository.kt | |
| +++ b/Etsy/src/main/java/com/etsy/android/ui/listing/ui/recommendations/RecommendationsRepository.kt | |
| @@ -2,6 +2,7 @@ package com.etsy.android.ui.listing.ui.recommendations | |
| import com.etsy.android.extensions.Exceptions.Companion.suspendRunCatchingRepository | |
| import com.etsy.android.lib.dagger.IODispatcher | |
| +import com.etsy.android.lib.logger.EtsyLogConstants | |
| import com.etsy.android.lib.models.apiv3.sdl.Page | |
| import com.etsy.android.lib.network.response.RepositoryResult | |
| import com.etsy.android.lib.network.response.fold | |
| @@ -42,6 +43,8 @@ class RecommendationsRepository @Inject constructor( | |
| shouldRemoveFavoriteIcon = spec.shouldRemoveFavoriteIcon, | |
| isNotActiveListing = spec.isShowingNotActiveListing, | |
| headerMap = spec.urlUtmParams ?: emptyMap(), | |
| + prolistQuery = spec.prolistQuery, | |
| + referringScreen = spec.getCleanReferringScreen() | |
| ) | |
| if (response.isSuccessful && response.body() != null && response.body() is Page) { | |
| RecommendedListingsFetchResult.Success(response.body() as Page) | |
| @@ -89,7 +92,23 @@ data class RecommendedListingsSpec( | |
| val includeSimilarItemsModule: Boolean? = false, // the API implementation for this param seems to be confusing. The module gets excluded if includeSimilarItemsModule == true. So the default for this is "false" to fetch the module at all times. | |
| val urlUtmParams: Map<String, String>? = null, // Marketing query params | |
| val isShowingNotActiveListing: Boolean? = false, // Without this API param, recs won't load for listings that are sold out or otherwise unavailable | |
| -) | |
| + val prolistQuery: String? = null, | |
| + val referringScreen: String? = null, | |
| +) { | |
| + /** | |
| + * We need to pass a slightly modified referring screen value for the recommendations module. The helper function looks | |
| + * for specific referring screens and then passes back a supported value. This is to be used with the recommendations | |
| + * endpoints. | |
| + * | |
| + * See the supported values at | |
| + * https://github.etsycorp.com/Engineering/Etsyweb/blob/main/phplib/DataType/SDL/LandingPage/Referrer.php | |
| + */ | |
| + fun getCleanReferringScreen(): String? { | |
| + return if (referringScreen?.contains(EtsyLogConstants.PageInViews.SEARCH_RESULTS) == true) { | |
| + "search-results" | |
| + } else referringScreen | |
| + } | |
| +} | |
| data class RecommendationsGeneratorSpec( | |
| val listingId: Long, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment