From 625c79d9239b9a07787a23ec5c352803636b375c Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Thu, 3 Oct 2024 14:23:36 +0200 Subject: [PATCH 01/10] feat: Added product catalog manager and impl --- .../api/managers/CatalogManager.kt | 14 +++++++++++++ .../features/catalog/CatalogManagerImpl.kt | 21 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/managers/CatalogManager.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/features/catalog/CatalogManagerImpl.kt diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/managers/CatalogManager.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/CatalogManager.kt new file mode 100644 index 00000000..c740981c --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/CatalogManager.kt @@ -0,0 +1,14 @@ +package com.personalization.api.managers + +interface CatalogManager { + + fun getProductsList( + brands: String?, + merchants: String?, + categories: String?, + locations: String?, + limit: Int?, + page: Int?, + filters: Map? + ) +} diff --git a/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/CatalogManagerImpl.kt b/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/CatalogManagerImpl.kt new file mode 100644 index 00000000..fb3b498c --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/CatalogManagerImpl.kt @@ -0,0 +1,21 @@ +package com.personalization.features.catalog + +import com.personalization.api.managers.CatalogManager +import javax.inject.Inject + +internal class CatalogManagerImpl @Inject constructor( + +) : CatalogManager { + + override fun getProductsList( + brands: String?, + merchants: String?, + categories: String?, + locations: String?, + limit: Int?, + page: Int?, + filters: Map? + ) { + TODO("Not yet implemented") + } +} From 1ddd1c7e83ca4652120c19fde7f16562964a14f8 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 30 Oct 2024 11:51:08 +0200 Subject: [PATCH 02/10] feat: Added repository and use case --- .../api/managers/{CatalogManager.kt => ProductsManager.kt} | 2 +- .../{CatalogManagerImpl.kt => ProductsManagerImpl.kt} | 6 +++--- .../sdk/domain/repositories/ProductsRepository.kt | 7 +++++++ .../sdk/domain/usecases/products/GetProductsUseCase.kt | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) rename personalization-sdk/src/main/kotlin/com/personalization/api/managers/{CatalogManager.kt => ProductsManager.kt} (90%) rename personalization-sdk/src/main/kotlin/com/personalization/features/catalog/{CatalogManagerImpl.kt => ProductsManagerImpl.kt} (72%) create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/managers/CatalogManager.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/ProductsManager.kt similarity index 90% rename from personalization-sdk/src/main/kotlin/com/personalization/api/managers/CatalogManager.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/managers/ProductsManager.kt index c740981c..aa495118 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/managers/CatalogManager.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/ProductsManager.kt @@ -1,6 +1,6 @@ package com.personalization.api.managers -interface CatalogManager { +interface ProductsManager { fun getProductsList( brands: String?, diff --git a/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/CatalogManagerImpl.kt b/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/ProductsManagerImpl.kt similarity index 72% rename from personalization-sdk/src/main/kotlin/com/personalization/features/catalog/CatalogManagerImpl.kt rename to personalization-sdk/src/main/kotlin/com/personalization/features/catalog/ProductsManagerImpl.kt index fb3b498c..5181daea 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/CatalogManagerImpl.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/ProductsManagerImpl.kt @@ -1,11 +1,11 @@ package com.personalization.features.catalog -import com.personalization.api.managers.CatalogManager +import com.personalization.api.managers.ProductsManager import javax.inject.Inject -internal class CatalogManagerImpl @Inject constructor( +internal class ProductsManagerImpl @Inject constructor( -) : CatalogManager { +) : ProductsManager { override fun getProductsList( brands: String?, diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt new file mode 100644 index 00000000..13af7219 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt @@ -0,0 +1,7 @@ +package com.personalization.sdk.domain.repositories + +interface ProductsRepository { + + fun getProductsList() + +} diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt new file mode 100644 index 00000000..9ce57226 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt @@ -0,0 +1,4 @@ +package com.personalization.sdk.domain.usecases.products + +class GetProductsUseCase { +} \ No newline at end of file From c99ec66a410e2c18c4b022883dad127c86b3aa41 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 30 Oct 2024 15:41:11 +0200 Subject: [PATCH 03/10] feat: Added network repository with getter method --- .../personalization/api/managers/ProductsManager.kt | 5 ++++- .../{catalog => products/impl}/ProductsManagerImpl.kt | 9 ++++++--- .../sdk/domain/repositories/ProductsRepository.kt | 10 +++++++++- .../sdk/domain/usecases/products/GetProductsUseCase.kt | 10 ++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) rename personalization-sdk/src/main/kotlin/com/personalization/features/{catalog => products/impl}/ProductsManagerImpl.kt (56%) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/managers/ProductsManager.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/ProductsManager.kt index aa495118..7c428415 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/managers/ProductsManager.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/managers/ProductsManager.kt @@ -1,5 +1,7 @@ package com.personalization.api.managers +import com.personalization.api.OnApiCallbackListener + interface ProductsManager { fun getProductsList( @@ -9,6 +11,7 @@ interface ProductsManager { locations: String?, limit: Int?, page: Int?, - filters: Map? + filters: Map?, + listener: OnApiCallbackListener? = null ) } diff --git a/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/ProductsManagerImpl.kt b/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt similarity index 56% rename from personalization-sdk/src/main/kotlin/com/personalization/features/catalog/ProductsManagerImpl.kt rename to personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt index 5181daea..9cba74a3 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/features/catalog/ProductsManagerImpl.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt @@ -1,10 +1,12 @@ -package com.personalization.features.catalog +package com.personalization.features.products.impl +import com.personalization.api.OnApiCallbackListener import com.personalization.api.managers.ProductsManager +import com.personalization.sdk.domain.usecases.products.GetProductsUseCase import javax.inject.Inject internal class ProductsManagerImpl @Inject constructor( - + val getProductsUseCase: GetProductsUseCase ) : ProductsManager { override fun getProductsList( @@ -14,7 +16,8 @@ internal class ProductsManagerImpl @Inject constructor( locations: String?, limit: Int?, page: Int?, - filters: Map? + filters: Map?, + listener: OnApiCallbackListener? ) { TODO("Not yet implemented") } diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt index 13af7219..e1071cf8 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt @@ -2,6 +2,14 @@ package com.personalization.sdk.domain.repositories interface ProductsRepository { - fun getProductsList() + fun getProductsList( + brands: String?, + merchants: String?, + categories: String?, + locations: String?, + limit: Int?, + page: Int?, + filters: Map? + ) } diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt index 9ce57226..5bc858f2 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt @@ -1,4 +1,10 @@ package com.personalization.sdk.domain.usecases.products -class GetProductsUseCase { -} \ No newline at end of file +import com.personalization.sdk.domain.repositories.NetworkRepository +import javax.inject.Inject + +class GetProductsUseCase @Inject constructor( + private val networkRepository: NetworkRepository +) { + +} From aa35d068a2834545ca6fbbc19eb914568b8a78e3 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 30 Oct 2024 15:45:12 +0200 Subject: [PATCH 04/10] feat: Added binding impl class --- .../com/personalization/sdk/data/di/RepositoriesModule.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt index d8720528..64f26265 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt @@ -33,4 +33,7 @@ abstract class RepositoriesModule { @Binds abstract fun bindNotificationRepository(impl: NotificationRepositoryImpl): NotificationRepository + + @Binds + abstract fun bindProductsRepository(impl: PreferencesRepositoryImpl): PreferencesRepository } From 3781367caf00c620e15529c27eb25851f0c9cbca Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 30 Oct 2024 16:06:37 +0200 Subject: [PATCH 05/10] feat: Added providing manager with injecting dependencies --- .../com/personalization/di/SdkModule.kt | 10 ++++ .../products/impl/ProductsManagerImpl.kt | 4 +- .../impl/RecommendationManagerImpl.kt | 52 ++++++++++++------- .../sdk/data/di/RepositoriesModule.kt | 4 +- 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/di/SdkModule.kt b/personalization-sdk/src/main/kotlin/com/personalization/di/SdkModule.kt index e9cce6c5..1ae1df92 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/di/SdkModule.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/di/SdkModule.kt @@ -2,10 +2,12 @@ package com.personalization.di import com.personalization.RegisterManager import com.personalization.api.managers.InAppNotificationManager +import com.personalization.api.managers.ProductsManager import com.personalization.api.managers.RecommendationManager import com.personalization.api.managers.SearchManager import com.personalization.api.managers.TrackEventManager import com.personalization.features.inAppNotification.impl.InAppNotificationManagerImpl +import com.personalization.features.products.impl.ProductsManagerImpl import com.personalization.features.recommendation.impl.RecommendationManagerImpl import com.personalization.features.search.impl.SearchManagerImpl import com.personalization.features.trackEvent.impl.TrackEventManagerImpl @@ -51,6 +53,14 @@ class SdkModule { sendNetworkMethodUseCase = sendNetworkMethodUseCase ) + @Singleton + @Provides + fun provideProductsManager( + sendNetworkMethodUseCase: SendNetworkMethodUseCase + ): ProductsManager = ProductsManagerImpl( + sendNetworkMethodUseCase = sendNetworkMethodUseCase + ) + @Singleton @Provides fun provideTrackEventManager( diff --git a/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt b/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt index 9cba74a3..acb6c7fe 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt @@ -2,11 +2,11 @@ package com.personalization.features.products.impl import com.personalization.api.OnApiCallbackListener import com.personalization.api.managers.ProductsManager -import com.personalization.sdk.domain.usecases.products.GetProductsUseCase +import com.personalization.sdk.domain.usecases.network.SendNetworkMethodUseCase import javax.inject.Inject internal class ProductsManagerImpl @Inject constructor( - val getProductsUseCase: GetProductsUseCase + private val sendNetworkMethodUseCase: SendNetworkMethodUseCase ) : ProductsManager { override fun getProductsList( diff --git a/personalization-sdk/src/main/kotlin/com/personalization/features/recommendation/impl/RecommendationManagerImpl.kt b/personalization-sdk/src/main/kotlin/com/personalization/features/recommendation/impl/RecommendationManagerImpl.kt index 03d15817..1a9c2540 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/features/recommendation/impl/RecommendationManagerImpl.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/features/recommendation/impl/RecommendationManagerImpl.kt @@ -4,11 +4,11 @@ import com.google.gson.Gson import com.personalization.Params import com.personalization.api.OnApiCallbackListener import com.personalization.api.managers.RecommendationManager -import com.personalization.api.responses.recommendation.GetRecommendationResponse import com.personalization.api.responses.recommendation.GetExtendedRecommendationResponse +import com.personalization.api.responses.recommendation.GetRecommendationResponse import com.personalization.sdk.domain.usecases.network.SendNetworkMethodUseCase -import org.json.JSONObject import javax.inject.Inject +import org.json.JSONObject internal class RecommendationManagerImpl @Inject constructor( private val sendNetworkMethodUseCase: SendNetworkMethodUseCase @@ -22,18 +22,23 @@ internal class RecommendationManagerImpl @Inject constructor( ) { params.put(EXTENDED_PARAMETER, false) - getRecommendation(recommenderCode, params, object : OnApiCallbackListener() { - override fun onSuccess(response: JSONObject?) { - response?.let { - val getRecommendationResponse = Gson().fromJson(it.toString(), GetRecommendationResponse::class.java) - onGetRecommendation(getRecommendationResponse) + getRecommendation( + recommenderCode = recommenderCode, + params = params, + listener = object : OnApiCallbackListener() { + override fun onSuccess(response: JSONObject?) { + response?.let { + val getRecommendationResponse = + Gson().fromJson(it.toString(), GetRecommendationResponse::class.java) + onGetRecommendation(getRecommendationResponse) + } } - } - override fun onError(code: Int, msg: String?) { - onError(code, msg) + override fun onError(code: Int, msg: String?) { + onError(code, msg) + } } - }) + ) } override fun getExtendedRecommendation( @@ -44,18 +49,25 @@ internal class RecommendationManagerImpl @Inject constructor( ) { params.put(EXTENDED_PARAMETER, true) - getRecommendation(recommenderCode, params, object : OnApiCallbackListener() { - override fun onSuccess(response: JSONObject?) { - response?.let { - val getExtendedRecommendationResponse = Gson().fromJson(it.toString(), GetExtendedRecommendationResponse::class.java) - onGetExtendedRecommendation.invoke(getExtendedRecommendationResponse) + getRecommendation( + recommenderCode = recommenderCode, + params = params, + listener = object : OnApiCallbackListener() { + override fun onSuccess(response: JSONObject?) { + response?.let { + val getExtendedRecommendationResponse = Gson().fromJson( + it.toString(), + GetExtendedRecommendationResponse::class.java + ) + onGetExtendedRecommendation.invoke(getExtendedRecommendationResponse) + } } - } - override fun onError(code: Int, msg: String?) { - onError(code, msg) + override fun onError(code: Int, msg: String?) { + onError(code, msg) + } } - }) + ) } override fun getRecommendation(recommenderCode: String, params: Params, listener: OnApiCallbackListener) { diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt index 64f26265..ca89cda9 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt @@ -34,6 +34,6 @@ abstract class RepositoriesModule { @Binds abstract fun bindNotificationRepository(impl: NotificationRepositoryImpl): NotificationRepository - @Binds - abstract fun bindProductsRepository(impl: PreferencesRepositoryImpl): PreferencesRepository +// @Binds +// abstract fun bindProductsRepository(impl: PreferencesRepositoryImpl): PreferencesRepository } From e6fa1fdf21621b30fb15847beb5380f235c4c916 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 30 Oct 2024 16:17:44 +0200 Subject: [PATCH 06/10] feat: Added response model with items --- .../sdk/domain/models/products/ApiResponse.kt | 12 ++++ .../sdk/domain/models/products/Brand.kt | 59 +++++++++++++++++++ .../domain/models/products/PriceRangeItem.kt | 6 ++ .../sdk/domain/models/products/Product.kt | 28 +++++++++ .../usecases/products/GetProductsUseCase.kt | 10 ---- 5 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt new file mode 100644 index 00000000..fa4ac849 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt @@ -0,0 +1,12 @@ +package com.personalization.sdk.domain.models.products + +data class ApiResponse( + val brands: List, + val categories: List, + val filters: List, + val priceRange: PriceRange, + val products: List, + val productsTotal: Int, + val priceRanges: List, + val priceMedian: Double +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt new file mode 100644 index 00000000..60a7e109 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt @@ -0,0 +1,59 @@ +package com.personalization.sdk.domain.models.products + +data class Brand( + val name: String, + val picture: String, + val count: Int +) + +data class Category( + val id: String, + val name: String, + val url: String, + val urlHandle: String, + val count: Int, + val parent: String?, + val alias: String? +) + +data class FilterValue( + val value: String, + val count: Int +) + +data class Filter( + val filter: FilterDetails +) + +data class FilterDetails( + val count: Int, + val priority: Int, + val ranges: List?, + val values: List +) + +data class PriceRange( + val min: Double, + val max: Double +) + +data class ProductCategory( + val id: String, + val name: String, + val parent: String?, + val params: List +) + +data class ProductParam( + val key: String, + val values: List +) + +data class ImageUrlResized( + val sizeToPath: Map +) + + + + + diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt new file mode 100644 index 00000000..f0b88cad --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt @@ -0,0 +1,6 @@ +package com.personalization.sdk.domain.models.products + +data class PriceRangeItem( + val to: Double, + val count: Int +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt new file mode 100644 index 00000000..823f389a --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt @@ -0,0 +1,28 @@ +package com.personalization.sdk.domain.models.products + +data class Product( + val brand: String, + val currency: String, + val id: String, + val isNew: Boolean? = null, + val name: String, + val oldPrice: String = "0", + val price: Double, + val priceFormatted: String, + val priceFullFormatted: String, + val picture: String, + val url: String, + val description: String, + val categoryIds: List, + val fashionFeature: String?, + val fashionGender: String?, + val salesRate: Int, + val relativeSalesRate: Int, + val imageUrl: String, + val imageUrlHandle: String, + val imageUrlResized: ImageUrlResized, + val internalId: String, + val groupId: String, + val barcode: String, + val categories: List +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt deleted file mode 100644 index 5bc858f2..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/usecases/products/GetProductsUseCase.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.personalization.sdk.domain.usecases.products - -import com.personalization.sdk.domain.repositories.NetworkRepository -import javax.inject.Inject - -class GetProductsUseCase @Inject constructor( - private val networkRepository: NetworkRepository -) { - -} From 755baa46058733b3405bcfb8e5c5783fcbac3b21 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 30 Oct 2024 16:18:50 +0200 Subject: [PATCH 07/10] feat: Added brands and filter models --- .../sdk/domain/models/products/Brand.kt | 52 ------------------- .../sdk/domain/models/products/Category.kt | 11 ++++ .../sdk/domain/models/products/Filter.kt | 5 ++ .../domain/models/products/FilterDetails.kt | 8 +++ .../sdk/domain/models/products/FilterValue.kt | 6 +++ .../domain/models/products/ImageUrlResized.kt | 5 ++ .../sdk/domain/models/products/PriceRange.kt | 6 +++ .../domain/models/products/ProductCategory.kt | 8 +++ .../domain/models/products/ProductParam.kt | 6 +++ 9 files changed, 55 insertions(+), 52 deletions(-) create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ImageUrlResized.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductCategory.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductParam.kt diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt index 60a7e109..38b680cd 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt @@ -5,55 +5,3 @@ data class Brand( val picture: String, val count: Int ) - -data class Category( - val id: String, - val name: String, - val url: String, - val urlHandle: String, - val count: Int, - val parent: String?, - val alias: String? -) - -data class FilterValue( - val value: String, - val count: Int -) - -data class Filter( - val filter: FilterDetails -) - -data class FilterDetails( - val count: Int, - val priority: Int, - val ranges: List?, - val values: List -) - -data class PriceRange( - val min: Double, - val max: Double -) - -data class ProductCategory( - val id: String, - val name: String, - val parent: String?, - val params: List -) - -data class ProductParam( - val key: String, - val values: List -) - -data class ImageUrlResized( - val sizeToPath: Map -) - - - - - diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt new file mode 100644 index 00000000..d515e27b --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt @@ -0,0 +1,11 @@ +package com.personalization.sdk.domain.models.products + +data class Category( + val id: String, + val name: String, + val url: String, + val urlHandle: String, + val count: Int, + val parent: String?, + val alias: String? +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt new file mode 100644 index 00000000..5d03f125 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt @@ -0,0 +1,5 @@ +package com.personalization.sdk.domain.models.products + +data class Filter( + val filter: FilterDetails +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt new file mode 100644 index 00000000..5ebd9934 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt @@ -0,0 +1,8 @@ +package com.personalization.sdk.domain.models.products + +data class FilterDetails( + val count: Int, + val priority: Int, + val ranges: List?, + val values: List +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt new file mode 100644 index 00000000..ade7f007 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt @@ -0,0 +1,6 @@ +package com.personalization.sdk.domain.models.products + +data class FilterValue( + val value: String, + val count: Int +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ImageUrlResized.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ImageUrlResized.kt new file mode 100644 index 00000000..739b04d0 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ImageUrlResized.kt @@ -0,0 +1,5 @@ +package com.personalization.sdk.domain.models.products + +data class ImageUrlResized( + val sizeToPath: Map +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt new file mode 100644 index 00000000..6902a874 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt @@ -0,0 +1,6 @@ +package com.personalization.sdk.domain.models.products + +data class PriceRange( + val min: Double, + val max: Double +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductCategory.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductCategory.kt new file mode 100644 index 00000000..8fc54780 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductCategory.kt @@ -0,0 +1,8 @@ +package com.personalization.sdk.domain.models.products + +data class ProductCategory( + val id: String, + val name: String, + val parent: String?, + val params: List +) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductParam.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductParam.kt new file mode 100644 index 00000000..92a3b6ef --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductParam.kt @@ -0,0 +1,6 @@ +package com.personalization.sdk.domain.models.products + +data class ProductParam( + val key: String, + val values: List +) \ No newline at end of file From 61346e7b4cbd65ad915d7a3af959f14110347531 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Thu, 31 Oct 2024 13:03:27 +0200 Subject: [PATCH 08/10] feat: Added request with handling response --- .../main/kotlin/com/personalization/SDK.kt | 4 ++ .../api/responses/products/Brand.kt | 12 ++++ .../api/responses/products/Category.kt | 20 +++++++ .../api/responses/products/Filter.kt | 8 +++ .../api/responses/products/FilterDetails.kt | 14 +++++ .../api/responses/products/FilterValue.kt | 10 ++++ .../responses}/products/ImageUrlResized.kt | 4 +- .../api/responses/products/PriceRange.kt | 10 ++++ .../api/responses/products/PriceRangeItem.kt | 10 ++++ .../api/responses/products/Product.kt | 55 +++++++++++++++++++ .../responses}/products/ProductCategory.kt | 2 +- .../responses}/products/ProductParam.kt | 2 +- .../responses/products/ProductsResponse.kt | 22 ++++++++ .../products/impl/ProductsManagerImpl.kt | 52 +++++++++++++++++- .../sdk/data/di/RepositoriesModule.kt | 2 - .../sdk/domain/models/products/ApiResponse.kt | 12 ---- .../sdk/domain/models/products/Brand.kt | 7 --- .../sdk/domain/models/products/Category.kt | 11 ---- .../sdk/domain/models/products/Filter.kt | 5 -- .../domain/models/products/FilterDetails.kt | 8 --- .../sdk/domain/models/products/FilterValue.kt | 6 -- .../sdk/domain/models/products/PriceRange.kt | 6 -- .../domain/models/products/PriceRangeItem.kt | 6 -- .../sdk/domain/models/products/Product.kt | 28 ---------- 24 files changed, 219 insertions(+), 97 deletions(-) create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Brand.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Category.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Filter.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterDetails.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterValue.kt rename personalization-sdk/src/main/kotlin/com/personalization/{sdk/domain/models => api/responses}/products/ImageUrlResized.kt (55%) create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRange.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRangeItem.kt create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Product.kt rename personalization-sdk/src/main/kotlin/com/personalization/{sdk/domain/models => api/responses}/products/ProductCategory.kt (70%) rename personalization-sdk/src/main/kotlin/com/personalization/{sdk/domain/models => api/responses}/products/ProductParam.kt (58%) create mode 100644 personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductsResponse.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt diff --git a/personalization-sdk/src/main/kotlin/com/personalization/SDK.kt b/personalization-sdk/src/main/kotlin/com/personalization/SDK.kt index 065fc9dc..d2507d12 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/SDK.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/SDK.kt @@ -10,6 +10,7 @@ import com.personalization.Params.InternalParameter import com.personalization.Params.TrackEvent import com.personalization.api.OnApiCallbackListener import com.personalization.api.managers.InAppNotificationManager +import com.personalization.api.managers.ProductsManager import com.personalization.api.managers.RecommendationManager import com.personalization.api.managers.SearchManager import com.personalization.api.managers.TrackEventManager @@ -53,6 +54,9 @@ open class SDK { @Inject lateinit var recommendationManager: RecommendationManager + @Inject + lateinit var productsManager: ProductsManager + @Inject lateinit var trackEventManager: TrackEventManager diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Brand.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Brand.kt new file mode 100644 index 00000000..506d0f16 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Brand.kt @@ -0,0 +1,12 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class Brand( + @SerializedName("name") + val name: String, + @SerializedName("picture") + val picture: String, + @SerializedName("count") + val count: Int +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Category.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Category.kt new file mode 100644 index 00000000..c5bfe6db --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Category.kt @@ -0,0 +1,20 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class Category( + @SerializedName("id") + val id: String, + @SerializedName("name") + val name: String, + @SerializedName("url") + val url: String, + @SerializedName("url_handle") + val urlHandle: String, + @SerializedName("count") + val count: Int, + @SerializedName("parent") + val parent: String?, + @SerializedName("alias") + val alias: String? +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Filter.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Filter.kt new file mode 100644 index 00000000..ddb86ac1 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Filter.kt @@ -0,0 +1,8 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class Filter( + @SerializedName("filter") + val filter: FilterDetails +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterDetails.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterDetails.kt new file mode 100644 index 00000000..7777e302 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterDetails.kt @@ -0,0 +1,14 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class FilterDetails( + @SerializedName("count") + val count: Int, + @SerializedName("priority") + val priority: Int, + @SerializedName("ranges") + val ranges: List?, + @SerializedName("values") + val values: List +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterValue.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterValue.kt new file mode 100644 index 00000000..81204359 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterValue.kt @@ -0,0 +1,10 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class FilterValue( + @SerializedName("value") + val value: String, + @SerializedName("count") + val count: Int +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ImageUrlResized.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ImageUrlResized.kt similarity index 55% rename from personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ImageUrlResized.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ImageUrlResized.kt index 739b04d0..abd1f972 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ImageUrlResized.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ImageUrlResized.kt @@ -1,5 +1,5 @@ -package com.personalization.sdk.domain.models.products +package com.personalization.api.responses.products data class ImageUrlResized( val sizeToPath: Map -) \ No newline at end of file +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRange.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRange.kt new file mode 100644 index 00000000..770cd08f --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRange.kt @@ -0,0 +1,10 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class PriceRange( + @SerializedName("min") + val min: Double, + @SerializedName("max") + val max: Double +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRangeItem.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRangeItem.kt new file mode 100644 index 00000000..e021f9a6 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRangeItem.kt @@ -0,0 +1,10 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class PriceRangeItem( + @SerializedName("to") + val to: Double, + @SerializedName("count") + val count: Int +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Product.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Product.kt new file mode 100644 index 00000000..c72b80f0 --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Product.kt @@ -0,0 +1,55 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName +import com.personalization.api.responses.product.ImageUrlResized + +data class Product( + @SerializedName("brand") + val brand: String, + @SerializedName("currency") + val currency: String, + @SerializedName("id") + val id: String, + @SerializedName("is_new") + val isNew: Boolean? = null, + @SerializedName("name") + val name: String, + @SerializedName("old_price") + val oldPrice: String = "0", + @SerializedName("price") + val price: Double, + @SerializedName("price_formatted") + val priceFormatted: String, + @SerializedName("price_full_formatted") + val priceFullFormatted: String, + @SerializedName("picture") + val picture: String, + @SerializedName("url") + val url: String, + @SerializedName("description") + val description: String, + @SerializedName("category_ids") + val categoryIds: List, + @SerializedName("fashion_feature") + val fashionFeature: String?, + @SerializedName("fashion_gender") + val fashionGender: String?, + @SerializedName("sales_rate") + val salesRate: Int, + @SerializedName("relative_sales_rate") + val relativeSalesRate: Double, + @SerializedName("image_url") + val imageUrl: String, + @SerializedName("image_url_handle") + val imageUrlHandle: String, + @SerializedName("image_url_resized") + val imageUrlResized: ImageUrlResized, + @SerializedName("_id") + val internalId: String, + @SerializedName("group_id") + val groupId: String, + @SerializedName("barcode") + val barcode: String, + @SerializedName("categories") + val categories: List +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductCategory.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductCategory.kt similarity index 70% rename from personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductCategory.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductCategory.kt index 8fc54780..f6130de5 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductCategory.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductCategory.kt @@ -1,4 +1,4 @@ -package com.personalization.sdk.domain.models.products +package com.personalization.api.responses.products data class ProductCategory( val id: String, diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductParam.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductParam.kt similarity index 58% rename from personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductParam.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductParam.kt index 92a3b6ef..511e256d 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ProductParam.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductParam.kt @@ -1,4 +1,4 @@ -package com.personalization.sdk.domain.models.products +package com.personalization.api.responses.products data class ProductParam( val key: String, diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductsResponse.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductsResponse.kt new file mode 100644 index 00000000..2777507d --- /dev/null +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductsResponse.kt @@ -0,0 +1,22 @@ +package com.personalization.api.responses.products + +import com.google.gson.annotations.SerializedName + +data class ProductsResponse( + @SerializedName("brands") + val brands: List, + @SerializedName("categories") + val categories: List, + @SerializedName("filters") + val filters: List, + @SerializedName("price_range") + val priceRange: PriceRange, + @SerializedName("products") + val products: List, + @SerializedName("products_total") + val productsTotal: Int, + @SerializedName("price_ranges") + val priceRanges: List, + @SerializedName("price_median") + val priceMedian: Double +) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt b/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt index acb6c7fe..8afd8dab 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/features/products/impl/ProductsManagerImpl.kt @@ -1,12 +1,14 @@ package com.personalization.features.products.impl +import com.personalization.Params import com.personalization.api.OnApiCallbackListener import com.personalization.api.managers.ProductsManager import com.personalization.sdk.domain.usecases.network.SendNetworkMethodUseCase import javax.inject.Inject +import org.json.JSONObject internal class ProductsManagerImpl @Inject constructor( - private val sendNetworkMethodUseCase: SendNetworkMethodUseCase + private val sendNetworkMethodUseCase: SendNetworkMethodUseCase, ) : ProductsManager { override fun getProductsList( @@ -19,6 +21,52 @@ internal class ProductsManagerImpl @Inject constructor( filters: Map?, listener: OnApiCallbackListener? ) { - TODO("Not yet implemented") + sendNetworkMethodUseCase.getAsync( + method = GET_PRODUCT_LIST_REQUEST, + params = Params().buildParams( + brands = brands, + merchants = merchants, + categories = categories, + locations = locations, + limit = limit, + page = page, + filters = filters, + ).build(), + listener = listener + ) + } + + private fun Params.buildParams( + brands: String?, + merchants: String?, + categories: String?, + locations: String?, + limit: Int?, + page: Int?, + filters: Map?, + ): Params = this.apply { + limit?.let { put(LIMIT_KEY, it) } + page?.let { put(PAGE_KEY, it) } + locations?.let { put(LOCATION_KEY, it) } + brands?.let { put(BRANDS_KEY, it) } + merchants?.let { put(MERCHANTS_KEY, it) } + categories?.let { put(CATEGORIES_KEY, it) } + + filters?.takeIf { it.isNotEmpty() }?.let { + val filtersJson = JSONObject(it).toString() + put(FILTERS_KEY, filtersJson) + } + } + + companion object { + const val GET_PRODUCT_LIST_REQUEST = "products" + + private const val LIMIT_KEY = "limit" + private const val PAGE_KEY = "page" + private const val LOCATION_KEY = "locations" + private const val BRANDS_KEY = "brands" + private const val MERCHANTS_KEY = "merchants" + private const val CATEGORIES_KEY = "categories" + private const val FILTERS_KEY = "" } } diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt index ca89cda9..c4cce075 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/sdk/data/di/RepositoriesModule.kt @@ -34,6 +34,4 @@ abstract class RepositoriesModule { @Binds abstract fun bindNotificationRepository(impl: NotificationRepositoryImpl): NotificationRepository -// @Binds -// abstract fun bindProductsRepository(impl: PreferencesRepositoryImpl): PreferencesRepository } diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt deleted file mode 100644 index fa4ac849..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/ApiResponse.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class ApiResponse( - val brands: List, - val categories: List, - val filters: List, - val priceRange: PriceRange, - val products: List, - val productsTotal: Int, - val priceRanges: List, - val priceMedian: Double -) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt deleted file mode 100644 index 38b680cd..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Brand.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class Brand( - val name: String, - val picture: String, - val count: Int -) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt deleted file mode 100644 index d515e27b..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Category.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class Category( - val id: String, - val name: String, - val url: String, - val urlHandle: String, - val count: Int, - val parent: String?, - val alias: String? -) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt deleted file mode 100644 index 5d03f125..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Filter.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class Filter( - val filter: FilterDetails -) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt deleted file mode 100644 index 5ebd9934..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterDetails.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class FilterDetails( - val count: Int, - val priority: Int, - val ranges: List?, - val values: List -) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt deleted file mode 100644 index ade7f007..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/FilterValue.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class FilterValue( - val value: String, - val count: Int -) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt deleted file mode 100644 index 6902a874..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRange.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class PriceRange( - val min: Double, - val max: Double -) \ No newline at end of file diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt deleted file mode 100644 index f0b88cad..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/PriceRangeItem.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class PriceRangeItem( - val to: Double, - val count: Int -) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt deleted file mode 100644 index 823f389a..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/models/products/Product.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.personalization.sdk.domain.models.products - -data class Product( - val brand: String, - val currency: String, - val id: String, - val isNew: Boolean? = null, - val name: String, - val oldPrice: String = "0", - val price: Double, - val priceFormatted: String, - val priceFullFormatted: String, - val picture: String, - val url: String, - val description: String, - val categoryIds: List, - val fashionFeature: String?, - val fashionGender: String?, - val salesRate: Int, - val relativeSalesRate: Int, - val imageUrl: String, - val imageUrlHandle: String, - val imageUrlResized: ImageUrlResized, - val internalId: String, - val groupId: String, - val barcode: String, - val categories: List -) \ No newline at end of file From 6303d2fa3936e2247cbb0bbb2a76474712900be1 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Thu, 31 Oct 2024 13:13:23 +0200 Subject: [PATCH 09/10] chore: Remove useless repository --- .../sdk/domain/repositories/ProductsRepository.kt | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt diff --git a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt b/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt deleted file mode 100644 index e1071cf8..00000000 --- a/personalization-sdk/src/main/kotlin/com/personalization/sdk/domain/repositories/ProductsRepository.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.personalization.sdk.domain.repositories - -interface ProductsRepository { - - fun getProductsList( - brands: String?, - merchants: String?, - categories: String?, - locations: String?, - limit: Int?, - page: Int?, - filters: Map? - ) - -} From a61f74d01dce296911fce98c12d87d3956826b45 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Fri, 1 Nov 2024 10:31:57 +0200 Subject: [PATCH 10/10] chore: Moved models to self directories --- .../api/responses/products/{ => brand}/Brand.kt | 2 +- .../api/responses/products/{ => category}/Category.kt | 2 +- .../api/responses/products/{ => filter}/Filter.kt | 2 +- .../api/responses/products/{ => filter}/FilterDetails.kt | 2 +- .../api/responses/products/{ => filter}/FilterValue.kt | 2 +- .../api/responses/products/{ => image}/ImageUrlResized.kt | 2 +- .../api/responses/products/{ => price}/PriceRange.kt | 2 +- .../api/responses/products/{ => price}/PriceRangeItem.kt | 2 +- .../api/responses/products/{ => product}/Product.kt | 2 +- .../responses/products/{ => product}/ProductCategory.kt | 2 +- .../api/responses/products/{ => product}/ProductParam.kt | 2 +- .../responses/products/{ => product}/ProductsResponse.kt | 7 ++++++- 12 files changed, 17 insertions(+), 12 deletions(-) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => brand}/Brand.kt (79%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => category}/Category.kt (87%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => filter}/Filter.kt (69%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => filter}/FilterDetails.kt (84%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => filter}/FilterValue.kt (75%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => image}/ImageUrlResized.kt (55%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => price}/PriceRange.kt (75%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => price}/PriceRangeItem.kt (75%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => product}/Product.kt (96%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => product}/ProductCategory.kt (69%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => product}/ProductParam.kt (56%) rename personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/{ => product}/ProductsResponse.kt (61%) diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Brand.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/brand/Brand.kt similarity index 79% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Brand.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/brand/Brand.kt index 506d0f16..007b7de5 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Brand.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/brand/Brand.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.brand import com.google.gson.annotations.SerializedName diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Category.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/category/Category.kt similarity index 87% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Category.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/category/Category.kt index c5bfe6db..cb1b9571 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Category.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/category/Category.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.category import com.google.gson.annotations.SerializedName diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Filter.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/Filter.kt similarity index 69% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Filter.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/Filter.kt index ddb86ac1..55a88a94 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Filter.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/Filter.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.filter import com.google.gson.annotations.SerializedName diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterDetails.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/FilterDetails.kt similarity index 84% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterDetails.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/FilterDetails.kt index 7777e302..85b65e0a 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterDetails.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/FilterDetails.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.filter import com.google.gson.annotations.SerializedName diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterValue.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/FilterValue.kt similarity index 75% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterValue.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/FilterValue.kt index 81204359..1908095b 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/FilterValue.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/filter/FilterValue.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.filter import com.google.gson.annotations.SerializedName diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ImageUrlResized.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/image/ImageUrlResized.kt similarity index 55% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ImageUrlResized.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/image/ImageUrlResized.kt index abd1f972..fc6c295f 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ImageUrlResized.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/image/ImageUrlResized.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.image data class ImageUrlResized( val sizeToPath: Map diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRange.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/price/PriceRange.kt similarity index 75% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRange.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/price/PriceRange.kt index 770cd08f..317c9c83 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRange.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/price/PriceRange.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.price import com.google.gson.annotations.SerializedName diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRangeItem.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/price/PriceRangeItem.kt similarity index 75% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRangeItem.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/price/PriceRangeItem.kt index e021f9a6..b9b41c76 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/PriceRangeItem.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/price/PriceRangeItem.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.price import com.google.gson.annotations.SerializedName diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Product.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/Product.kt similarity index 96% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Product.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/Product.kt index c72b80f0..2927a978 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/Product.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/Product.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.product import com.google.gson.annotations.SerializedName import com.personalization.api.responses.product.ImageUrlResized diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductCategory.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductCategory.kt similarity index 69% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductCategory.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductCategory.kt index f6130de5..3924f7a2 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductCategory.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductCategory.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.product data class ProductCategory( val id: String, diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductParam.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductParam.kt similarity index 56% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductParam.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductParam.kt index 511e256d..602282de 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductParam.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductParam.kt @@ -1,4 +1,4 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.product data class ProductParam( val key: String, diff --git a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductsResponse.kt b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductsResponse.kt similarity index 61% rename from personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductsResponse.kt rename to personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductsResponse.kt index 2777507d..c5863358 100644 --- a/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/ProductsResponse.kt +++ b/personalization-sdk/src/main/kotlin/com/personalization/api/responses/products/product/ProductsResponse.kt @@ -1,6 +1,11 @@ -package com.personalization.api.responses.products +package com.personalization.api.responses.products.product import com.google.gson.annotations.SerializedName +import com.personalization.api.responses.products.brand.Brand +import com.personalization.api.responses.products.category.Category +import com.personalization.api.responses.products.filter.Filter +import com.personalization.api.responses.products.price.PriceRange +import com.personalization.api.responses.products.price.PriceRangeItem data class ProductsResponse( @SerializedName("brands")