package com.braintreepayments.api;

import android.text.TextUtils;

import androidx.annotation.Nullable;

/**
 * Generic base class for Braintree authorization
 */
abstract class Authorization {

    private final String rawValue;

    Authorization(String rawValue) {
        this.rawValue = rawValue;
    }

    /**
     * Returns an {@link Authorization} of the correct type for a given {@link String}. If an
     * invalid authorization string is provided, an {@link InvalidAuthorization} will be returned.
     * Requests with an {@link InvalidAuthorization} will return a {@link BraintreeException} to the
     * {@link HttpResponseCallback}.
     *
     * @param authorizationString Given string to transform into an {@link Authorization}.
     * @return {@link Authorization}
     */
    static Authorization fromString(@Nullable String authorizationString) {
        try {
            if (isTokenizationKey(authorizationString)) {
                return new TokenizationKey(authorizationString);
            } else if (isPayPalUAT(authorizationString)){
                return new PayPalUAT(authorizationString);
            } else if (isClientToken(authorizationString)) {
                return new ClientToken(authorizationString);
            } else {
                String errorMessage = "Authorization provided is invalid: " + authorizationString;
                return new InvalidAuthorization(authorizationString, errorMessage);
            }
        } catch (InvalidArgumentException error) {
            return new InvalidAuthorization(authorizationString, error.getMessage());
        }
    }

    /**
     * @return The url to fetch configuration for the current Braintree environment.
     */
    abstract String getConfigUrl();

    /**
     * @return The authorization bearer string for authorizing requests.
     */
    abstract String getBearer();

    /**
     * @return The original Client token or Tokenization Key string, which can be used for serialization
     */
    @Override
    public String toString() {
        return rawValue;
    }

    private static boolean isTokenizationKey(String tokenizationKey) {
        return !TextUtils.isEmpty(tokenizationKey) && tokenizationKey.matches(TokenizationKey.MATCHER);
    }

    private static boolean isPayPalUAT(String payPalUAT) {
        return !TextUtils.isEmpty(payPalUAT) && payPalUAT.matches(PayPalUAT.MATCHER);
    }

    private static boolean isClientToken(String clientToken) {
        return !TextUtils.isEmpty(clientToken) && clientToken.matches(ClientToken.BASE_64_MATCHER);
    }
}

@@ -2068,32 +2068,24 @@
 %0A    %7D%0A%0A    
-private 
 static boole
@@ -2242,32 +2242,24 @@
 %0A    %7D%0A%0A    
-private 
 static boole
@@ -2390,24 +2390,16 @@
  %7D%0A%0A    
-private 
 static b

Make authorization type methods package private