Skip to content

Commit f2d7ef1

Browse files
authored
Merge pull request #422 from Ecwid/ECWID-144507
ECWID-144507 New customer extrafields
2 parents 13b770f + c188d1a commit f2d7ef1

29 files changed

Lines changed: 312 additions & 31 deletions

.DS_Store

8 KB
Binary file not shown.

src/.DS_Store

6 KB
Binary file not shown.

src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ open class ApiClient private constructor(
7373
instantSiteRedirectsApiClient: InstantSiteRedirectsApiClientImpl,
7474
slugInfoApiClient: SlugInfoApiClientImpl,
7575
productReviewsApiClient: ProductReviewsApiClientImpl,
76+
storeExtrafieldsApiClient: StoreExtrafieldsApiClientImpl,
7677
) :
7778
StoreProfileApiClient by storeProfileApiClient,
7879
ProductsApiClient by productsApiClient,
@@ -92,7 +93,8 @@ open class ApiClient private constructor(
9293
SubscriptionsApiClient by subscriptionsApiClient,
9394
InstantSiteRedirectsApiClient by instantSiteRedirectsApiClient,
9495
SlugInfoApiClient by slugInfoApiClient,
95-
ProductReviewsApiClient by productReviewsApiClient {
96+
ProductReviewsApiClient by productReviewsApiClient,
97+
StoreExtrafieldsApiClient by storeExtrafieldsApiClient {
9698

9799
constructor(apiClientHelper: ApiClientHelper) : this(
98100
apiClientHelper = apiClientHelper,
@@ -115,6 +117,7 @@ open class ApiClient private constructor(
115117
instantSiteRedirectsApiClient = InstantSiteRedirectsApiClientImpl(apiClientHelper),
116118
slugInfoApiClient = SlugInfoApiClientImpl(apiClientHelper),
117119
productReviewsApiClient = ProductReviewsApiClientImpl(apiClientHelper),
120+
storeExtrafieldsApiClient = StoreExtrafieldsApiClientImpl(apiClientHelper),
118121
)
119122

120123
companion object {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.ecwid.apiclient.v3
2+
3+
import com.ecwid.apiclient.v3.dto.extrafield.request.*
4+
import com.ecwid.apiclient.v3.dto.extrafield.result.*
5+
6+
7+
interface StoreExtrafieldsApiClient {
8+
fun searchCustomersConfigs(request: CustomersConfigsSearchRequest): CustomersConfigsSearchResult
9+
fun getCustomersConfig(request: CustomersConfigDetailsRequest): FetchedCustomersConfig
10+
fun createCustomersConfig(request: CustomersConfigCreateRequest): CustomersConfigCreateResult
11+
fun updateCustomersConfig(request: CustomersConfigUpdateRequest): CustomersConfigUpdateResult
12+
fun deleteCustomersConfig(request: CustomersConfigDeleteRequest): CustomersConfigDeleteResult
13+
}

src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedCustomer.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fun FetchedCustomer.toUpdated(): UpdatedCustomer {
1717
lang = lang,
1818
privateAdminNotes = privateAdminNotes,
1919
commercialRelationshipScheme = commercialRelationshipScheme,
20+
extrafields = extrafields?.map(FetchedCustomer.CustomerExtrafield::toUpdated)
2021
)
2122
}
2223

@@ -61,3 +62,12 @@ fun FetchedCustomer.CustomerContact.toUpdated(): UpdatedCustomer.CustomerContact
6162
orderBy = orderBy,
6263
)
6364
}
65+
66+
fun FetchedCustomer.CustomerExtrafield.toUpdated(): UpdatedCustomer.CustomerExtrafield {
67+
return UpdatedCustomer.CustomerExtrafield(
68+
key = key,
69+
title = title,
70+
value = value,
71+
type = type,
72+
)
73+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.ecwid.apiclient.v3.converter
2+
3+
import com.ecwid.apiclient.v3.dto.extrafield.request.UpdatedCustomersConfig
4+
import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig
5+
6+
7+
fun FetchedCustomersConfig.toUpdated(): UpdatedCustomersConfig {
8+
return UpdatedCustomersConfig(
9+
key = key,
10+
title = title,
11+
type = type,
12+
shownOnOrderDetails = shownOnOrderDetails,
13+
)
14+
}

src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/request/UpdatedCustomer.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO
44
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind
55
import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme
66
import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer
7+
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
78
import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName
89

910
data class UpdatedCustomer(
@@ -19,6 +20,7 @@ data class UpdatedCustomer(
1920
val acceptMarketing: Boolean? = null,
2021
val lang: String? = null,
2122
val privateAdminNotes: String? = null,
23+
val extrafields: List<CustomerExtrafield>? = null,
2224

2325
@JsonFieldName("b2b_b2c")
2426
val commercialRelationshipScheme: CommercialRelationshipScheme? = null,
@@ -60,5 +62,12 @@ data class UpdatedCustomer(
6062
val orderBy: Int? = null,
6163
)
6264

65+
data class CustomerExtrafield(
66+
val key: String? = null,
67+
val title: String? = null,
68+
val value: String? = null,
69+
val type: ExtrafieldType? = null,
70+
)
71+
6372
override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCustomer::class)
6473
}

src/main/kotlin/com/ecwid/apiclient/v3/dto/customer/result/FetchedCustomer.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
44
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind
55
import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme
66
import com.ecwid.apiclient.v3.dto.customer.request.UpdatedCustomer
7+
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldEntityType
8+
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
79
import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName
810
import java.util.*
9-
import kotlin.collections.ArrayList
1011

1112
data class FetchedCustomer(
1213
val id: Int = 0,
@@ -26,6 +27,7 @@ data class FetchedCustomer(
2627
val stats: CustomerStats? = null,
2728
val privateAdminNotes: String? = null,
2829
val favorites: List<CustomerFavorite> = ArrayList(),
30+
val extrafields: List<CustomerExtrafield>? = null,
2931

3032
@JsonFieldName("b2b_b2c")
3133
val commercialRelationshipScheme: CommercialRelationshipScheme = CommercialRelationshipScheme.b2c,
@@ -89,5 +91,14 @@ data class FetchedCustomer(
8991
val addedTimestamp: Date? = null,
9092
)
9193

94+
data class CustomerExtrafield(
95+
val key: String? = null,
96+
val title: String? = null,
97+
val value: String? = null,
98+
val orderBy: Int = 0,
99+
val type: ExtrafieldType? = null,
100+
val entityTypes: List<ExtrafieldEntityType> = emptyList(),
101+
)
102+
92103
override fun getModifyKind() = ModifyKind.ReadWrite(UpdatedCustomer::class)
93104
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.ecwid.apiclient.v3.dto.extrafield.enums
2+
3+
enum class ExtrafieldEntityType {
4+
CHECKOUT,
5+
CUSTOMERS,
6+
}

src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ExtrafieldType.kt renamed to src/main/kotlin/com/ecwid/apiclient/v3/dto/extrafield/enums/ExtrafieldType.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.ecwid.apiclient.v3.dto.profile.enums
1+
package com.ecwid.apiclient.v3.dto.extrafield.enums
22

33
enum class ExtrafieldType {
44
TEXT,

0 commit comments

Comments
 (0)