Skip to content

Commit

Permalink
ECWID-126129 New Customers: SDK improvements: refactoring fields for …
Browse files Browse the repository at this point in the history
…Customers Request
  • Loading branch information
winrokru committed Sep 5, 2023
1 parent 413048e commit 343895b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ import com.ecwid.apiclient.v3.impl.RequestInfo
import com.ecwid.apiclient.v3.responsefields.ResponseFields

data class CustomersIdsRequest(
val keyword: String? = null,
val minOrderCount: Int? = null,
val maxOrderCount: Int? = null,
val minSalesValue: Int? = null,
val maxSalesValue: Int? = null,
val taxExempt: Boolean? = null,
val acceptMarketing: Boolean? = null,
val purchasedProductIds: String? = null,
val customerGroupIds: String? = null,
val countryCodes: String? = null,
val lang: String? = null,
val requestFields: CustomersRequestFields = CustomersRequestFields(),
val responseFields: ResponseFields = ResponseFields.All,
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createGetRequest(
Expand All @@ -27,7 +17,7 @@ data class CustomersIdsRequest(
)

private fun toParams(): Map<String, String> {
val request = this
val request = this.requestFields
return mutableMapOf<String, String>().apply {
request.keyword?.let { put("keyword", it) }
request.minOrderCount?.let { put("minOrderCount", it.toString()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ import com.ecwid.apiclient.v3.httptransport.HttpBody
import com.ecwid.apiclient.v3.impl.RequestInfo

data class CustomersMassUpdateRequest(
val keyword: String? = null,
val minOrderCount: Int? = null,
val maxOrderCount: Int? = null,
val minSalesValue: Int? = null,
val maxSalesValue: Int? = null,
val taxExempt: Boolean? = null,
val acceptMarketing: Boolean? = null,
val purchasedProductIds: String? = null,
val customerGroupIds: String? = null,
val countryCodes: String? = null,
val lang: String? = null,
val requestFields: CustomersRequestFields = CustomersRequestFields(),
val customer: MassUpdateCustomer = MassUpdateCustomer()
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createPostRequest(
Expand All @@ -29,7 +19,7 @@ data class CustomersMassUpdateRequest(
)

private fun toParams(): Map<String, String> {
val request = this
val request = this.requestFields
return mutableMapOf<String, String>().apply {
request.keyword?.let { put("keyword", it) }
request.minOrderCount?.let { put("minOrderCount", it.toString()) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ecwid.apiclient.v3.dto.customer.request

import com.ecwid.apiclient.v3.dto.common.ApiRequestDTO

data class CustomersRequestFields(
val keyword: String? = null,
val minOrderCount: Int? = null,
val maxOrderCount: Int? = null,
val minSalesValue: Int? = null,
val maxSalesValue: Int? = null,
val taxExempt: Boolean? = null,
val acceptMarketing: Boolean? = null,
val purchasedProductIds: String? = null,
val customerGroupIds: String? = null,
val countryCodes: String? = null,
val lang: String? = null,
) : ApiRequestDTO
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.ecwid.apiclient.v3.rule.nullablepropertyrules

import com.ecwid.apiclient.v3.dto.customer.request.CustomersIdsRequest
import com.ecwid.apiclient.v3.dto.customer.request.CustomersRequestFields
import com.ecwid.apiclient.v3.rule.NullablePropertyRule
import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable

val customersIdsRequestNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
NullablePropertyRule.AllowNullable(CustomersIdsRequest::keyword),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::maxOrderCount),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::minOrderCount),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::maxSalesValue),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::minSalesValue),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::purchasedProductIds),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::customerGroupIds),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::countryCodes),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::taxExempt),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::acceptMarketing),
NullablePropertyRule.AllowNullable(CustomersIdsRequest::lang),
AllowNullable(CustomersRequestFields::keyword),
AllowNullable(CustomersRequestFields::maxOrderCount),
AllowNullable(CustomersRequestFields::minOrderCount),
AllowNullable(CustomersRequestFields::maxSalesValue),
AllowNullable(CustomersRequestFields::minSalesValue),
AllowNullable(CustomersRequestFields::purchasedProductIds),
AllowNullable(CustomersRequestFields::customerGroupIds),
AllowNullable(CustomersRequestFields::countryCodes),
AllowNullable(CustomersRequestFields::taxExempt),
AllowNullable(CustomersRequestFields::acceptMarketing),
AllowNullable(CustomersRequestFields::lang),
)
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package com.ecwid.apiclient.v3.rule.nullablepropertyrules

import com.ecwid.apiclient.v3.dto.customer.request.CustomersMassUpdateRequest
import com.ecwid.apiclient.v3.dto.customer.request.CustomersRequestFields
import com.ecwid.apiclient.v3.dto.customer.request.MassUpdateCustomer
import com.ecwid.apiclient.v3.rule.NullablePropertyRule
import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable


val customersMassUpdatedRequestNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(

AllowNullable(CustomersMassUpdateRequest::keyword),
AllowNullable(CustomersMassUpdateRequest::maxOrderCount),
AllowNullable(CustomersMassUpdateRequest::minOrderCount),
AllowNullable(CustomersMassUpdateRequest::maxSalesValue),
AllowNullable(CustomersMassUpdateRequest::minSalesValue),
AllowNullable(CustomersMassUpdateRequest::purchasedProductIds),
AllowNullable(CustomersMassUpdateRequest::customerGroupIds),
AllowNullable(CustomersMassUpdateRequest::countryCodes),
AllowNullable(CustomersMassUpdateRequest::taxExempt),
AllowNullable(CustomersMassUpdateRequest::acceptMarketing),
AllowNullable(CustomersMassUpdateRequest::lang),
AllowNullable(CustomersRequestFields::keyword),
AllowNullable(CustomersRequestFields::maxOrderCount),
AllowNullable(CustomersRequestFields::minOrderCount),
AllowNullable(CustomersRequestFields::maxSalesValue),
AllowNullable(CustomersRequestFields::minSalesValue),
AllowNullable(CustomersRequestFields::purchasedProductIds),
AllowNullable(CustomersRequestFields::customerGroupIds),
AllowNullable(CustomersRequestFields::countryCodes),
AllowNullable(CustomersRequestFields::taxExempt),
AllowNullable(CustomersRequestFields::acceptMarketing),
AllowNullable(CustomersRequestFields::lang),

AllowNullable(MassUpdateCustomer::ids),
AllowNullable(MassUpdateCustomer::delete),
Expand Down

0 comments on commit 343895b

Please sign in to comment.