From 5762422202d7c219b1705020ddfc693e168af924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81sar=20Vargas=20Casaseca?= Date: Wed, 4 Dec 2024 17:18:05 +0100 Subject: [PATCH] Decrease Cyclomatic Complexity --- .../rest/wpcom/wc/product/ProductRestClient.kt | 13 ++++++++++--- 1 file changed, 10 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 1531ef1db6..ecebccb600 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 @@ -654,13 +654,20 @@ class ProductRestClient @Inject constructor( } } - if (globalUniqueIdSearchQuery.isNullOrEmpty().not()) { - params["global_unique_id"] = globalUniqueIdSearchQuery!! - } + addGlobalUniqueIdSearchQuery(params, globalUniqueIdSearchQuery) return params } + private fun addGlobalUniqueIdSearchQuery( + params: MutableMap, + globalUniqueIdSearchQuery: String? + ) { + if (!globalUniqueIdSearchQuery.isNullOrEmpty()) { + params["global_unique_id"] = globalUniqueIdSearchQuery + } + } + /** * Makes a GET request to `/wp-json/wc/v3/products/categories` retrieving a list of product * categories for the given WooCommerce [SiteModel].