Skip to content

Commit 9bbe27e

Browse files
authored
Merge pull request #200 from Ecwid/products_endpoint
Update parameter list for /products endpoint
2 parents d202c58 + c52b115 commit 9bbe27e

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

config/detekt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
complexity:
22
ComplexMethod:
3-
threshold: 30
3+
threshold: 40
44
LargeClass:
55
excludes: ['**/test/**']
66
LongMethod:

src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/ProductsSearchRequest.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ sealed class ProductsSearchRequest : ApiRequest {
99

1010
data class ByFilters(
1111
val keyword: String? = null,
12+
val externalReferenceId: String? = null,
1213
val priceFrom: Double? = null,
1314
val priceTo: Double? = null,
1415
val categories: List<Int>? = null,
@@ -25,11 +26,15 @@ sealed class ProductsSearchRequest : ApiRequest {
2526
val attributes: ProductSearchAttributes? = null,
2627
val options: ProductSearchOptions? = null,
2728
val sku: String? = null,
29+
val isGiftCard: Boolean? = null,
30+
val discountsAllowed: Boolean? = null,
31+
val isCustomerSetPrice: Boolean? = null,
2832
val baseUrl: String? = null,
2933
val cleanUrls: Boolean? = null,
3034
val offset: Int = 0,
3135
val limit: Int = 100,
32-
val lang: String? = null
36+
val lang: String? = null,
37+
val visibleInStorefront: Boolean? = null,
3338
) : ProductsSearchRequest() {
3439
override fun toRequestInfo() = RequestInfo.createGetRequest(
3540
pathSegments = listOf(
@@ -42,7 +47,11 @@ sealed class ProductsSearchRequest : ApiRequest {
4247
val request = this
4348
return mutableMapOf<String, String>().apply {
4449
request.keyword?.let { put("keyword", it) }
50+
request.externalReferenceId?.let { put("externalReferenceId", it) }
4551
request.sku?.let { put("sku", it) }
52+
request.isGiftCard?.let { put("isGiftCard", it.toString()) }
53+
request.discountsAllowed?.let { put("discountsAllowed", it.toString()) }
54+
request.isCustomerSetPrice?.let { put("isCustomerSetPrice", it.toString()) }
4655
request.priceFrom?.let { put("priceFrom", it.toString()) }
4756
request.priceTo?.let { put("priceTo", it.toString()) }
4857
request.createdFrom?.let { put("createdFrom", TimeUnit.MILLISECONDS.toSeconds(it.time).toString()) }
@@ -71,11 +80,15 @@ sealed class ProductsSearchRequest : ApiRequest {
7180
put("offset", request.offset.toString())
7281
put("limit", request.limit.toString())
7382
request.lang?.let { put("lang", it) }
83+
request.visibleInStorefront?.let { put("visibleInStorefront", it.toString()) }
7484
}.toMap()
7585
}
7686
}
7787

78-
data class ByIds(val productIds: List<Int> = listOf()) : ProductsSearchRequest() {
88+
data class ByIds(
89+
val productIds: List<Int> = listOf(),
90+
val sortBy: SortOrder? = null,
91+
) : ProductsSearchRequest() {
7992
override fun toRequestInfo() = RequestInfo.createGetRequest(
8093
pathSegments = listOf(
8194
"products"
@@ -90,6 +103,7 @@ sealed class ProductsSearchRequest : ApiRequest {
90103
val request = this
91104
return mutableMapOf<String, String>().apply {
92105
put("productId", request.productIds.joinToString(","))
106+
request.sortBy?.let { put("sortBy", it.name) }
93107
}.toMap()
94108
}
95109
}

src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductsSearchRequestRules.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,11 @@ val productsSearchRequestNullablePropertyRules: List<NullablePropertyRule<*, *>>
2424
AllowNullable(ProductsSearchRequest.ByFilters::sku),
2525
AllowNullable(ProductsSearchRequest.ByFilters::sortBy),
2626
AllowNullable(ProductsSearchRequest.ByFilters::updatedFrom),
27-
AllowNullable(ProductsSearchRequest.ByFilters::updatedTo)
27+
AllowNullable(ProductsSearchRequest.ByFilters::updatedTo),
28+
AllowNullable(ProductsSearchRequest.ByFilters::externalReferenceId),
29+
AllowNullable(ProductsSearchRequest.ByFilters::isGiftCard),
30+
AllowNullable(ProductsSearchRequest.ByFilters::discountsAllowed),
31+
AllowNullable(ProductsSearchRequest.ByFilters::isCustomerSetPrice),
32+
AllowNullable(ProductsSearchRequest.ByFilters::visibleInStorefront),
33+
AllowNullable(ProductsSearchRequest.ByIds::sortBy),
2834
)

0 commit comments

Comments
 (0)