public final class CustomerCreateEmailTokenCommand extends CommandImpl<CustomerToken>
withUpdateableCustomer(client(), customer -> { assertThat(customer.isEmailVerified()).isFalse(); final int ttlMinutes = 15; final Command<CustomerToken> createTokenCommand = CustomerCreateEmailTokenCommand.ofCustomerId(customer.getId(), ttlMinutes); final CustomerToken customerToken = client().executeBlocking(createTokenCommand); final String tokenValue = customerToken.getValue();//this token needs to be sent via email to the customer final Command<Customer> verifyEmailCommand = CustomerVerifyEmailCommand.ofTokenValue(tokenValue); final Customer loadedCustomer = client().executeBlocking(verifyEmailCommand); assertThat(loadedCustomer.isEmailVerified()).isTrue(); Query<CustomerEmailVerifiedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(customer)) .withSort(m -> m.createdAt().sort().desc()) .withLimit(1L) .forMessageType(CustomerEmailVerifiedMessage.MESSAGE_HINT); assertEventually(() -> { final PagedQueryResult<CustomerEmailVerifiedMessage> queryResult = client().executeBlocking(messageQuery); assertThat(queryResult.head()).isPresent(); }); return loadedCustomer; });
See the test code.
Modifier and Type | Method and Description |
---|---|
String |
getId() |
Integer |
getTtlMinutes() |
HttpRequestIntent |
httpRequestIntent()
Provides an http request intent, this does not include the execution of it.
|
protected com.fasterxml.jackson.databind.JavaType |
jacksonJavaType() |
static CustomerCreateEmailTokenCommand |
of(Identifiable<Customer> customer,
Integer timeToLiveInMinutes)
Creates a command object to create a token to verify a customer's email.
|
static CustomerCreateEmailTokenCommand |
ofCustomerId(String id,
Integer timeToLiveInMinutes)
Creates a command object to create a token to verify a customer's email.
|
deserialize
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
canDeserialize
public static CustomerCreateEmailTokenCommand ofCustomerId(String id, Integer timeToLiveInMinutes)
id
- the id belonging to the customertimeToLiveInMinutes
- the time in minutes the token is valid, Composable Commerce limitation applypublic static CustomerCreateEmailTokenCommand of(Identifiable<Customer> customer, Integer timeToLiveInMinutes)
customer
- customertimeToLiveInMinutes
- the time in minutes the token is valid, Composable Commerce limitation applypublic String getId()
public Integer getTtlMinutes()
protected com.fasterxml.jackson.databind.JavaType jacksonJavaType()
jacksonJavaType
in class CommandImpl<CustomerToken>
public HttpRequestIntent httpRequestIntent()
SphereRequest