updatePassword method

Future<void> updatePassword(
  1. UpdatePasswordRequest updatePasswordRequest
)

Make request for password reset

You can choose between a UpdatePasswordRequestWithAccessToken that require a authToken and your oldPassword

or a UpdatePasswordRequestWithFreshAccessToken that need a authToken with an access token from less than 5 minutes ago

or a UpdatePasswordRequestWithEmail that need your email and a verification code

or a UpdatePasswordRequestWithPhoneNumber that need your phone number and a verification code

Implementation

Future<void> updatePassword(
  UpdatePasswordRequest updatePasswordRequest,
) async {
  try {
    await switch (updatePasswordRequest) {
      UpdatePasswordRequestWithAccessToken(
        :final authToken,
        :final oldPassword,
        :final newPassword
      ) =>
        _platform.updatePasswordWithAccessToken(
          reachFiveKey: ReachFiveKeyConverter.toInterface(reachFiveKey),
          authToken: AuthTokenConverter.toInterface(authToken),
          oldPassword: oldPassword,
          newPassword: newPassword,
        ),
      UpdatePasswordRequestWithFreshAccessToken(
        :final freshAuthToken,
        :final newPassword
      ) =>
        _platform.updatePasswordWithFreshAccessToken(
          reachFiveKey: ReachFiveKeyConverter.toInterface(reachFiveKey),
          freshAuthToken: AuthTokenConverter.toInterface(freshAuthToken),
          newPassword: newPassword,
        ),
      UpdatePasswordRequestWithEmail(
        :final email,
        :final verificationCode,
        :final newPassword
      ) =>
        _platform.updatePasswordWithEmail(
          reachFiveKey: ReachFiveKeyConverter.toInterface(reachFiveKey),
          email: email,
          verificationCode: verificationCode,
          newPassword: newPassword,
        ),
      UpdatePasswordRequestWithPhoneNumber(
        :final phoneNumber,
        :final verificationCode,
        :final newPassword
      ) =>
        _platform.updatePasswordWithPhoneNumber(
          reachFiveKey: ReachFiveKeyConverter.toInterface(reachFiveKey),
          phoneNumber: phoneNumber,
          verificationCode: verificationCode,
          newPassword: newPassword,
        ),
    };
  } catch (error, stackTrace) {
    try {
      _platform.parseError(error, stackTrace);
    } catch (interfaceError, interfaceStackTrace) {
      adaptErrors(
        error: interfaceError,
        stackTrace: interfaceStackTrace,
      );
    }
  }
}