Class CustomerBuilder

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

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

     Customer customer = Customer.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .email("{email}")
             .plusAddresses(addressesBuilder -> addressesBuilder)
             .isEmailVerified(true)
             .plusStores(storesBuilder -> storesBuilder)
             .authenticationMode(AuthenticationMode.PASSWORD)
             .build()
 
  • Constructor Details

    • CustomerBuilder

      public CustomerBuilder()
  • Method Details

    • id

      public CustomerBuilder id(String id)

      Unique identifier of the Customer.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • version

      public CustomerBuilder version(Long version)

      Current version of the Customer.

      Parameters:
      version - value to be set
      Returns:
      Builder
    • createdAt

      public CustomerBuilder createdAt(ZonedDateTime createdAt)

      Date and time (UTC) the Customer was initially created.

      Parameters:
      createdAt - value to be set
      Returns:
      Builder
    • lastModifiedAt

      public CustomerBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

      Date and time (UTC) the Customer was last updated.

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

      public CustomerBuilder key(@Nullable String key)

      User-defined unique identifier of the Customer.

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

      public CustomerBuilder customerNumber(@Nullable String customerNumber)

      User-defined unique identifier of the Customer.

      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 CustomerBuilder 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
    • lastModifiedBy

      IDs and references that last modified the Customer.

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

      public CustomerBuilder withLastModifiedBy(Function<LastModifiedByBuilder,LastModifiedBy> builder)

      IDs and references that last modified the Customer.

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

      public CustomerBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the Customer.

      Parameters:
      lastModifiedBy - value to be set
      Returns:
      Builder
    • createdBy

      IDs and references that created the Customer.

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

      public CustomerBuilder withCreatedBy(Function<CreatedByBuilder,CreatedBy> builder)

      IDs and references that created the Customer.

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

      public CustomerBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the Customer.

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

      public CustomerBuilder email(String email)

      Email address of the Customer that is 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 CustomerBuilder password(@Nullable String password)

      Present only when authenticationMode is set to Password.

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

      public CustomerBuilder firstName(@Nullable String firstName)

      Given name (first name) of the Customer.

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

      public CustomerBuilder lastName(@Nullable String lastName)

      Family name (last name) of the Customer.

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

      public CustomerBuilder middleName(@Nullable String middleName)

      Middle name of the Customer.

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

      public CustomerBuilder title(@Nullable String title)

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

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

      public CustomerBuilder dateOfBirth(@Nullable LocalDate dateOfBirth)

      Date of birth of the Customer.

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

      public CustomerBuilder companyName(@Nullable String companyName)

      Company name of the Customer.

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

      public CustomerBuilder vatId(@Nullable String vatId)

      Individual VAT ID of the Customer.

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

      public CustomerBuilder addresses(Address... addresses)

      Addresses used by the Customer.

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

      public CustomerBuilder addresses(List<Address> addresses)

      Addresses used by the Customer.

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

      public CustomerBuilder plusAddresses(Address... addresses)

      Addresses used by the Customer.

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

      public CustomerBuilder plusAddresses(Function<AddressBuilder,AddressBuilder> builder)

      Addresses used by the Customer.

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

      public CustomerBuilder withAddresses(Function<AddressBuilder,AddressBuilder> builder)

      Addresses used by the Customer.

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

      public CustomerBuilder addAddresses(Function<AddressBuilder,Address> builder)

      Addresses used by the Customer.

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

      public CustomerBuilder setAddresses(Function<AddressBuilder,Address> builder)

      Addresses used by the Customer.

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

      public CustomerBuilder defaultShippingAddressId(@Nullable String defaultShippingAddressId)

      ID of the address in addresses used as the default shipping address.

      Parameters:
      defaultShippingAddressId - value to be set
      Returns:
      Builder
    • shippingAddressIds

      public CustomerBuilder shippingAddressIds(@Nullable String... shippingAddressIds)

      IDs of addresses in addresses used as shipping addresses.

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

      public CustomerBuilder shippingAddressIds(@Nullable List<String> shippingAddressIds)

      IDs of addresses in addresses used as shipping addresses.

      Parameters:
      shippingAddressIds - value to be set
      Returns:
      Builder
    • plusShippingAddressIds

      public CustomerBuilder plusShippingAddressIds(@Nullable String... shippingAddressIds)

      IDs of addresses in addresses used as shipping addresses.

      Parameters:
      shippingAddressIds - value to be set
      Returns:
      Builder
    • defaultBillingAddressId

      public CustomerBuilder defaultBillingAddressId(@Nullable String defaultBillingAddressId)

      ID of the address in addresses used as the default billing address.

      Parameters:
      defaultBillingAddressId - value to be set
      Returns:
      Builder
    • billingAddressIds

      public CustomerBuilder billingAddressIds(@Nullable String... billingAddressIds)

      IDs of addresses in addresses used as billing addresses.

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

      public CustomerBuilder billingAddressIds(@Nullable List<String> billingAddressIds)

      IDs of addresses in addresses used as billing addresses.

      Parameters:
      billingAddressIds - value to be set
      Returns:
      Builder
    • plusBillingAddressIds

      public CustomerBuilder plusBillingAddressIds(@Nullable String... billingAddressIds)

      IDs of addresses in addresses used as billing addresses.

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

      public CustomerBuilder isEmailVerified(Boolean isEmailVerified)

      Indicates whether the email address of the Customer is verified.

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

      CustomerGroup to which the Customer belongs.

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

      CustomerGroup to which the Customer belongs.

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

      public CustomerBuilder customerGroup(@Nullable CustomerGroupReference customerGroup)

      CustomerGroup to which the Customer belongs.

      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

      public CustomerBuilder custom(@Nullable CustomFields custom)

      Custom Fields for the Customer.

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

      public CustomerBuilder locale(@Nullable String locale)

      Preferred language of the Customer.

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

      public CustomerBuilder salutation(@Nullable String salutation)

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

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

      public CustomerBuilder stores(StoreKeyReference... stores)

      Stores to which the Customer is assigned to.

      • If stores is empty, 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

      public CustomerBuilder stores(List<StoreKeyReference> stores)

      Stores to which the Customer is assigned to.

      • If stores is empty, 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

      public CustomerBuilder plusStores(StoreKeyReference... stores)

      Stores to which the Customer is assigned to.

      • If stores is empty, 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

      Stores to which the Customer is assigned to.

      • If stores is empty, 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

      Stores to which the Customer is assigned to.

      • If stores is empty, 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

      Stores to which the Customer is assigned to.

      • If stores is empty, 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

      Stores to which the Customer is assigned to.

      • If stores is empty, 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 CustomerBuilder authenticationMode(AuthenticationMode authenticationMode)

      Indicates whether the password is required for the Customer.

      Parameters:
      authenticationMode - value to be set
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the Customer.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the Customer.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

      Date and time (UTC) the Customer was initially created.

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

      Date and time (UTC) the Customer was last updated.

      Returns:
      lastModifiedAt
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the Customer.

      Returns:
      key
    • getCustomerNumber

      @Nullable public String getCustomerNumber()

      User-defined unique identifier of the Customer.

      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
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the Customer.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the Customer.

      Returns:
      createdBy
    • getEmail

      public String getEmail()

      Email address of the Customer that is 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()

      Present only when authenticationMode is set to Password.

      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
    • getDateOfBirth

      @Nullable public LocalDate getDateOfBirth()

      Date of birth of the Customer.

      Returns:
      dateOfBirth
    • getCompanyName

      @Nullable public String getCompanyName()

      Company name of the Customer.

      Returns:
      companyName
    • getVatId

      @Nullable public String getVatId()

      Individual VAT ID of the Customer.

      Returns:
      vatId
    • getAddresses

      public List<Address> getAddresses()

      Addresses used by the Customer.

      Returns:
      addresses
    • getDefaultShippingAddressId

      @Nullable public String getDefaultShippingAddressId()

      ID of the address in addresses used as the default shipping address.

      Returns:
      defaultShippingAddressId
    • getShippingAddressIds

      @Nullable public List<String> getShippingAddressIds()

      IDs of addresses in addresses used as shipping addresses.

      Returns:
      shippingAddressIds
    • getDefaultBillingAddressId

      @Nullable public String getDefaultBillingAddressId()

      ID of the address in addresses used as the default billing address.

      Returns:
      defaultBillingAddressId
    • getBillingAddressIds

      @Nullable public List<String> getBillingAddressIds()

      IDs of addresses in addresses used as billing addresses.

      Returns:
      billingAddressIds
    • getIsEmailVerified

      public Boolean getIsEmailVerified()

      Indicates whether the email address of the Customer is verified.

      Returns:
      isEmailVerified
    • getCustomerGroup

      @Nullable public CustomerGroupReference getCustomerGroup()

      CustomerGroup to which the Customer belongs.

      Returns:
      customerGroup
    • getCustom

      @Nullable public CustomFields getCustom()

      Custom Fields for the Customer.

      Returns:
      custom
    • getLocale

      @Nullable public String getLocale()

      Preferred language of the Customer.

      Returns:
      locale
    • getSalutation

      @Nullable public String getSalutation()

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

      Returns:
      salutation
    • getStores

      public List<StoreKeyReference> getStores()

      Stores to which the Customer is assigned to.

      • If stores is empty, 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

      public AuthenticationMode getAuthenticationMode()

      Indicates whether the password is required for the Customer.

      Returns:
      authenticationMode
    • build

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

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

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

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