use of org.matrix.androidsdk.rest.model.RequestEmailValidationParams in project matrix-android-sdk by matrix-org.
the class ProfileRestClient method requestEmailValidationToken.
/**
* Request an email validation token.
*
* @param address the email address
* @param clientSecret the client secret number
* @param attempt the attempt count
* @param nextLink the next link
* @param isDuringRegistration true if it occurs during a registration flow
* @param callback the callback
*/
public void requestEmailValidationToken(final String address, final String clientSecret, final int attempt, final String nextLink, final boolean isDuringRegistration, final ApiCallback<RequestEmailValidationResponse> callback) {
final String description = "requestEmailValidationToken";
RequestEmailValidationParams params = new RequestEmailValidationParams();
params.email = address;
params.clientSecret = clientSecret;
params.sendAttempt = attempt;
params.id_server = mHsConfig.getIdentityServerUri().getHost();
if (!TextUtils.isEmpty(nextLink)) {
params.next_link = nextLink;
}
final RestAdapterCallback<RequestEmailValidationResponse> adapterCallback = new RestAdapterCallback<RequestEmailValidationResponse>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
requestEmailValidationToken(address, clientSecret, attempt, nextLink, isDuringRegistration, callback);
}
}) {
@Override
public void success(RequestEmailValidationResponse requestEmailValidationResponse, Response response) {
onEventSent();
requestEmailValidationResponse.email = address;
requestEmailValidationResponse.clientSecret = clientSecret;
requestEmailValidationResponse.sendAttempt = attempt;
callback.onSuccess(requestEmailValidationResponse);
}
};
try {
if (isDuringRegistration) {
// URL differs in that case
mApi.requestEmailValidationForRegistration(params, adapterCallback);
} else {
mApi.requestEmailValidation(params, adapterCallback);
}
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
Aggregations