Search in sources :

Example 1 with RequestOwnershipParams

use of org.matrix.androidsdk.rest.model.RequestOwnershipParams in project matrix-android-sdk by matrix-org.

the class ThirdPidRestClient method submitValidationToken.

/**
 * Request the ownership validation of an email address or a phone number previously set
 * by {@link ThirdPidRestClient#requestEmailValidationToken(ThreePid, String, ApiCallback)}
 *
 * @param medium       the medium of the 3pid
 * @param token        the token generated by the requestEmailValidationToken call
 * @param clientSecret the client secret which was supplied in the requestEmailValidationToken call
 * @param sid          the sid for the session
 * @param callback     asynchronous callback response
 */
public void submitValidationToken(final String medium, final String token, final String clientSecret, final String sid, final ApiCallback<Boolean> callback) {
    RequestOwnershipParams params = RequestOwnershipParams.Companion.with(clientSecret, sid, token);
    mApi.requestOwnershipValidationV2(medium, params).enqueue(new RestAdapterCallback<>("submitValidationToken", null, new SimpleApiCallback<SuccessResult>(callback) {

        @Override
        public void onSuccess(SuccessResult info) {
            callback.onSuccess(info.success);
        }

        @Override
        public void onMatrixError(MatrixError e) {
            if (e.mStatus == HttpURLConnection.HTTP_NOT_FOUND) /*404*/
            {
                // Use legacy request
                submitValidationTokenLegacy(medium, token, clientSecret, sid, callback);
            } else {
                super.onMatrixError(e);
            }
        }
    }, null));
}
Also used : SuccessResult(org.matrix.androidsdk.rest.model.SuccessResult) MatrixError(org.matrix.androidsdk.core.model.MatrixError) RequestOwnershipParams(org.matrix.androidsdk.rest.model.RequestOwnershipParams) SimpleApiCallback(org.matrix.androidsdk.core.callback.SimpleApiCallback)

Example 2 with RequestOwnershipParams

use of org.matrix.androidsdk.rest.model.RequestOwnershipParams in project matrix-android-sdk by matrix-org.

the class ProfileRestClient method submitToken.

public void submitToken(final String submitUrl, ThreePid pid, String token, final ApiCallback<SuccessResult> callback) {
    final String description = "submitPNToken";
    RequestOwnershipParams params = RequestOwnershipParams.Companion.with(pid.getClientSecret(), pid.getSid(), token);
    mApi.submitPhoneNumberToken(submitUrl, params).enqueue(new RestAdapterCallback<SuccessResult>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {

        @Override
        public void onRetry() {
            submitToken(submitUrl, pid, token, callback);
        }
    }));
}
Also used : SuccessResult(org.matrix.androidsdk.rest.model.SuccessResult) RequestOwnershipParams(org.matrix.androidsdk.rest.model.RequestOwnershipParams)

Aggregations

RequestOwnershipParams (org.matrix.androidsdk.rest.model.RequestOwnershipParams)2 SuccessResult (org.matrix.androidsdk.rest.model.SuccessResult)2 SimpleApiCallback (org.matrix.androidsdk.core.callback.SimpleApiCallback)1 MatrixError (org.matrix.androidsdk.core.model.MatrixError)1