From 5cfedf935176f8f42e71ed7c11953c591f823935 Mon Sep 17 00:00:00 2001 From: winrok Date: Thu, 25 Jul 2024 19:08:35 +0400 Subject: [PATCH] ECWID-144507 new endpoint for store extrafields customers config --- .DS_Store | Bin 0 -> 8196 bytes src/.DS_Store | Bin 0 -> 6148 bytes .../com/ecwid/apiclient/v3/ApiClient.kt | 5 +- .../apiclient/v3/StoreExtrafieldsApiClient.kt | 13 +++++ .../v3/converter/FetchedCustomersConfig.kt | 14 +++++ .../dto/customer/request/UpdatedCustomer.kt | 3 +- .../v3/dto/customer/result/FetchedCustomer.kt | 15 ++--- .../extrafield/enums/ExtrafieldEntityType.kt | 6 ++ .../enums/ExtrafieldType.kt | 2 +- .../request/CustomersConfigCreateRequest.kt | 19 +++++++ .../request/CustomersConfigDeleteRequest.kt | 17 ++++++ .../request/CustomersConfigDetailsRequest.kt | 20 +++++++ .../request/CustomersConfigUpdateRequest.kt | 21 +++++++ .../request/CustomersConfigsSearchRequest.kt | 19 +++++++ .../request/UpdatedCustomersConfig.kt | 16 ++++++ .../result/CustomersConfigCreateResult.kt | 8 +++ .../result/CustomersConfigDeleteResult.kt | 7 +++ .../result/CustomersConfigUpdateResult.kt | 7 +++ .../result/CustomersConfigsSearchResult.kt | 7 +++ .../result/FetchedCustomersConfig.kt | 20 +++++++ .../request/ExtrafieldConfigUpdateRequest.kt | 2 +- .../request/UpdatedExtrafieldConfig.kt | 52 +++++++++--------- .../profile/result/FetchedExtrafieldConfig.kt | 2 +- .../v3/impl/StoreExtrafieldsApiClientImpl.kt | 26 +++++++++ .../v3/rule/NonUpdatablePropertyRules.kt | 5 ++ .../v3/rule/NullablePropertyRules.kt | 1 + .../FetchedCustomersConfigRules.kt | 15 +++++ 27 files changed, 284 insertions(+), 38 deletions(-) create mode 100644 .DS_Store create mode 100644 src/.DS_Store create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/StoreExtrafieldsApiClient.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedCustomersConfig.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldEntityType.kt rename src/main/kotlin/com/ecwid/apiclient/v3/dto/{profile => extrafield}/enums/ExtrafieldType.kt (69%) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigCreateRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDeleteRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDetailsRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigUpdateRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigsSearchRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/UpdatedCustomersConfig.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigCreateResult.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigDeleteResult.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigUpdateResult.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigsSearchResult.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/FetchedCustomersConfig.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreExtrafieldsApiClientImpl.kt create mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ac96bd15cff368246c3872fba3c3f62dd7b104f4 GIT binary patch literal 8196 zcmeHMF>4e-6n>Lj;t@eorgIvFG>6yNiJNeC7UETcf_Jy^a&YH{oN2698&T2-Y3*WX zErK9I)Y8JjPPoQG#3KK|@6C*RZ*FhJN({b%nQwRAd-J~iW_RaikBH3XUfLvDBceJg zn>3j8YyV9n-IuUPlJRa;d+ z75Fa|;P-7+#%Ic+%181DYuPfM zj$+PZ9>jN;`uqP0yfUS%3aA2q zs(`7r+O17^yH$No6tD6Y^)@OO_RBrG5H!&b0h||q7~S5T4P1k)re{2(mZNeS@{co43Azt(B@YreMA2A;g1E;X8QqX?z5~*%@sX zgGUjaf!%L*es+=%vYR0y9^cPLL_;DfF$7tZ9uae|Ys-Sg$+E|CF`8U7^{Qu+-)fR) zFQ}#|UDIv${5ylAuCH#YYPM`iUCXVTP2E0!R(JPV>bf`s&VV!E4E%2faA%8@14W;m0cXG&_+&uNhkzj% z4O_)@bYMy?0I+~L33TZtBqta~!&VU<2x}@(Q`uS!)^yl|#YMwbQPYX7`CzO3(Y$b~ zj{QRlCyt6fI|I%@&cL=VhjRa);*;rZ^79m5IRnnXA7g-vYEq5yQg*j~c|Eyn1I9Uq rh{Uy`K%i$o0a(a6a*&+r527P38n%kEi`Y{-(0>FHAwD?+Kfu5{^c+Iu literal 0 HcmV?d00001 diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt index 41689b9e8..ab3964113 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt @@ -73,6 +73,7 @@ open class ApiClient private constructor( instantSiteRedirectsApiClient: InstantSiteRedirectsApiClientImpl, slugInfoApiClient: SlugInfoApiClientImpl, productReviewsApiClient: ProductReviewsApiClientImpl, + storeExtrafieldsApiClient: StoreExtrafieldsApiClientImpl, ) : StoreProfileApiClient by storeProfileApiClient, ProductsApiClient by productsApiClient, @@ -92,7 +93,8 @@ open class ApiClient private constructor( SubscriptionsApiClient by subscriptionsApiClient, InstantSiteRedirectsApiClient by instantSiteRedirectsApiClient, SlugInfoApiClient by slugInfoApiClient, - ProductReviewsApiClient by productReviewsApiClient { + ProductReviewsApiClient by productReviewsApiClient, + StoreExtrafieldsApiClient by storeExtrafieldsApiClient { constructor(apiClientHelper: ApiClientHelper) : this( apiClientHelper = apiClientHelper, @@ -115,6 +117,7 @@ open class ApiClient private constructor( instantSiteRedirectsApiClient = InstantSiteRedirectsApiClientImpl(apiClientHelper), slugInfoApiClient = SlugInfoApiClientImpl(apiClientHelper), productReviewsApiClient = ProductReviewsApiClientImpl(apiClientHelper), + storeExtrafieldsApiClient = StoreExtrafieldsApiClientImpl(apiClientHelper), ) companion object { diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/StoreExtrafieldsApiClient.kt b/src/main/kotlin/com/ecwid/apiclient/v3/StoreExtrafieldsApiClient.kt new file mode 100644 index 000000000..cbc25de30 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/StoreExtrafieldsApiClient.kt @@ -0,0 +1,13 @@ +package com.ecwid.apiclient.v3 + +import com.ecwid.apiclient.v3.dto.extrafield.request.* +import com.ecwid.apiclient.v3.dto.extrafield.result.* + + +interface StoreExtrafieldsApiClient { + fun searchCustomersConfigs(request: CustomersConfigsSearchRequest): CustomersConfigsSearchResult + fun getCustomersConfig(request: CustomersConfigDetailsRequest): FetchedCustomersConfig + fun createCustomersConfig(request: CustomersConfigCreateRequest): CustomersConfigCreateResult + fun updateCustomersConfig(request: CustomersConfigUpdateRequest): CustomersConfigUpdateResult + fun deleteCustomersConfig(request: CustomersConfigDeleteRequest): CustomersConfigDeleteResult +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedCustomersConfig.kt b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedCustomersConfig.kt new file mode 100644 index 000000000..7fd20665e --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedCustomersConfig.kt @@ -0,0 +1,14 @@ +package com.ecwid.apiclient.v3.converter + +import com.ecwid.apiclient.v3.dto.extrafield.request.UpdatedCustomersConfig +import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig + + +fun FetchedCustomersConfig.toUpdated(): UpdatedCustomersConfig { + return UpdatedCustomersConfig( + key = key, + title = title, + type = type, + shownOnOrderDetails = shownOnOrderDetails, + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/request/UpdatedCustomer.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/request/UpdatedCustomer.kt index 7f9b37d35..b074b1f9b 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/request/UpdatedCustomer.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/request/UpdatedCustomer.kt @@ -4,6 +4,7 @@ import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName data class UpdatedCustomer( @@ -65,7 +66,7 @@ data class UpdatedCustomer( val key: String? = null, val title: String? = null, val value: String? = null, - val type: String? = null, + val type: ExtrafieldType? = null, ) override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCustomer::class) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/result/FetchedCustomer.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/result/FetchedCustomer.kt index 64aee8edc..0eb8e146f 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/result/FetchedCustomer.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/result/FetchedCustomer.kt @@ -4,9 +4,10 @@ import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme import com.ecwid.apiclient.v3.dto.customer.request.UpdatedCustomer +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldEntityType +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName import java.util.* -import kotlin.collections.ArrayList data class FetchedCustomer( val id: Int = 0, @@ -91,12 +92,12 @@ data class FetchedCustomer( ) data class CustomerExtrafield( - val key: String? = null, - val title: String? = null, - val value: String? = null, - val orderBy: Int = 0, - val type: String? = null, - val entityTypes: List = emptyList(), + val key: String? = null, + val title: String? = null, + val value: String? = null, + val orderBy: Int = 0, + val type: ExtrafieldType? = null, + val entityTypes: List = emptyList(), ) override fun getModifyKind() = ModifyKind.ReadWrite(UpdatedCustomer::class) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldEntityType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldEntityType.kt new file mode 100644 index 000000000..aeab6936c --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldEntityType.kt @@ -0,0 +1,6 @@ +package com.ecwid.apiclient.v3.dto.extrafield.enums + +enum class ExtrafieldEntityType { + CHECKOUT, + CUSTOMERS, +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ExtrafieldType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldType.kt similarity index 69% rename from src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ExtrafieldType.kt rename to src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldType.kt index 06de06240..b33010764 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ExtrafieldType.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldType.kt @@ -1,4 +1,4 @@ -package com.ecwid.apiclient.v3.dto.profile.enums +package com.ecwid.apiclient.v3.dto.extrafield.enums enum class ExtrafieldType { TEXT, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigCreateRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigCreateRequest.kt new file mode 100644 index 000000000..afb90e4e7 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigCreateRequest.kt @@ -0,0 +1,19 @@ +package com.ecwid.apiclient.v3.dto.extrafield.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.httptransport.HttpBody +import com.ecwid.apiclient.v3.impl.RequestInfo + +data class CustomersConfigCreateRequest( + val newConfig: UpdatedCustomersConfig = UpdatedCustomersConfig() +) : ApiRequest { + override fun toRequestInfo() = RequestInfo.createPostRequest( + pathSegments = listOf( + "store_extrafields", + "customers" + ), + httpBody = HttpBody.JsonBody( + obj = newConfig + ) + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDeleteRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDeleteRequest.kt new file mode 100644 index 000000000..720d72984 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDeleteRequest.kt @@ -0,0 +1,17 @@ +package com.ecwid.apiclient.v3.dto.extrafield.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.impl.RequestInfo + +data class CustomersConfigDeleteRequest( + val extrafieldKey: String = "" +) : ApiRequest { + override fun toRequestInfo() = RequestInfo.createDeleteRequest( + pathSegments = listOf( + "store_extrafields", + "customers", + extrafieldKey + ), + params = mapOf() + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDetailsRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDetailsRequest.kt new file mode 100644 index 000000000..b25344fb7 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigDetailsRequest.kt @@ -0,0 +1,20 @@ +package com.ecwid.apiclient.v3.dto.extrafield.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.impl.RequestInfo +import com.ecwid.apiclient.v3.responsefields.ResponseFields + +data class CustomersConfigDetailsRequest( + val extrafieldKey: String = "", + val responseFields: ResponseFields = ResponseFields.All, +) : ApiRequest { + override fun toRequestInfo() = RequestInfo.createGetRequest( + pathSegments = listOf( + "store_extrafields", + "customers", + extrafieldKey + ), + params = mapOf(), + responseFields = responseFields, + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigUpdateRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigUpdateRequest.kt new file mode 100644 index 000000000..2d684caeb --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigUpdateRequest.kt @@ -0,0 +1,21 @@ +package com.ecwid.apiclient.v3.dto.extrafield.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.httptransport.HttpBody +import com.ecwid.apiclient.v3.impl.RequestInfo + +data class CustomersConfigUpdateRequest( + val extrafieldKey: String = "", + val updatedConfig: UpdatedCustomersConfig = UpdatedCustomersConfig() +) : ApiRequest { + override fun toRequestInfo() = RequestInfo.createPutRequest( + pathSegments = listOf( + "store_extrafields", + "customers", + extrafieldKey + ), + httpBody = HttpBody.JsonBody( + obj = updatedConfig + ) + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigsSearchRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigsSearchRequest.kt new file mode 100644 index 000000000..15bd3d0a9 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/CustomersConfigsSearchRequest.kt @@ -0,0 +1,19 @@ +package com.ecwid.apiclient.v3.dto.extrafield.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.impl.RequestInfo +import com.ecwid.apiclient.v3.responsefields.ResponseFields + + +data class CustomersConfigsSearchRequest( + val responseFields: ResponseFields = ResponseFields.All, +) : ApiRequest { + override fun toRequestInfo() = RequestInfo.createGetRequest( + pathSegments = listOf( + "store_extrafields", + "customers" + ), + params = mapOf(), + responseFields = responseFields, + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/UpdatedCustomersConfig.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/UpdatedCustomersConfig.kt new file mode 100644 index 000000000..e56c4b68f --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/request/UpdatedCustomersConfig.kt @@ -0,0 +1,16 @@ +package com.ecwid.apiclient.v3.dto.extrafield.request + +import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO +import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType +import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig + +data class UpdatedCustomersConfig( + val key: String? = null, + val title: String? = null, + val type: ExtrafieldType? = null, + val shownOnOrderDetails: Boolean? = null, +) : ApiUpdatedDTO { + + override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCustomersConfig::class) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigCreateResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigCreateResult.kt new file mode 100644 index 000000000..f1ade57c7 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigCreateResult.kt @@ -0,0 +1,8 @@ +package com.ecwid.apiclient.v3.dto.extrafield.result + +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class CustomersConfigCreateResult( + val createCount: Int = 0, + val key: String = "" +) : ApiResultDTO diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigDeleteResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigDeleteResult.kt new file mode 100644 index 000000000..505e782b0 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigDeleteResult.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.extrafield.result + +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class CustomersConfigDeleteResult( + val deleteCount: Int = 0 +) : ApiResultDTO diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigUpdateResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigUpdateResult.kt new file mode 100644 index 000000000..284195248 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigUpdateResult.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.extrafield.result + +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class CustomersConfigUpdateResult( + val updateCount: Int = 0 +) : ApiResultDTO diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigsSearchResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigsSearchResult.kt new file mode 100644 index 000000000..58bfa93af --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/CustomersConfigsSearchResult.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.extrafield.result + +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class CustomersConfigsSearchResult( + val items: List = listOf(), +) : ApiResultDTO diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/FetchedCustomersConfig.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/FetchedCustomersConfig.kt new file mode 100644 index 000000000..1bd77f459 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/result/FetchedCustomersConfig.kt @@ -0,0 +1,20 @@ +package com.ecwid.apiclient.v3.dto.extrafield.result + +import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldEntityType +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType +import com.ecwid.apiclient.v3.dto.extrafield.request.UpdatedCustomersConfig +import java.util.* + +data class FetchedCustomersConfig( + val key: String? = null, + val title: String? = null, + val entityTypes: ExtrafieldEntityType? = null, + val type: ExtrafieldType? = null, + val shownOnOrderDetails: Boolean? = null, + val createdDate: Date? = null, + val lastModifiedDate: Date? = null, +) : ApiFetchedDTO { + + override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadWrite(UpdatedCustomersConfig::class) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/ExtrafieldConfigUpdateRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/ExtrafieldConfigUpdateRequest.kt index c5048d004..8589b925e 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/ExtrafieldConfigUpdateRequest.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/ExtrafieldConfigUpdateRequest.kt @@ -12,7 +12,7 @@ data class ExtrafieldConfigUpdateRequest( pathSegments = listOf( "profile", "extrafields", - "$extrafieldKey" + extrafieldKey ), httpBody = HttpBody.JsonBody( obj = updatedConfig diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedExtrafieldConfig.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedExtrafieldConfig.kt index 16d43cc46..a1ccf2613 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedExtrafieldConfig.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedExtrafieldConfig.kt @@ -3,38 +3,38 @@ package com.ecwid.apiclient.v3.dto.profile.request import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType import com.ecwid.apiclient.v3.dto.profile.enums.CheckoutDisplaySection -import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType import com.ecwid.apiclient.v3.dto.profile.enums.OrderDetailsDisplaySection import com.ecwid.apiclient.v3.dto.profile.enums.SurchargeType import com.ecwid.apiclient.v3.dto.profile.result.FetchedExtrafieldConfig data class UpdatedExtrafieldConfig( - val key: String? = null, - val title: String? = null, - val type: ExtrafieldType? = null, - val textPlaceholder: String? = null, - val tip: String? = null, - val options: List? = null, - val value: String? = null, - val available: Boolean? = null, - val required: Boolean? = null, - val checkoutDisplaySection: CheckoutDisplaySection? = null, - val orderDetailsDisplaySection: OrderDetailsDisplaySection? = null, - val showForCountry: List? = null, - val showForPaymentMethodIds: List? = null, - val showForShippingMethodIds: List? = null, - val showInInvoice: Boolean? = null, - val showInNotifications: Boolean? = null, - val orderBy: Int? = null, - val surchargeType: SurchargeType? = null, - val surchargeTaxable: Boolean? = null, - val showZeroSurchargeInTotal: Boolean? = null, - val surchargeShortName: UpdatedExtrafieldSurchargeConfig? = null, - val titleTranslated: LocalizedValueMap? = null, - val textPlaceholderTranslated: LocalizedValueMap? = null, - val tipTranslated: LocalizedValueMap? = null, - val valueTranslated: LocalizedValueMap? = null + val key: String? = null, + val title: String? = null, + val type: ExtrafieldType? = null, + val textPlaceholder: String? = null, + val tip: String? = null, + val options: List? = null, + val value: String? = null, + val available: Boolean? = null, + val required: Boolean? = null, + val checkoutDisplaySection: CheckoutDisplaySection? = null, + val orderDetailsDisplaySection: OrderDetailsDisplaySection? = null, + val showForCountry: List? = null, + val showForPaymentMethodIds: List? = null, + val showForShippingMethodIds: List? = null, + val showInInvoice: Boolean? = null, + val showInNotifications: Boolean? = null, + val orderBy: Int? = null, + val surchargeType: SurchargeType? = null, + val surchargeTaxable: Boolean? = null, + val showZeroSurchargeInTotal: Boolean? = null, + val surchargeShortName: UpdatedExtrafieldSurchargeConfig? = null, + val titleTranslated: LocalizedValueMap? = null, + val textPlaceholderTranslated: LocalizedValueMap? = null, + val tipTranslated: LocalizedValueMap? = null, + val valueTranslated: LocalizedValueMap? = null ) : ApiUpdatedDTO { data class UpdatedExtrafieldOptionConfig( diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedExtrafieldConfig.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedExtrafieldConfig.kt index d80480e5c..d5b3f77cb 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedExtrafieldConfig.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedExtrafieldConfig.kt @@ -3,8 +3,8 @@ package com.ecwid.apiclient.v3.dto.profile.result import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap +import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType import com.ecwid.apiclient.v3.dto.profile.enums.CheckoutDisplaySection -import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType import com.ecwid.apiclient.v3.dto.profile.enums.OrderDetailsDisplaySection import com.ecwid.apiclient.v3.dto.profile.enums.SurchargeType import com.ecwid.apiclient.v3.dto.profile.request.UpdatedExtrafieldConfig diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreExtrafieldsApiClientImpl.kt b/src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreExtrafieldsApiClientImpl.kt new file mode 100644 index 000000000..4c11fc7a2 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreExtrafieldsApiClientImpl.kt @@ -0,0 +1,26 @@ +package com.ecwid.apiclient.v3.impl + +import com.ecwid.apiclient.v3.ApiClientHelper +import com.ecwid.apiclient.v3.StoreExtrafieldsApiClient +import com.ecwid.apiclient.v3.dto.extrafield.request.* +import com.ecwid.apiclient.v3.dto.extrafield.result.* + +internal class StoreExtrafieldsApiClientImpl( + private val apiClientHelper: ApiClientHelper +) : StoreExtrafieldsApiClient { + + override fun searchCustomersConfigs(request: CustomersConfigsSearchRequest): CustomersConfigsSearchResult = + apiClientHelper.makeObjectResultRequest(request) + + override fun getCustomersConfig(request: CustomersConfigDetailsRequest): FetchedCustomersConfig = + apiClientHelper.makeObjectResultRequest(request) + + override fun createCustomersConfig(request: CustomersConfigCreateRequest): CustomersConfigCreateResult = + apiClientHelper.makeObjectResultRequest(request) + + override fun updateCustomersConfig(request: CustomersConfigUpdateRequest): CustomersConfigUpdateResult = + apiClientHelper.makeObjectResultRequest(request) + + override fun deleteCustomersConfig(request: CustomersConfigDeleteRequest): CustomersConfigDeleteResult = + apiClientHelper.makeObjectResultRequest(request) +} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt index f3a663542..7484c0172 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt @@ -5,6 +5,7 @@ import com.ecwid.apiclient.v3.dto.category.result.FetchedCategory import com.ecwid.apiclient.v3.dto.coupon.result.FetchedCoupon import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer import com.ecwid.apiclient.v3.dto.customergroup.result.FetchedCustomerGroup +import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig import com.ecwid.apiclient.v3.dto.instantsite.redirects.result.FetchedInstantSiteRedirect import com.ecwid.apiclient.v3.dto.order.result.FetchedOrder import com.ecwid.apiclient.v3.dto.product.result.FetchedProduct @@ -323,6 +324,10 @@ val nonUpdatablePropertyRules: List> = listOf( ReadOnly(FetchedOrderStatusSettings::lastNameChangeDate), ReadOnly(FetchedInstantSiteRedirect::id), + + ReadOnly(FetchedCustomersConfig::entityTypes), + ReadOnly(FetchedCustomersConfig::createdDate), + ReadOnly(FetchedCustomersConfig::lastModifiedDate), ) sealed class NonUpdatablePropertyRule( 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 b8fd414bd..5054d9647 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt @@ -186,6 +186,7 @@ val nullablePropertyRules: List> = listOf( fetchedProductReviewNullablePropertyRules, productReviewMassUpdateRequestNullablePropertyRules, productReviewSearchRequestNullablePropertyRules, + fetchedCustomersConfigNullablePropertyRules, ).flatten() sealed class NullablePropertyRule( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt new file mode 100644 index 000000000..5f4f7d4da --- /dev/null +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt @@ -0,0 +1,15 @@ +package com.ecwid.apiclient.v3.rule.nullablepropertyrules + +import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig +import com.ecwid.apiclient.v3.rule.NullablePropertyRule +import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable + +val fetchedCustomersConfigNullablePropertyRules: List> = listOf( + AllowNullable(FetchedCustomersConfig::key), + AllowNullable(FetchedCustomersConfig::title), + AllowNullable(FetchedCustomersConfig::entityTypes), + AllowNullable(FetchedCustomersConfig::type), + AllowNullable(FetchedCustomersConfig::shownOnOrderDetails), + AllowNullable(FetchedCustomersConfig::createdDate), + AllowNullable(FetchedCustomersConfig::lastModifiedDate), +)