Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECWID-126129 New Customers: SDK improvements: added new endpoint for … #321

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ interface CustomersApiClient {
fun searchCustomersLocations(request: CustomersLocationsSearchRequest): CustomersLocationsSearchResult
fun searchCustomersFilters(request: CustomerFiltersDataSearchRequest): CustomersFiltersDataSearchResult
fun massUpdate(request: CustomersMassUpdateRequest): CustomerUpdateResult
fun getCustomersIds(request: CustomersIdsRequest): CustomersIdsResult
}

// Customer groups
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.ecwid.apiclient.v3.dto.customer.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.impl.RequestInfo
import com.ecwid.apiclient.v3.responsefields.ResponseFields

data class CustomersIdsRequest(
val requestFields: CustomersRequestFields = CustomersRequestFields(),
val responseFields: ResponseFields = ResponseFields.All,
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createGetRequest(
pathSegments = listOf(
"customers_ids"
),
params = toParams(),
responseFields = responseFields,
)

private fun toParams(): Map<String, String> {
val request = this.requestFields
return mutableMapOf<String, String>().apply {
request.keyword?.let { put("keyword", it) }
request.minOrderCount?.let { put("minOrderCount", it.toString()) }
request.maxOrderCount?.let { put("maxOrderCount", it.toString()) }
request.minSalesValue?.let { put("minSalesValue", it.toString()) }
request.maxSalesValue?.let { put("maxSalesValue", it.toString()) }
request.taxExempt?.let { put("taxExempt", it.toString()) }
request.acceptMarketing?.let { put("acceptMarketing", it.toString()) }
request.purchasedProductIds?.let { put("purchasedProductIds", it) }
request.customerGroupIds?.let { put("customerGroupIds", it) }
request.countryCodes?.let { put("countryCodes", it) }
request.lang?.let { put("lang", it) }
}.toMap()
}
}
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
@@ -0,0 +1,7 @@
package com.ecwid.apiclient.v3.dto.customer.result

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

data class CustomersIdsResult(
val ids: List<Int> = listOf(),
) : ApiResultDTO
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ internal data class CustomersApiClientImpl(
override fun massUpdate(request: CustomersMassUpdateRequest) =
apiClientHelper.makeObjectResultRequest<CustomerUpdateResult>(request)

override fun getCustomersIds(request: CustomersIdsRequest) =
apiClientHelper.makeObjectResultRequest<CustomersIdsResult>(request)

}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ val nullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
customAppRequestNullablePropertyRules,
customersSearchRequestNullablePropertyRules,
customersMassUpdatedRequestNullablePropertyRules,
customersIdsRequestNullablePropertyRules,
deletedCustomersSearchRequestNullablePropertyRules,
deletedOrdersSearchRequestNullablePropertyRules,
deletedProductsSearchRequestNullablePropertyRules,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ecwid.apiclient.v3.rule.nullablepropertyrules

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(
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