Skip to content

Commit

Permalink
Merge pull request #354 from Ecwid/ECWID-130642
Browse files Browse the repository at this point in the history
ECWID-130642 New customers: internal API for updating customers
  • Loading branch information
winrokru authored Nov 30, 2023
2 parents 0063a6e + 03cadf1 commit 277643b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fun FetchedCustomer.toUpdated(): UpdatedCustomer {
customerGroupId = customerGroupId,
billingPerson = billingPerson?.toUpdated(),
shippingAddresses = shippingAddresses?.map(FetchedCustomer.ShippingAddress::toUpdated),
contacts = contacts?.map(FetchedCustomer.CustomerContact::toUpdated),
taxId = taxId,
taxIdValid = taxIdValid,
taxExempt = taxExempt,
Expand Down Expand Up @@ -48,3 +49,15 @@ fun FetchedCustomer.ShippingAddress.toUpdated(): UpdatedCustomer.ShippingAddress
orderBy = orderBy,
)
}

fun FetchedCustomer.CustomerContact.toUpdated(): UpdatedCustomer.CustomerContact {
return UpdatedCustomer.CustomerContact(
id = id,
contact = contact,
handle = handle,
note = note,
type = type,
default = default,
orderBy = orderBy,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data class UpdatedCustomer(
val customerGroupId: Int? = null,
val billingPerson: BillingPerson? = null,
val shippingAddresses: List<ShippingAddress>? = null,
val contacts: List<CustomerContact>? = null,
val taxId: String? = null,
val taxIdValid: Boolean? = null,
val taxExempt: Boolean? = null,
Expand Down Expand Up @@ -49,5 +50,15 @@ data class UpdatedCustomer(
val orderBy: Int? = null,
)

data class CustomerContact(
val id: Long? = null,
val contact: String? = null,
val handle: String? = null,
val note: String? = null,
val type: String? = null,
val default: Boolean? = null,
val orderBy: Int? = null,
)

override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCustomer::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ val nonUpdatablePropertyRules: List<NonUpdatablePropertyRule<*, *>> = listOf(
Ignored(FetchedCustomer.ShippingAddress::stateOrProvinceName),
ReadOnly(FetchedCustomer.ShippingAddress::createdDate),
ReadOnly(FetchedCustomer::stats),
ReadOnly(FetchedCustomer::contacts),
ReadOnly(FetchedCustomer.CustomerContact::timestamp),

ReadOnly(FetchedCustomerGroup::id),

Expand Down

0 comments on commit 277643b

Please sign in to comment.