@ThreadSafe
public class CurrentCustomer
extends java.lang.Object
After calling Sphere.logout
, any existing CurrentCustomer instance is not valid any more
and will throw IllegalStateException
.
Therefore, don't keep instances of this class around, but always use Sphere.currentCustomer
to get an up-to-date instance or null, if noone is logged in.
Modifier and Type | Method and Description |
---|---|
void |
changePassword(java.lang.String currentPassword,
java.lang.String newPassword)
Changes customer's password.
|
play.libs.F.Promise<SphereResult<Customer>> |
changePasswordAsync(java.lang.String currentPassword,
java.lang.String newPassword)
Changes customer's password asynchronously.
|
QueryRequest<Comment> |
comments()
Queries all comments that the current customer created.
|
Customer |
confirmEmail(java.lang.String token)
Sets
Customer.isEmailVerified to true. |
play.libs.F.Promise<SphereResult<Customer>> |
confirmEmailAsync(java.lang.String token)
Sets
Customer.isEmailVerified to true asynchronously. |
Comment |
createComment(java.lang.String productId,
java.lang.String authorName,
java.lang.String title,
java.lang.String text)
Creates a comment.
|
play.libs.F.Promise<SphereResult<Comment>> |
createCommentAsync(java.lang.String productId,
java.lang.String authorName,
java.lang.String title,
java.lang.String text)
Creates a comment asynchronously.
|
CustomerToken |
createEmailVerificationToken(int ttlMinutes)
Creates a token to verify customer's email.
|
play.libs.F.Promise<SphereResult<CustomerToken>> |
createEmailVerificationTokenAsync(int ttlMinutes)
Creates a token to verify customer's email asynchronously.
|
static CurrentCustomer |
createFromSession(CustomerService customerService,
OrderService orderService,
CommentService commentService,
ReviewService reviewService)
If a customer is logged in, returns a
CurrentCustomer instance. |
Review |
createReview(java.lang.String productId,
java.lang.String authorName,
java.lang.String title,
java.lang.String text,
java.lang.Double score)
Creates a review.
|
play.libs.F.Promise<SphereResult<Review>> |
createReviewAsync(java.lang.String productId,
java.lang.String authorName,
java.lang.String title,
java.lang.String text,
java.lang.Double score)
Creates a review asynchronously.
|
Customer |
fetch()
Fetches the currently authenticated
Customer . |
play.libs.F.Promise<Customer> |
fetchAsync()
Fetches the currently authenticated
Customer asynchronously. |
QueryRequest<Order> |
orders()
Queries all orders of given customer.
|
QueryRequest<Review> |
reviews()
Queries all reviews of the current.
|
QueryRequest<Review> |
reviewsForProduct(java.lang.String productId)
Queries all reviews of the current customer for a specific product.
|
Customer |
update(CustomerUpdate update)
Updates the currently authenticated customer.
|
play.libs.F.Promise<SphereResult<Customer>> |
updateAsync(CustomerUpdate update)
Updates the currently authenticated customer asynchronously.
|
public static CurrentCustomer createFromSession(CustomerService customerService, OrderService orderService, CommentService commentService, ReviewService reviewService)
CurrentCustomer
instance. If no customer is logged in, returns null.public Customer fetch()
Customer
.public play.libs.F.Promise<Customer> fetchAsync()
Customer
asynchronously.public void changePassword(java.lang.String currentPassword, java.lang.String newPassword)
InvalidPasswordException
- if the current password is invalid.public play.libs.F.Promise<SphereResult<Customer>> changePasswordAsync(java.lang.String currentPassword, java.lang.String newPassword)
InvalidPasswordException
if the current password is invalid.
public Customer update(CustomerUpdate update)
public play.libs.F.Promise<SphereResult<Customer>> updateAsync(CustomerUpdate update)
public CustomerToken createEmailVerificationToken(int ttlMinutes)
public play.libs.F.Promise<SphereResult<CustomerToken>> createEmailVerificationTokenAsync(int ttlMinutes)
ttlMinutes
- Validity of the token in minutes.public Customer confirmEmail(java.lang.String token)
Customer.isEmailVerified
to true.
Requires a token that was previously generated using the createEmailVerificationToken(int)
method.public play.libs.F.Promise<SphereResult<Customer>> confirmEmailAsync(java.lang.String token)
Customer.isEmailVerified
to true asynchronously.
Requires a token that was previously generated using the createEmailVerificationToken(int)
method.public QueryRequest<Order> orders()
public QueryRequest<Review> reviews()
public QueryRequest<Review> reviewsForProduct(java.lang.String productId)
public Review createReview(java.lang.String productId, java.lang.String authorName, java.lang.String title, java.lang.String text, java.lang.Double score)
public play.libs.F.Promise<SphereResult<Review>> createReviewAsync(java.lang.String productId, java.lang.String authorName, java.lang.String title, java.lang.String text, java.lang.Double score)
public QueryRequest<Comment> comments()
public Comment createComment(java.lang.String productId, java.lang.String authorName, java.lang.String title, java.lang.String text)
public play.libs.F.Promise<SphereResult<Comment>> createCommentAsync(java.lang.String productId, java.lang.String authorName, java.lang.String title, java.lang.String text)