Skip to content

Commit

Permalink
ECWID-150909 Added update counters method for product reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
kitty-ecwid committed Oct 23, 2024
1 parent de4559d commit 5eff249
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -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<Long> = listOf(),
val status: ProductReviewStatus? = null,
)
Original file line number Diff line number Diff line change
@@ -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
)
)
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ class ProductReviewsApiClientImpl(
override fun getProductReviewsFiltersData(request: ProductReviewFiltersDataRequest) =
apiClientHelper.makeObjectResultRequest<ProductReviewFiltersDataResult>(request)

override fun updateProductReviewCounters(request: ProductReviewCountersUpdateRequest) =
apiClientHelper.makeObjectResultRequest<ProductReviewUpdateCountersResult>(request)

}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ val nullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
fetchedProductReviewNullablePropertyRules,
productReviewMassUpdateRequestNullablePropertyRules,
productReviewSearchRequestNullablePropertyRules,
productReviewCountersUpdateRequestNullablePropertyRules,
fetchedCustomersConfigNullablePropertyRules,
).flatten()

Expand Down
Original file line number Diff line number Diff line change
@@ -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<NullablePropertyRule<*, *>> = listOf(
AllowNullable(ProductReviewCountersUpdate::productIds),
AllowNullable(ProductReviewCountersUpdate::status),
)

0 comments on commit 5eff249

Please sign in to comment.