From 5eff249007f3a625732bea1a49e57cfdb4c44073 Mon Sep 17 00:00:00 2001 From: Kate Kolmakova Date: Wed, 23 Oct 2024 19:10:24 +0400 Subject: [PATCH 1/2] ECWID-150909 Added update counters method for product reviews --- .../com/ecwid/apiclient/v3/ApiClient.kt | 3 +-- .../request/ProductReviewCountersUpdate.kt | 8 ++++++++ .../ProductReviewCountersUpdateRequest.kt | 20 +++++++++++++++++++ .../ProductReviewUpdateCountersResult.kt | 7 +++++++ .../v3/impl/ProductReviewsApiClientImpl.kt | 3 +++ .../v3/rule/NullablePropertyRules.kt | 1 + ...ProductReviewUpdateCountersRequestRules.kt | 10 ++++++++++ 7 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdateRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/result/ProductReviewUpdateCountersResult.kt create mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewUpdateCountersRequestRules.kt diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt index ab396411..4e210ffc 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt @@ -26,8 +26,6 @@ import com.ecwid.apiclient.v3.dto.customergroup.request.* import com.ecwid.apiclient.v3.dto.customergroup.result.* import com.ecwid.apiclient.v3.dto.instantsite.redirects.request.* import com.ecwid.apiclient.v3.dto.instantsite.redirects.result.* -import com.ecwid.apiclient.v3.dto.order.request.* -import com.ecwid.apiclient.v3.dto.order.result.* import com.ecwid.apiclient.v3.dto.productreview.request.* import com.ecwid.apiclient.v3.dto.productreview.result.* import com.ecwid.apiclient.v3.dto.producttype.request.* @@ -314,4 +312,5 @@ interface ProductReviewsApiClient { fun deleteProductReview(request: ProductReviewDeleteRequest): ProductReviewDeleteResult fun massUpdateProductReview(request: ProductReviewMassUpdateRequest): ProductReviewMassUpdateResult fun getProductReviewsFiltersData(request: ProductReviewFiltersDataRequest): ProductReviewFiltersDataResult + fun updateProductReviewCounters(request: ProductReviewCountersUpdateRequest): ProductReviewUpdateCountersResult } diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt new file mode 100644 index 00000000..1c7e69cc --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt @@ -0,0 +1,8 @@ +package com.ecwid.apiclient.v3.dto.productreview.request + +import com.ecwid.apiclient.v3.dto.productreview.enums.ProductReviewStatus + +data class ProductReviewCountersUpdate( + val productIds: List = listOf(), + val status: ProductReviewStatus? = null, +) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdateRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdateRequest.kt new file mode 100644 index 00000000..3ec6d7ac --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdateRequest.kt @@ -0,0 +1,20 @@ +package com.ecwid.apiclient.v3.dto.productreview.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.httptransport.HttpBody +import com.ecwid.apiclient.v3.impl.RequestInfo + +data class ProductReviewCountersUpdateRequest( + val updateInfo: ProductReviewCountersUpdate = ProductReviewCountersUpdate(), +) : ApiRequest { + override fun toRequestInfo() = RequestInfo.createPostRequest( + pathSegments = listOf( + "reviews", + "update_counters", + ), + params = mapOf(), + httpBody = HttpBody.JsonBody( + obj = updateInfo + ) + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/result/ProductReviewUpdateCountersResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/result/ProductReviewUpdateCountersResult.kt new file mode 100644 index 00000000..fd74a106 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/result/ProductReviewUpdateCountersResult.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.productreview.result + +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class ProductReviewUpdateCountersResult( + val updateCount: Int = 0 +) : ApiResultDTO diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/impl/ProductReviewsApiClientImpl.kt b/src/main/kotlin/com/ecwid/apiclient/v3/impl/ProductReviewsApiClientImpl.kt index fbae60fc..08ed49fd 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/impl/ProductReviewsApiClientImpl.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/impl/ProductReviewsApiClientImpl.kt @@ -29,4 +29,7 @@ class ProductReviewsApiClientImpl( override fun getProductReviewsFiltersData(request: ProductReviewFiltersDataRequest) = apiClientHelper.makeObjectResultRequest(request) + override fun updateProductReviewCounters(request: ProductReviewCountersUpdateRequest) = + apiClientHelper.makeObjectResultRequest(request) + } diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt index e0ed2c84..55621d29 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt @@ -199,6 +199,7 @@ val nullablePropertyRules: List> = listOf( fetchedProductReviewNullablePropertyRules, productReviewMassUpdateRequestNullablePropertyRules, productReviewSearchRequestNullablePropertyRules, + productReviewCountersUpdateRequestNullablePropertyRules, fetchedCustomersConfigNullablePropertyRules, ).flatten() diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewUpdateCountersRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewUpdateCountersRequestRules.kt new file mode 100644 index 00000000..927e1b9f --- /dev/null +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewUpdateCountersRequestRules.kt @@ -0,0 +1,10 @@ +package com.ecwid.apiclient.v3.rule.nullablepropertyrules + +import com.ecwid.apiclient.v3.dto.productreview.request.ProductReviewCountersUpdate +import com.ecwid.apiclient.v3.rule.NullablePropertyRule +import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable + +val productReviewCountersUpdateRequestNullablePropertyRules: List> = listOf( + AllowNullable(ProductReviewCountersUpdate::productIds), + AllowNullable(ProductReviewCountersUpdate::status), +) From 77bfebacce249ef24a966330742dcae1105f498d Mon Sep 17 00:00:00 2001 From: Kate Kolmakova Date: Wed, 23 Oct 2024 19:39:41 +0400 Subject: [PATCH 2/2] ECWID-150909 Added missing ApiRequestDTO implement --- .../dto/productreview/request/ProductReviewCountersUpdate.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt index 1c7e69cc..61f0844d 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productreview/request/ProductReviewCountersUpdate.kt @@ -1,8 +1,9 @@ package com.ecwid.apiclient.v3.dto.productreview.request +import com.ecwid.apiclient.v3.dto.common.ApiRequestDTO import com.ecwid.apiclient.v3.dto.productreview.enums.ProductReviewStatus data class ProductReviewCountersUpdate( val productIds: List = listOf(), val status: ProductReviewStatus? = null, -) +) : ApiRequestDTO