All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.univapay.sdk.builders.RetryUtils Maven / Gradle / Ivy

There is a newer version: 0.2.35
Show newest version
package com.univapay.sdk.builders;

import com.univapay.sdk.models.errors.DetailedError;
import com.univapay.sdk.models.errors.UnivapayException;
import com.univapay.sdk.utils.functions.ErrorHandler;
import com.univapay.sdk.utils.functions.Function;
import com.univapay.sdk.utils.functions.UnivapayFunctions;

public abstract class RetryUtils {

  public static >> Request retryIgnoringDescriptor(
      Request originalRequest, final DescriptorRetry builder) {
    return UnivapayFunctions.retry(
        originalRequest,
        new ErrorHandler<>(
            t ->
                t instanceof UnivapayException
                    && ((UnivapayException) t)
                        .getBody()
                        .getErrors()
                        .contains(new DetailedError("descriptor", "NOT_SUPPORTED_BY_PROCESSOR")),
            new Function>() {
              @Override
              public Request apply(Throwable arg) {
                return builder.withDescriptor(null).build();
              }
            }));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy