public interface CustomerService
Modifier and Type | Method and Description |
---|---|
QueryRequest<Customer> |
all()
Deprecated.
since 0.49.0. Use
query() instead. |
FetchRequest<Customer> |
byId(java.lang.String id)
Finds a customer by id.
|
FetchRequest<Customer> |
byToken(java.lang.String token)
Finds a customer by a token value.
|
CommandRequest<Customer> |
changePassword(VersionedId customerId,
java.lang.String currentPassword,
java.lang.String newPassword)
Sets a new password for a customer.
|
CommandRequest<Customer> |
confirmEmail(VersionedId customerId,
java.lang.String token)
Sets
Customer.isEmailVerified to true. |
CommandRequest<CustomerToken> |
createEmailVerificationToken(VersionedId customerId,
int ttlMinutes)
Creates a token used to verify customer's email.
|
CommandRequest<CustomerToken> |
createPasswordResetToken(java.lang.String email)
Creates a password reset token for the customer with the given email.
|
CommandRequest<CustomerToken> |
createPasswordResetToken(java.lang.String email,
int ttlMinutes) |
QueryRequest<Customer> |
query()
Queries customers.
|
CommandRequest<Customer> |
resetPassword(VersionedId customerId,
java.lang.String token,
java.lang.String newPassword)
Sets a new password for a customer.
|
CommandRequest<SignInResult> |
signIn(java.lang.String email,
java.lang.String password)
Signs in a customer.
|
CommandRequest<SignInResult> |
signIn(java.lang.String email,
java.lang.String password,
java.lang.String anonymousCartId)
Signs in a customer and associates an existing anonymous cart to the customer.
|
CommandRequest<SignInResult> |
signUp(SignUpBuilder builder)
Creates a new customer.
|
CommandRequest<SignInResult> |
signUp(java.lang.String email,
java.lang.String password,
CustomerName name)
Creates a new customer.
|
CommandRequest<SignInResult> |
signUp(java.lang.String email,
java.lang.String password,
CustomerName customerName,
java.lang.String anonymousCartId)
Creates a new customer and associates an existing anonymous cart to the customer.
|
CommandRequest<Customer> |
update(VersionedId customerId,
CustomerUpdate customerUpdate)
Updates a customer.
|
FetchRequest<Customer> byId(java.lang.String id)
FetchRequest<Customer> byToken(java.lang.String token)
@Deprecated QueryRequest<Customer> all()
query()
instead.QueryRequest<Customer> query()
CommandRequest<SignInResult> signUp(java.lang.String email, java.lang.String password, CustomerName name)
EmailAlreadyInUseException
if the email is already taken.
CommandRequest<SignInResult> signUp(java.lang.String email, java.lang.String password, CustomerName customerName, java.lang.String anonymousCartId)
If the customer already had a cart, the given anonymous cart is merged with customer's cart. If no cart existed for the customer, the anonymous cart becomes customer's cart.
anonymousCartId
- The id of the anonymous cart that should be merged / associated to the customer. Can't be empty.EmailAlreadyInUseException
if the email is already taken.
CommandRequest<SignInResult> signUp(SignUpBuilder builder)
If the customer already had a cart, the given anonymous cart is merged with customer's cart. If no cart existed for the customer, the anonymous cart becomes customer's cart.
EmailAlreadyInUseException
if the email is already taken.
CommandRequest<SignInResult> signIn(java.lang.String email, java.lang.String password)
InvalidCredentialsException
if no customer with given credentials exists.
CommandRequest<SignInResult> signIn(java.lang.String email, java.lang.String password, java.lang.String anonymousCartId)
If the customer already had a cart, the given anonymous cart is merged with customer's cart. If no cart existed for the customer, the anonymous cart becomes customer's cart.
anonymousCartId
- The id of the anonymous cart that should be merged / associated to the customer. Can't be empty.InvalidCredentialsException
if no customer with given credentials exists.
CommandRequest<Customer> changePassword(VersionedId customerId, java.lang.String currentPassword, java.lang.String newPassword)
InvalidPasswordException
if the current password is invalid.
CommandRequest<Customer> update(VersionedId customerId, CustomerUpdate customerUpdate)
CommandRequest<Customer> resetPassword(VersionedId customerId, java.lang.String token, java.lang.String newPassword)
createPasswordResetToken(String)
method.CommandRequest<CustomerToken> createEmailVerificationToken(VersionedId customerId, int ttlMinutes)
Typically, verification emails are sent as part of the signup process but the decision is when and whether to verify customer emails is up to you.
The typical workflow is the following:
confirmEmail(io.sphere.client.model.VersionedId, java.lang.String)
,
passing in current customer's id, version and the token, extracted from the URL.
CustomerService
.ttlMinutes
- Validity of the token in minutes. The maximum allowed value is 43200 (30 days).CommandRequest<Customer> confirmEmail(VersionedId customerId, java.lang.String token)
Customer.isEmailVerified
to true.
Requires a token that was previously generated using the createEmailVerificationToken(io.sphere.client.model.VersionedId, int)
method.CommandRequest<CustomerToken> createPasswordResetToken(java.lang.String email)
The typical workflow is the following:
byToken(java.lang.String)
and remember customer's id and version in hidden form fields.
If the customer can't be found, the token has expired or is invalid.
resetPassword(io.sphere.client.model.VersionedId, java.lang.String, java.lang.String)
,
passing in the customer id and version, the new password and the token (the token is extracted from the URL).
email
- Email address for which the token should be created.CommandRequest<CustomerToken> createPasswordResetToken(java.lang.String email, int ttlMinutes)
email
- Email address for which the token should be created.ttlMinutes
- A hint for the backend how long the token should be valid.
The actual timeout could be shorter.createPasswordResetToken(java.lang.String)