Class CustomerDraftBuilder

java.lang.Object
com.commercetools.api.models.customer.CustomerDraftBuilder
All Implemented Interfaces:
Builder<CustomerDraft>

public class CustomerDraftBuilder extends Object implements Builder<CustomerDraft>
CustomerDraftBuilder
Example to create an instance using the builder pattern

     CustomerDraft customerDraft = CustomerDraft.builder()
             .email("{email}")
             .build()
 
  • Constructor Details

    • CustomerDraftBuilder

      public CustomerDraftBuilder()
  • Method Details

    • key

      User-defined unique identifier for the Customer. The key field is preferred over customerNumber as it is mutable and provides more flexibility.

      This field is optional for backwards compatibility reasons, but we strongly recommend setting it. Keys are mandatory for importing Customers with the Import API.

      Parameters:
      key - value to be set
      Returns:
      Builder
    • customerNumber

      public CustomerDraftBuilder customerNumber(@Nullable String customerNumber)

      User-defined unique identifier for a Customer. Once set, it cannot be changed.

      Can be used to refer to a Customer in a human-readable way (in emails, invoices, and other correspondence).

      Parameters:
      customerNumber - value to be set
      Returns:
      Builder
    • externalId

      public CustomerDraftBuilder externalId(@Nullable String externalId)

      Optional identifier for use in external systems like customer relationship management (CRM) or enterprise resource planning (ERP).

      Parameters:
      externalId - value to be set
      Returns:
      Builder
    • email

      public CustomerDraftBuilder email(String email)

      Email address of the Customer that must be unique for an entire Project or to a Store the Customer is assigned to. It is the mandatory unique identifier of a Customer.

      Parameters:
      email - value to be set
      Returns:
      Builder
    • password

      public CustomerDraftBuilder password(@Nullable String password)

      Required when authenticationMode is set to Password. Provide the Customer's password in plain text. The API stores passwords in an encrypted format.

      Parameters:
      password - value to be set
      Returns:
      Builder
    • firstName

      public CustomerDraftBuilder firstName(@Nullable String firstName)

      Given name (first name) of the Customer.

      Parameters:
      firstName - value to be set
      Returns:
      Builder
    • lastName

      public CustomerDraftBuilder lastName(@Nullable String lastName)

      Family name (last name) of the Customer.

      Parameters:
      lastName - value to be set
      Returns:
      Builder
    • middleName

      public CustomerDraftBuilder middleName(@Nullable String middleName)

      Middle name of the Customer.

      Parameters:
      middleName - value to be set
      Returns:
      Builder
    • title

      public CustomerDraftBuilder title(@Nullable String title)

      Title of the Customer, for example, 'Dr.'.

      Parameters:
      title - value to be set
      Returns:
      Builder
    • anonymousCartId

      @Deprecated public CustomerDraftBuilder anonymousCartId(@Nullable String anonymousCartId)
      Deprecated.

      Deprecated since an anonymous Cart can be identified by its id or external key.

      Parameters:
      anonymousCartId - value to be set
      Returns:
      Builder
    • anonymousCart

      Identifies a Cart that will be assigned to the new Customer.

      Parameters:
      builder - function to build the anonymousCart value
      Returns:
      Builder
    • withAnonymousCart

      Identifies a Cart that will be assigned to the new Customer.

      Parameters:
      builder - function to build the anonymousCart value
      Returns:
      Builder
    • anonymousCart

      public CustomerDraftBuilder anonymousCart(@Nullable CartResourceIdentifier anonymousCart)

      Identifies a Cart that will be assigned to the new Customer.

      Parameters:
      anonymousCart - value to be set
      Returns:
      Builder
    • anonymousId

      public CustomerDraftBuilder anonymousId(@Nullable String anonymousId)

      Identifies Carts and Orders belonging to an anonymous session that will be assigned to the new Customer.

      Parameters:
      anonymousId - value to be set
      Returns:
      Builder
    • dateOfBirth

      public CustomerDraftBuilder dateOfBirth(@Nullable LocalDate dateOfBirth)

      Date of birth of the Customer.

      Parameters:
      dateOfBirth - value to be set
      Returns:
      Builder
    • companyName

      public CustomerDraftBuilder companyName(@Nullable String companyName)

      Company name of the Customer. When representing a company as a Customer, Business Units provide extended funtionality.

      Parameters:
      companyName - value to be set
      Returns:
      Builder
    • vatId

      public CustomerDraftBuilder vatId(@Nullable String vatId)

      Individual VAT ID of the Customer.

      Parameters:
      vatId - value to be set
      Returns:
      Builder
    • addresses

      public CustomerDraftBuilder addresses(@Nullable BaseAddress... addresses)

      Addresses of the Customer.

      Parameters:
      addresses - value to be set
      Returns:
      Builder
    • addresses

      public CustomerDraftBuilder addresses(@Nullable List<BaseAddress> addresses)

      Addresses of the Customer.

      Parameters:
      addresses - value to be set
      Returns:
      Builder
    • plusAddresses

      public CustomerDraftBuilder plusAddresses(@Nullable BaseAddress... addresses)

      Addresses of the Customer.

      Parameters:
      addresses - value to be set
      Returns:
      Builder
    • plusAddresses

      Addresses of the Customer.

      Parameters:
      builder - function to build the addresses value
      Returns:
      Builder
    • withAddresses

      Addresses of the Customer.

      Parameters:
      builder - function to build the addresses value
      Returns:
      Builder
    • addAddresses

      Addresses of the Customer.

      Parameters:
      builder - function to build the addresses value
      Returns:
      Builder
    • setAddresses

      Addresses of the Customer.

      Parameters:
      builder - function to build the addresses value
      Returns:
      Builder
    • defaultShippingAddress

      public CustomerDraftBuilder defaultShippingAddress(@Nullable Integer defaultShippingAddress)

      Index of the address in the addresses array to use as the default shipping address. The defaultShippingAddressId of the Customer will be set to the id of that address.

      Parameters:
      defaultShippingAddress - value to be set
      Returns:
      Builder
    • shippingAddresses

      public CustomerDraftBuilder shippingAddresses(@Nullable Integer... shippingAddresses)

      Indices of the shipping addresses in the addresses array. The shippingAddressIds of the Customer will be set to the IDs of these addresses.

      Parameters:
      shippingAddresses - value to be set
      Returns:
      Builder
    • shippingAddresses

      public CustomerDraftBuilder shippingAddresses(@Nullable List<Integer> shippingAddresses)

      Indices of the shipping addresses in the addresses array. The shippingAddressIds of the Customer will be set to the IDs of these addresses.

      Parameters:
      shippingAddresses - value to be set
      Returns:
      Builder
    • plusShippingAddresses

      public CustomerDraftBuilder plusShippingAddresses(@Nullable Integer... shippingAddresses)

      Indices of the shipping addresses in the addresses array. The shippingAddressIds of the Customer will be set to the IDs of these addresses.

      Parameters:
      shippingAddresses - value to be set
      Returns:
      Builder
    • defaultBillingAddress

      public CustomerDraftBuilder defaultBillingAddress(@Nullable Integer defaultBillingAddress)

      Index of the address in the addresses array to use as the default billing address. The defaultBillingAddressId of the Customer will be set to the id of that address.

      Parameters:
      defaultBillingAddress - value to be set
      Returns:
      Builder
    • billingAddresses

      public CustomerDraftBuilder billingAddresses(@Nullable Integer... billingAddresses)

      Indices of the billing addresses in the addresses array. The billingAddressIds of the Customer will be set to the IDs of these addresses.

      Parameters:
      billingAddresses - value to be set
      Returns:
      Builder
    • billingAddresses

      public CustomerDraftBuilder billingAddresses(@Nullable List<Integer> billingAddresses)

      Indices of the billing addresses in the addresses array. The billingAddressIds of the Customer will be set to the IDs of these addresses.

      Parameters:
      billingAddresses - value to be set
      Returns:
      Builder
    • plusBillingAddresses

      public CustomerDraftBuilder plusBillingAddresses(@Nullable Integer... billingAddresses)

      Indices of the billing addresses in the addresses array. The billingAddressIds of the Customer will be set to the IDs of these addresses.

      Parameters:
      billingAddresses - value to be set
      Returns:
      Builder
    • isEmailVerified

      public CustomerDraftBuilder isEmailVerified(@Nullable Boolean isEmailVerified)

      Set to true if the email address of the Customer has been verified already. The intended use is to leave this field unset upon sign-up of the Customer and initiate the email verification afterwards.

      Parameters:
      isEmailVerified - value to be set
      Returns:
      Builder
    • customerGroup

      Sets the CustomerGroup for the Customer.

      Parameters:
      builder - function to build the customerGroup value
      Returns:
      Builder
    • withCustomerGroup

      Sets the CustomerGroup for the Customer.

      Parameters:
      builder - function to build the customerGroup value
      Returns:
      Builder
    • customerGroup

      public CustomerDraftBuilder customerGroup(@Nullable CustomerGroupResourceIdentifier customerGroup)

      Sets the CustomerGroup for the Customer.

      Parameters:
      customerGroup - value to be set
      Returns:
      Builder
    • custom

      Custom Fields for the Customer.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • withCustom

      Custom Fields for the Customer.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • custom

      Custom Fields for the Customer.

      Parameters:
      custom - value to be set
      Returns:
      Builder
    • locale

      public CustomerDraftBuilder locale(@Nullable String locale)

      Preferred language of the Customer. Must be one of the languages supported by the Project.

      Parameters:
      locale - value to be set
      Returns:
      Builder
    • salutation

      public CustomerDraftBuilder salutation(@Nullable String salutation)

      Salutation of the Customer, for example, 'Mr.' or 'Mrs.'.

      Parameters:
      salutation - value to be set
      Returns:
      Builder
    • stores

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Parameters:
      stores - value to be set
      Returns:
      Builder
    • stores

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Parameters:
      stores - value to be set
      Returns:
      Builder
    • plusStores

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Parameters:
      stores - value to be set
      Returns:
      Builder
    • plusStores

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • withStores

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • addStores

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • setStores

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • authenticationMode

      public CustomerDraftBuilder authenticationMode(@Nullable AuthenticationMode authenticationMode)
      • Set to Password to make the password field required for the Customer.
      • Set to ExternalAuth when the password is not required for the Customer.
      Parameters:
      authenticationMode - value to be set
      Returns:
      Builder
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier for the Customer. The key field is preferred over customerNumber as it is mutable and provides more flexibility.

      This field is optional for backwards compatibility reasons, but we strongly recommend setting it. Keys are mandatory for importing Customers with the Import API.

      Returns:
      key
    • getCustomerNumber

      @Nullable public String getCustomerNumber()

      User-defined unique identifier for a Customer. Once set, it cannot be changed.

      Can be used to refer to a Customer in a human-readable way (in emails, invoices, and other correspondence).

      Returns:
      customerNumber
    • getExternalId

      @Nullable public String getExternalId()

      Optional identifier for use in external systems like customer relationship management (CRM) or enterprise resource planning (ERP).

      Returns:
      externalId
    • getEmail

      public String getEmail()

      Email address of the Customer that must be unique for an entire Project or to a Store the Customer is assigned to. It is the mandatory unique identifier of a Customer.

      Returns:
      email
    • getPassword

      @Nullable public String getPassword()

      Required when authenticationMode is set to Password. Provide the Customer's password in plain text. The API stores passwords in an encrypted format.

      Returns:
      password
    • getFirstName

      @Nullable public String getFirstName()

      Given name (first name) of the Customer.

      Returns:
      firstName
    • getLastName

      @Nullable public String getLastName()

      Family name (last name) of the Customer.

      Returns:
      lastName
    • getMiddleName

      @Nullable public String getMiddleName()

      Middle name of the Customer.

      Returns:
      middleName
    • getTitle

      @Nullable public String getTitle()

      Title of the Customer, for example, 'Dr.'.

      Returns:
      title
    • getAnonymousCartId

      @Deprecated @Nullable public String getAnonymousCartId()
      Deprecated.

      Deprecated since an anonymous Cart can be identified by its id or external key.

      Returns:
      anonymousCartId
    • getAnonymousCart

      @Nullable public CartResourceIdentifier getAnonymousCart()

      Identifies a Cart that will be assigned to the new Customer.

      Returns:
      anonymousCart
    • getAnonymousId

      @Nullable public String getAnonymousId()

      Identifies Carts and Orders belonging to an anonymous session that will be assigned to the new Customer.

      Returns:
      anonymousId
    • getDateOfBirth

      @Nullable public LocalDate getDateOfBirth()

      Date of birth of the Customer.

      Returns:
      dateOfBirth
    • getCompanyName

      @Nullable public String getCompanyName()

      Company name of the Customer. When representing a company as a Customer, Business Units provide extended funtionality.

      Returns:
      companyName
    • getVatId

      @Nullable public String getVatId()

      Individual VAT ID of the Customer.

      Returns:
      vatId
    • getAddresses

      @Nullable public List<BaseAddress> getAddresses()

      Addresses of the Customer.

      Returns:
      addresses
    • getDefaultShippingAddress

      @Nullable public Integer getDefaultShippingAddress()

      Index of the address in the addresses array to use as the default shipping address. The defaultShippingAddressId of the Customer will be set to the id of that address.

      Returns:
      defaultShippingAddress
    • getShippingAddresses

      @Nullable public List<Integer> getShippingAddresses()

      Indices of the shipping addresses in the addresses array. The shippingAddressIds of the Customer will be set to the IDs of these addresses.

      Returns:
      shippingAddresses
    • getDefaultBillingAddress

      @Nullable public Integer getDefaultBillingAddress()

      Index of the address in the addresses array to use as the default billing address. The defaultBillingAddressId of the Customer will be set to the id of that address.

      Returns:
      defaultBillingAddress
    • getBillingAddresses

      @Nullable public List<Integer> getBillingAddresses()

      Indices of the billing addresses in the addresses array. The billingAddressIds of the Customer will be set to the IDs of these addresses.

      Returns:
      billingAddresses
    • getIsEmailVerified

      @Nullable public Boolean getIsEmailVerified()

      Set to true if the email address of the Customer has been verified already. The intended use is to leave this field unset upon sign-up of the Customer and initiate the email verification afterwards.

      Returns:
      isEmailVerified
    • getCustomerGroup

      @Nullable public CustomerGroupResourceIdentifier getCustomerGroup()

      Sets the CustomerGroup for the Customer.

      Returns:
      customerGroup
    • getCustom

      @Nullable public CustomFieldsDraft getCustom()

      Custom Fields for the Customer.

      Returns:
      custom
    • getLocale

      @Nullable public String getLocale()

      Preferred language of the Customer. Must be one of the languages supported by the Project.

      Returns:
      locale
    • getSalutation

      @Nullable public String getSalutation()

      Salutation of the Customer, for example, 'Mr.' or 'Mrs.'.

      Returns:
      salutation
    • getStores

      @Nullable public List<StoreResourceIdentifier> getStores()

      Sets the Stores for the Customer.

      • If no Stores are specified, the Customer is a global customer, and can log in using the Password Flow for global Customers.
      • If any Stores are specified, the Customer can only log in using the Password Flow for Customers in a Store for those specific Stores.
      Returns:
      stores
    • getAuthenticationMode

      @Nullable public AuthenticationMode getAuthenticationMode()
      • Set to Password to make the password field required for the Customer.
      • Set to ExternalAuth when the password is not required for the Customer.
      Returns:
      authenticationMode
    • build

      public CustomerDraft build()
      builds CustomerDraft with checking for non-null required values
      Specified by:
      build in interface Builder<CustomerDraft>
      Returns:
      CustomerDraft
    • buildUnchecked

      public CustomerDraft buildUnchecked()
      builds CustomerDraft without checking for non-null required values
      Returns:
      CustomerDraft
    • of

      public static CustomerDraftBuilder of()
      factory method for an instance of CustomerDraftBuilder
      Returns:
      builder
    • of

      public static CustomerDraftBuilder of(CustomerDraft template)
      create builder for CustomerDraft instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder