Skip to content

Commit 48207bf

Browse files
committed
ECWID-144507 New customer extrafields
1 parent 13b770f commit 48207bf

5 files changed

Lines changed: 35 additions & 0 deletions

File tree

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+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ data class UpdatedCustomer(
1919
val acceptMarketing: Boolean? = null,
2020
val lang: String? = null,
2121
val privateAdminNotes: String? = null,
22+
val extrafields: List<CustomerExtrafield>? = null,
2223

2324
@JsonFieldName("b2b_b2c")
2425
val commercialRelationshipScheme: CommercialRelationshipScheme? = null,
@@ -60,5 +61,12 @@ data class UpdatedCustomer(
6061
val orderBy: Int? = null,
6162
)
6263

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

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ data class FetchedCustomer(
2626
val stats: CustomerStats? = null,
2727
val privateAdminNotes: String? = null,
2828
val favorites: List<CustomerFavorite> = ArrayList(),
29+
val extrafields: List<CustomerExtrafield>? = null,
2930

3031
@JsonFieldName("b2b_b2c")
3132
val commercialRelationshipScheme: CommercialRelationshipScheme = CommercialRelationshipScheme.b2c,
@@ -89,5 +90,14 @@ data class FetchedCustomer(
8990
val addedTimestamp: Date? = null,
9091
)
9192

93+
data class CustomerExtrafield(
94+
val key: String? = null,
95+
val title: String? = null,
96+
val value: String? = null,
97+
val orderBy: Int = 0,
98+
val type: String? = null,
99+
val entityTypes: List<String> = emptyList(),
100+
)
101+
92102
override fun getModifyKind() = ModifyKind.ReadWrite(UpdatedCustomer::class)
93103
}

src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ val nonUpdatablePropertyRules: List<NonUpdatablePropertyRule<*, *>> = listOf(
161161
ReadOnly(FetchedCustomer::favorites),
162162
ReadOnly(FetchedCustomer.CustomerFavorite::productId),
163163
ReadOnly(FetchedCustomer.CustomerFavorite::addedTimestamp),
164+
ReadOnly(FetchedCustomer.CustomerExtrafield::entityTypes),
165+
ReadOnly(FetchedCustomer.CustomerExtrafield::orderBy),
164166

165167
ReadOnly(FetchedCustomerGroup::id),
166168

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ val fetchedCustomerNullablePropertyRules: List<NullablePropertyRule<*, *>> = lis
5555
AllowNullable(FetchedCustomer.CustomerContact::note),
5656
AllowNullable(FetchedCustomer.CustomerContact::timestamp),
5757
AllowNullable(FetchedCustomer.CustomerFavorite::addedTimestamp),
58+
AllowNullable(FetchedCustomer::extrafields),
59+
AllowNullable(FetchedCustomer.CustomerExtrafield::key),
60+
AllowNullable(FetchedCustomer.CustomerExtrafield::title),
61+
AllowNullable(FetchedCustomer.CustomerExtrafield::value),
62+
AllowNullable(FetchedCustomer.CustomerExtrafield::type),
5863

5964
AllowNullable(CustomerFilterShippingAddress::street),
6065
AllowNullable(CustomerFilterShippingAddress::city),

0 commit comments

Comments
 (0)