From 43bea2c6521affca8aa7276e7b768b4618c7dc7e Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Fri, 10 Jan 2025 10:28:11 +0530 Subject: [PATCH] Pass in status filter options for variations endpoint --- .../rest/wpcom/wc/product/ProductRestClient.kt | 7 ++++++- .../wordpress/android/fluxc/store/WCProductStore.kt | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductRestClient.kt b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductRestClient.kt index 5dc0bbc8bc..420579682d 100644 --- a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductRestClient.kt +++ b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductRestClient.kt @@ -939,7 +939,8 @@ class ProductRestClient @Inject constructor( offset: Int, includedVariationIds: List = emptyList(), searchQuery: String? = null, - excludedVariationIds: List = emptyList() + excludedVariationIds: List = emptyList(), + filterOptions: Map? = null, ): WooPayload> { val params = mutableMapOf( "per_page" to pageSize.toString(), @@ -950,6 +951,10 @@ class ProductRestClient @Inject constructor( .putIfNotEmpty("include" to includedVariationIds.map { it }.joinToString()) .putIfNotEmpty("exclude" to excludedVariationIds.map { it }.joinToString()) + filterOptions?.let { options -> + params.putAll(options.map { it.key.toString() to it.value }) + } + val url = WOOCOMMERCE.products.id(productId).variations.pathV3 val response = wooNetwork.executeGetGsonRequest( diff --git a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store/WCProductStore.kt b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store/WCProductStore.kt index c49b8b0505..d7a33be3b8 100644 --- a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store/WCProductStore.kt +++ b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store/WCProductStore.kt @@ -113,6 +113,12 @@ class WCProductStore @Inject constructor( override fun toString() = name.lowercase(Locale.US) } + enum class VariationFilterOption { + STATUS; + + override fun toString() = name.lowercase(Locale.US) + } + enum class SkuSearchOptions { Disabled, ExactSearch, PartialMatch } @@ -1754,7 +1760,8 @@ class WCProductStore @Inject constructor( offset: Int = 0, pageSize: Int = DEFAULT_PRODUCT_VARIATIONS_PAGE_SIZE, includedVariationIds: List = emptyList(), - excludedVariationIds: List = emptyList() + excludedVariationIds: List = emptyList(), + filterOptions: Map? = null, ): WooResult { return coroutineEngine.withDefaultContext(API, this, "fetchProductVariations") { val response = wcProductRestClient.fetchProductVariationsWithSyncRequest( @@ -1763,7 +1770,8 @@ class WCProductStore @Inject constructor( offset = offset, pageSize = pageSize, includedVariationIds = includedVariationIds, - excludedVariationIds = excludedVariationIds + excludedVariationIds = excludedVariationIds, + filterOptions = filterOptions ) when { response.isError -> WooResult(response.error)