resendVerificationCode method

  1. @override
Future<Either<Failure, Unit>> resendVerificationCode(
  1. AuthenticationData data,
  2. CustomVerificationCodePayload? customPayload
)
override

Implementation

@override
Future<Either<Failure, Unit>> resendVerificationCode(
  AuthenticationData data,
  CustomVerificationCodePayload? customPayload,
) async {
  return wrapAndHandleHttpBaseRequest<Unit>(
    () {
      final String body = config.resendVerificationCodeCustomRequestMapper?.call(
            data,
            customPayload,
          ) ??
          jsonEncode(customPayload?.toMap() ??
              {
                "user_id": data.id,
              });

      if (config.resendVerificationCodeApiEndpoint == null) {
        throw Exception(
            "'resendVerificationCodeApiEndpoint' property is not defined in provided AccountBasicConfig");
      }

      final Uri uri = config.resendVerificationCodeApiEndpoint!(data);

      return http.Request(config.resendVerificationCodeApiMethod, uri)..body = body;
    },
    onResponse: (response, left, right) {
      config.resendVerificationCodeCustomResponseParser?.call(
        response,
      );
      return right(unit);
    },
  );
}