// Path: src/main/java/com/cardinity/Cardinity.java
// public abstract class Cardinity {
// 
//     public static final String API_BASE = "https://api.cardinity.com";
//     public static final String API_VERSION = "v1";
//     public static final String VERSION = "0.1";
//     public static final String ENCODING_CHARSET = "UTF-8";
// 
// }
// 
// Path: src/main/java/com/cardinity/rest/RestResource.java
// public enum Resource {
//     PAYMENTS, REFUNDS, SETTLEMENTS, VOIDS, CHARGEBACKS
// }


import com.cardinity.Cardinity;
import com.cardinity.rest.RestResource.Resource;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.UUID;

    private static String buildCardinityUrl(UUID paymentId, Resource action, UUID actionId) {

        StringBuilder url = new StringBuilder(Cardinity.API_BASE).append(URL_SEPARATOR).append(Cardinity.API_VERSION)
                .append(URL_SEPARATOR).append(Resource.PAYMENTS);

        if (paymentId != null) {
            url.append(URL_SEPARATOR);
            url.append(paymentId);
            if (action != null) {
                url.append(URL_SEPARATOR);
                url.append(action);
                if (actionId != null) {
                    url.append(URL_SEPARATOR);
                    url.append(actionId);
                }
            }
        }
        return url.toString().toLowerCase();
    }

    public static String formatURL(String url, String query) {
        if (query == null || query.isEmpty()) {
            return url;
        } else {
            String separator = url.contains("?") ? "&" : "?";
            return String.format("%s%s%s", url, separator, query);
        }
    }

// Path: src/main/java/com/cardinity/Cardinity.java
// public abstract class Cardinity {
// 
//     public static final String API_BASE = "https://api.cardinity.com";
//     public static final String API_VERSION = "v1";
//     public static final String VERSION = "0.1";
//     public static final String ENCODING_CHARSET = "UTF-8";
// 
// }
// 
// Path: src/main/java/com/cardinity/rest/RestResource.java
// public enum Resource {
//     PAYMENTS, REFUNDS, SETTLEMENTS, VOIDS, CHARGEBACKS
// }


// Path: src/main/java/com/cardinity/rest/URLUtils.java
import com.cardinity.Cardinity;
import com.cardinity.rest.RestResource.Resource;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.UUID;


    private static String buildCardinityUrl(UUID paymentId, Resource action, UUID actionId) {

        StringBuilder url = new StringBuilder(Cardinity.API_BASE).append(URL_SEPARATOR).append(Cardinity.API_VERSION)
                .append(URL_SEPARATOR).append(Resource.PAYMENTS);

        if (paymentId != null) {
            url.append(URL_SEPARATOR);
            url.append(paymentId);
            if (action != null) {
                url.append(URL_SEPARATOR);
                url.append(action);
                if (actionId != null) {
                    url.append(URL_SEPARATOR);
                    url.append(actionId);
                }
            }
        }
        return url.toString().toLowerCase();
    }

    public static String formatURL(String url, String query) {
        if (query == null || query.isEmpty()) {
            return url;
        } else {
            String separator = url.contains("?") ? "&" : "?";
            return String.format("%s%s%s", url, separator, query);
        }
    }

    public static String buildQueryParam(String key, String value) throws UnsupportedEncodingException {