Skip to content

Commit 277643b

Browse files
authored
Merge pull request #354 from Ecwid/ECWID-130642
ECWID-130642 New customers: internal API for updating customers
2 parents 0063a6e + 03cadf1 commit 277643b

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fun FetchedCustomer.toUpdated(): UpdatedCustomer {
99
customerGroupId = customerGroupId,
1010
billingPerson = billingPerson?.toUpdated(),
1111
shippingAddresses = shippingAddresses?.map(FetchedCustomer.ShippingAddress::toUpdated),
12+
contacts = contacts?.map(FetchedCustomer.CustomerContact::toUpdated),
1213
taxId = taxId,
1314
taxIdValid = taxIdValid,
1415
taxExempt = taxExempt,
@@ -48,3 +49,15 @@ fun FetchedCustomer.ShippingAddress.toUpdated(): UpdatedCustomer.ShippingAddress
4849
orderBy = orderBy,
4950
)
5051
}
52+
53+
fun FetchedCustomer.CustomerContact.toUpdated(): UpdatedCustomer.CustomerContact {
54+
return UpdatedCustomer.CustomerContact(
55+
id = id,
56+
contact = contact,
57+
handle = handle,
58+
note = note,
59+
type = type,
60+
default = default,
61+
orderBy = orderBy,
62+
)
63+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ data class UpdatedCustomer(
1212
val customerGroupId: Int? = null,
1313
val billingPerson: BillingPerson? = null,
1414
val shippingAddresses: List<ShippingAddress>? = null,
15+
val contacts: List<CustomerContact>? = null,
1516
val taxId: String? = null,
1617
val taxIdValid: Boolean? = null,
1718
val taxExempt: Boolean? = null,
@@ -49,5 +50,15 @@ data class UpdatedCustomer(
4950
val orderBy: Int? = null,
5051
)
5152

53+
data class CustomerContact(
54+
val id: Long? = null,
55+
val contact: String? = null,
56+
val handle: String? = null,
57+
val note: String? = null,
58+
val type: String? = null,
59+
val default: Boolean? = null,
60+
val orderBy: Int? = null,
61+
)
62+
5263
override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCustomer::class)
5364
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ val nonUpdatablePropertyRules: List<NonUpdatablePropertyRule<*, *>> = listOf(
142142
Ignored(FetchedCustomer.ShippingAddress::stateOrProvinceName),
143143
ReadOnly(FetchedCustomer.ShippingAddress::createdDate),
144144
ReadOnly(FetchedCustomer::stats),
145-
ReadOnly(FetchedCustomer::contacts),
145+
ReadOnly(FetchedCustomer.CustomerContact::timestamp),
146146

147147
ReadOnly(FetchedCustomerGroup::id),
148148

0 commit comments

Comments
 (0)