Class CustomerUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.customers.utils.CustomerUpdateActionUtils
-
public final class CustomerUpdateActionUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CUSTOMER_NUMBER_EXISTS_WARNING
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildAddAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildAddBillingAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddressIds()
()} and aCustomerDraft.getBillingAddresses()
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildAddShippingAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddressIds()
and aCustomerDraft.getShippingAddresses()
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildAddStoreUpdateActions(java.util.List<com.commercetools.api.models.store.StoreKeyReference> oldStores, java.util.List<com.commercetools.api.models.store.StoreResourceIdentifier> newStores)
Compares theList
ofStoreKeyReference
s andStoreResourceIdentifier
s of aCustomerDraft
and aCustomer
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildAllAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares the addresses of aCustomer
and aCustomerDraft
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildChangeAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildChangeEmailUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theemail
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"changeEmail"
CustomerChangeEmailAction
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildRemoveAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildRemoveBillingAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddressIds()
()} and aCustomerDraft.getBillingAddresses()
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildRemoveShippingAddressUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddressIds()
and aCustomerDraft.getShippingAddresses()
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildRemoveStoreUpdateActions(java.util.List<com.commercetools.api.models.store.StoreKeyReference> oldStores, java.util.List<com.commercetools.api.models.store.StoreResourceIdentifier> newStores)
Compares theList
ofStoreKeyReference
s andStoreResourceIdentifier
s of aCustomerDraft
and aCustomer
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetCompanyNameUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thecompanyName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCompanyName"
CustomerSetCompanyNameAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetCustomerGroupUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theCustomerGroup
references of an oldCustomer
and newCustomerDraft
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetCustomerNumberUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer, CustomerSyncOptions syncOptions)
Compares thecustomerNumber
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCustomerNumber"
CustomerSetCustomerNumberAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetDateOfBirthUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thedateOfBirth
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setDateOfBirth"
CustomerSetDateOfBirthAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetDefaultBillingAddressUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theCustomer.getDefaultBillingAddressId()
andCustomerDraft.getDefaultBillingAddress()
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetDefaultShippingAddressUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theCustomer.getDefaultShippingAddressId()
andCustomerDraft.getDefaultShippingAddress()
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetExternalIdUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theexternalId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setExternalId"
CustomerSetExternalIdAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetFirstNameUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thefirstName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setFirstName"
CustomerSetFirstNameAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetLastNameUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thelastName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLastName"
CustomerSetLastNameAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetLocaleUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thelocale
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLocale"
CustomerSetLocaleAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetMiddleNameUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares themiddleName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setMiddleName"
CustomerSetMiddleNameAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetSalutationUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thesalutation
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"SetSalutation"
CustomerSetSalutationAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetTitleUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thetitle
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setTitle"
CustomerSetTitleAction
.static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction>
buildSetVatIdUpdateAction(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thevatId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setVatId"
CustomerSetVatIdAction
.static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction>
buildStoreUpdateActions(com.commercetools.api.models.customer.Customer oldCustomer, com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares the stores of aCustomer
and aCustomerDraft
.
-
-
-
Field Detail
-
CUSTOMER_NUMBER_EXISTS_WARNING
public static final java.lang.String CUSTOMER_NUMBER_EXISTS_WARNING
- See Also:
- Constant Field Values
-
-
Method Detail
-
buildChangeEmailUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildChangeEmailUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theemail
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"changeEmail"
CustomerChangeEmailAction
. If bothCustomer
andCustomerDraft
have the sameemail
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new email.- Returns:
- optional containing update action or empty optional if emails are identical.
-
buildSetFirstNameUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetFirstNameUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thefirstName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setFirstName"
CustomerSetFirstNameAction
. If bothCustomer
andCustomerDraft
have the samefirstName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new first name.- Returns:
- optional containing update action or empty optional if first names are identical.
-
buildSetLastNameUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetLastNameUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thelastName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLastName"
CustomerSetLastNameAction
. If bothCustomer
andCustomerDraft
have the samelastName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new last name.- Returns:
- optional containing update action or empty optional if last names are identical.
-
buildSetMiddleNameUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetMiddleNameUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares themiddleName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setMiddleName"
CustomerSetMiddleNameAction
. If bothCustomer
andCustomerDraft
have the samemiddleName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new middle name.- Returns:
- optional containing update action or empty optional if middle names are identical.
-
buildSetTitleUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetTitleUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thetitle
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setTitle"
CustomerSetTitleAction
. If bothCustomer
andCustomerDraft
have the sametitle
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new title.- Returns:
- optional containing update action or empty optional if titles are identical.
-
buildSetSalutationUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetSalutationUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thesalutation
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"SetSalutation"
CustomerSetSalutationAction
. If bothCustomer
andCustomerDraft
have the samesalutation
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the Customer that should be updated.newCustomer
- the Customer draft that contains the new salutation.- Returns:
- optional containing update action or empty optional if salutations are identical.
-
buildSetCustomerNumberUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetCustomerNumberUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer, @Nonnull CustomerSyncOptions syncOptions)
Compares thecustomerNumber
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCustomerNumber"
CustomerSetCustomerNumberAction
. If bothCustomer
andCustomerDraft
have the samecustomerNumber
values, then no update action is needed and empty optional will be returned.Note: Customer number should be unique across a project. Once it's set it cannot be changed. For this case, warning callback will be triggered and an empty optional will be returned.
- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new customer number.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the warning callback when trying to change an existing customer number.- Returns:
- optional containing update action or empty optional if customer numbers are identical.
-
buildSetExternalIdUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetExternalIdUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theexternalId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setExternalId"
CustomerSetExternalIdAction
. If bothCustomer
andCustomerDraft
have the sameexternalId
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new external id.- Returns:
- optional containing update action or empty optional if external ids are identical.
-
buildSetCompanyNameUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetCompanyNameUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thecompanyName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCompanyName"
CustomerSetCompanyNameAction
. If bothCustomer
andCustomerDraft
have the samecompanyName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new company name.- Returns:
- optional containing update action or empty optional if company names are identical.
-
buildSetDateOfBirthUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetDateOfBirthUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thedateOfBirth
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setDateOfBirth"
CustomerSetDateOfBirthAction
. If bothCustomer
andCustomerDraft
have the samedateOfBirth
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new date of birth.- Returns:
- optional containing update action or empty optional if dates of birth are identical.
-
buildSetVatIdUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetVatIdUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thevatId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setVatId"
CustomerSetVatIdAction
. If bothCustomer
andCustomerDraft
have the samevatId
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new vat id.- Returns:
- optional containing update action or empty optional if vat ids are identical.
-
buildSetLocaleUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetLocaleUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares thelocale
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLocale"
CustomerSetLocaleAction
. If bothCustomer
andCustomerDraft
have the samelocale
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new locale.- Returns:
- optional containing update action or empty optional if locales are identical.
-
buildSetCustomerGroupUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetCustomerGroupUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theCustomerGroup
references of an oldCustomer
and newCustomerDraft
. If they are different - returnCustomerSetCustomerGroupAction
update action.If the old value is set, but the new one is empty - the command will unset the customer group.
- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft with newCustomerGroup
reference.- Returns:
- An optional with
CustomerUpdateAction
update action.
-
buildStoreUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildStoreUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares the stores of aCustomer
and aCustomerDraft
. It returns aList
ofCustomerUpdateAction
as a result. If no update action is needed, for example in case where both theCustomer
and theCustomerDraft
have the identical stores, an emptyList
is returned.Note: Null values of the stores are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new data.- Returns:
- A list of customer store-related update actions.
-
buildRemoveStoreUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildRemoveStoreUpdateActions(@Nonnull java.util.List<com.commercetools.api.models.store.StoreKeyReference> oldStores, @Nonnull java.util.List<com.commercetools.api.models.store.StoreResourceIdentifier> newStores)
Compares theList
ofStoreKeyReference
s andStoreResourceIdentifier
s of aCustomerDraft
and aCustomer
. It returns aList
ofCustomerRemoveStoreAction
update actions as a result, if the old store needs to be removed from a customer to have the same set of stores as the new customer. If both theCustomer
and theCustomerDraft
have the same set of stores, then no update actions are needed and hence an emptyList
is returned.Note: Null values of the stores are filtered out.
- Parameters:
oldStores
- the stores which should be updated.newStores
- the stores where we get the new store.- Returns:
- A list containing the update actions or an empty list if the store references are identical.
-
buildAddStoreUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildAddStoreUpdateActions(@Nonnull java.util.List<com.commercetools.api.models.store.StoreKeyReference> oldStores, @Nonnull java.util.List<com.commercetools.api.models.store.StoreResourceIdentifier> newStores)
Compares theList
ofStoreKeyReference
s andStoreResourceIdentifier
s of aCustomerDraft
and aCustomer
. It returns aList
ofCustomerAddStoreAction
update actions as a result, if the old store needs to be added to a customer to have the same set of stores as the new customer. If both theCustomer
and theCustomerDraft
have the same set of stores, then no update actions are needed and hence an emptyList
is returned.Note: Null values of the stores are filtered out.
- Parameters:
oldStores
- the stores which should be updated.newStores
- the stores where we get the new store.- Returns:
- A list containing the update actions or an empty list if the store references are identical.
-
buildAllAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildAllAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares the addresses of aCustomer
and aCustomerDraft
. It returns aList
ofCustomerUpdateAction
as a result. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new data.- Returns:
- A list of customer address-related update actions.
-
buildRemoveAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildRemoveAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
. It returns aList
ofCustomerRemoveAddressAction
update actions as a result, if the old address needs to be removed from theoldCustomer
to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the new addresses are filtered out.
- Address values without keys are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new addresses.- Returns:
- A list containing the update actions or an empty list if the addresses are identical.
-
buildChangeAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildChangeAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
. It returns aList
ofCustomerChangeAddressAction
update actions as a result, if the old address needs to be changed/updated from theoldCustomer
to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the new addresses are filtered out.
- Address values without keys are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new addresses.- Returns:
- A list containing the update actions or an empty list if the addresses are identical.
-
buildAddAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildAddAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
. It returns aList
ofCustomerAddAddressAction
update actions as a result, if the new address needs to be added to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the new addresses are filtered out.
- Address values without keys are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new addresses.- Returns:
- A list containing the update actions or an empty list if the addresses are identical.
-
buildSetDefaultShippingAddressUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetDefaultShippingAddressUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theCustomer.getDefaultShippingAddressId()
andCustomerDraft.getDefaultShippingAddress()
. If they are different - returnCustomerSetDefaultShippingAddressAction
update action. If the old shipping address is set, but the new one is empty - the command will unset the default shipping address.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft with new default shipping address.- Returns:
- An optional with
CustomerSetDefaultShippingAddressAction
update action.
-
buildSetDefaultBillingAddressUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.customer.CustomerUpdateAction> buildSetDefaultBillingAddressUpdateAction(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theCustomer.getDefaultBillingAddressId()
andCustomerDraft.getDefaultBillingAddress()
. If they are different - returnCustomerSetDefaultBillingAddressAction
update action. If the old billing address id value is set, but the new one is empty - the command will unset the default billing address.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft with new default billing address.- Returns:
- An optional with
CustomerSetDefaultBillingAddressAction
update action.
-
buildAddShippingAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildAddShippingAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddressIds()
and aCustomerDraft.getShippingAddresses()
. It returns aList
ofCustomerAddShippingAddressIdAction
update actions as a result, if the new shipping address needs to be added to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of shipping addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Old address values without keys are filtered out.
- Each address in the new addresses list satisfies the following conditions:
- It is not null
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new shipping addresses.- Returns:
- A list containing the update actions or an empty list if the shipping addresses are identical.
-
buildRemoveShippingAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildRemoveShippingAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddressIds()
and aCustomerDraft.getShippingAddresses()
. It returns aList
ofCustomerRemoveShippingAddressIdAction
update actions as a result, if the old shipping address needs to be removed to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of shipping addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Old shipping addresses without keys will be removed.
- Each address in the new addresses list satisfies the following conditions:
- It exists in the given index.
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new shipping addresses.- Returns:
- A list containing the update actions or an empty list if the shipping addresses are identical.
-
buildAddBillingAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildAddBillingAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddressIds()
()} and aCustomerDraft.getBillingAddresses()
. It returns aList
ofCustomerAddBillingAddressIdAction
update actions as a result, if the new billing address needs to be added to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of billing addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Old address values without keys are filtered out.
- Each address in the new addresses list satisfies the following conditions:
- It is not null
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new billing addresses.- Returns:
- A list containing the update actions or an empty list if the billing addresses are identical.
-
buildRemoveBillingAddressUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.customer.CustomerUpdateAction> buildRemoveBillingAddressUpdateActions(@Nonnull com.commercetools.api.models.customer.Customer oldCustomer, @Nonnull com.commercetools.api.models.customer.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddressIds()
()} and aCustomerDraft.getBillingAddresses()
. It returns aList
ofCustomerRemoveBillingAddressIdAction
update actions as a result, if the old billing address needs to be removed to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of billing addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the old addresses are filtered out.
- Old shipping address values without keys are filtered out.
- Each address in the new addresses list satisfies the following conditions:
- It exists in the given index.
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new shipping addresses.- Returns:
- A list containing the update actions or an empty list if the shipping addresses are identical.
-
-