// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/PasteBinApiParams.java
// enum PasteBinApiParams {
// 
//     /**
//      * API dev key, check the API documentation to see how to obtain one. <a href="http://pastebin.com/api#1">http://pastebin.com/api#1</a>.
//      */
//     DEV_KEY("api_dev_key"),
//     /**
//      * The contents of a {@link Paste}.
//      *
//      * @see Paste#content
//      */
//     PASTE_CODE("api_paste_code"),
//     /**
//      * The visibility of the paste.
//      *
//      * @see PasteVisibility
//      * @see Paste#setVisibility(PasteVisibility)
//      */
//     PASTE_PRIVATE("api_paste_private"),
//     /**
//      * The title of the paste.
//      *
//      * @see Paste#title
//      */
//     PASTE_NAME("api_paste_name"),
//     /**
//      * Expiration time of the paste.
//      *
//      * @see PasteExpiration
//      * @see Paste#setExpiration(PasteExpiration)
//      */
//     PASTE_EXPIRE_DATE("api_paste_expire_date"),
//     /**
//      * The syntax highligh for the paste.
//      *
//      * @see PasteHighLight
//      * @see Paste#setHighLight(PasteHighLight)
//      */
//     PASTE_FORMAT("api_paste_format"),
//     /**
//      * The current Session User Key.
//      *
//      * @see AccountCredentials#userKey
//      */
//     USER_KEY("api_user_key"),
//     /**
//      * The options supported by the API
//      *
//      * @see PasteBinApiOptions
//      */
//     OPTION("api_option"),
//     /**
//      * Username to fetch a user session key
//      */
//     USER_NAME("api_user_name"),
//     /**
//      * Password to fetch a user session key
//      */
//     USER_PASSWORD("api_user_password"),
//     /**
//      * Limit for listing a users pastes.
//      */
//     LIST_RESULT_LIMIT("api_results_limit"),
//     /**
//      * Unique key of a paste
//      *
//      * @see Paste#key
//      */
//     UNIQUE_PASTE_KEY("api_paste_key");
// 
//     private final String param;
// 
//     PasteBinApiParams(String param) {
//         this.param = param;
//     }
// 
//     @Override
//     public String toString() {
//         return param;
//     }
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/ResponseUtils.java
// public static Optional<String> requiresValidResponse(Optional<String> response) {
//     validateResponse(response);
//     return response;
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/StringUtils.java
// public static boolean isNotNullNorEmpty(String s) {
//     return s != null && s.length() > 0;
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/StringUtils.java
// public static boolean isNullOrEmpty(String s) {
//     return s == null || s.length() == 0;
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/WebUtils.java
// public static Optional<String> get(@NotNull String url, @NotNull Map<Object, Object> parameters) {
//     return get(url, parameters, false);
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/WebUtils.java
// public static Optional<String> post(@NotNull String url, @NotNull Map<Object, Object> parameters) {
//     try {
//         final URL url1 = new URL(url);
// 
//         final HttpURLConnection urlConnection = (HttpURLConnection) url1.openConnection();
// 
//         urlConnection.setRequestMethod("POST");
//         urlConnection.addRequestProperty("User-Agent", USER_AGENT);
//         urlConnection.addRequestProperty("Accept", Locale.getDefault().getLanguage());
//         urlConnection.setConnectTimeout(30000);
// 
//         final String params = getParams(parameters);
// 
//         String result = doRequest(url, urlConnection, params, false);
// 
//         return Optional.of(result);
//     } catch (IOException e) {
//         throw new RuntimeException(e);
//     }
// }


import com.github.kennedyoliveira.pastebin4j.*;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.function.Function;
import static com.github.kennedyoliveira.pastebin4j.api.PasteBinApiParams.*;
import static com.github.kennedyoliveira.pastebin4j.api.ResponseUtils.requiresValidResponse;
import static com.github.kennedyoliveira.pastebin4j.api.StringUtils.isNotNullNorEmpty;
import static com.github.kennedyoliveira.pastebin4j.api.StringUtils.isNullOrEmpty;
import static com.github.kennedyoliveira.pastebin4j.api.WebUtils.get;
import static com.github.kennedyoliveira.pastebin4j.api.WebUtils.post;
                      params -> {
                          params.put(USER_KEY, accountCredentials.getUserSessionKey().get());
                          params.put(UNIQUE_PASTE_KEY, pasteKey);

                          return requiresValidResponse(post(PasteBinApiUrls.API_POST_URL, params))
                                  .filter("Paste Removed"::equalsIgnoreCase)
                                  .isPresent();
                      });
    }

    @Override
    public String getPasteContent(@NotNull Paste paste) {
        Objects.requireNonNull(paste);

        Map<Object, Object> params = new HashMap<>();

        params.put("i", paste.getKey());

        return requiresValidResponse(get(PasteBinApiUrls.PASTE_RAW_URL, params, true)).get();
    }

    @Override
    public String getPasteContent(@NotNull AccountCredentials accountCredentials, @NotNull Paste paste) {
        Objects.requireNonNull(paste);

        if (paste.getVisibility() == PasteVisibility.PRIVATE) {
            return doPost(accountCredentials, PasteBinApiOptions.SHOW_PASTE, params -> {
                params.put(USER_KEY, accountCredentials.getUserSessionKey().get());
                params.put(UNIQUE_PASTE_KEY, paste.getKey().toUpperCase());

// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/PasteBinApiParams.java
// enum PasteBinApiParams {
// 
//     /**
//      * API dev key, check the API documentation to see how to obtain one. <a href="http://pastebin.com/api#1">http://pastebin.com/api#1</a>.
//      */
//     DEV_KEY("api_dev_key"),
//     /**
//      * The contents of a {@link Paste}.
//      *
//      * @see Paste#content
//      */
//     PASTE_CODE("api_paste_code"),
//     /**
//      * The visibility of the paste.
//      *
//      * @see PasteVisibility
//      * @see Paste#setVisibility(PasteVisibility)
//      */
//     PASTE_PRIVATE("api_paste_private"),
//     /**
//      * The title of the paste.
//      *
//      * @see Paste#title
//      */
//     PASTE_NAME("api_paste_name"),
//     /**
//      * Expiration time of the paste.
//      *
//      * @see PasteExpiration
//      * @see Paste#setExpiration(PasteExpiration)
//      */
//     PASTE_EXPIRE_DATE("api_paste_expire_date"),
//     /**
//      * The syntax highligh for the paste.
//      *
//      * @see PasteHighLight
//      * @see Paste#setHighLight(PasteHighLight)
//      */
//     PASTE_FORMAT("api_paste_format"),
//     /**
//      * The current Session User Key.
//      *
//      * @see AccountCredentials#userKey
//      */
//     USER_KEY("api_user_key"),
//     /**
//      * The options supported by the API
//      *
//      * @see PasteBinApiOptions
//      */
//     OPTION("api_option"),
//     /**
//      * Username to fetch a user session key
//      */
//     USER_NAME("api_user_name"),
//     /**
//      * Password to fetch a user session key
//      */
//     USER_PASSWORD("api_user_password"),
//     /**
//      * Limit for listing a users pastes.
//      */
//     LIST_RESULT_LIMIT("api_results_limit"),
//     /**
//      * Unique key of a paste
//      *
//      * @see Paste#key
//      */
//     UNIQUE_PASTE_KEY("api_paste_key");
// 
//     private final String param;
// 
//     PasteBinApiParams(String param) {
//         this.param = param;
//     }
// 
//     @Override
//     public String toString() {
//         return param;
//     }
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/ResponseUtils.java
// public static Optional<String> requiresValidResponse(Optional<String> response) {
//     validateResponse(response);
//     return response;
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/StringUtils.java
// public static boolean isNotNullNorEmpty(String s) {
//     return s != null && s.length() > 0;
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/StringUtils.java
// public static boolean isNullOrEmpty(String s) {
//     return s == null || s.length() == 0;
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/WebUtils.java
// public static Optional<String> get(@NotNull String url, @NotNull Map<Object, Object> parameters) {
//     return get(url, parameters, false);
// }
// 
// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/WebUtils.java
// public static Optional<String> post(@NotNull String url, @NotNull Map<Object, Object> parameters) {
//     try {
//         final URL url1 = new URL(url);
// 
//         final HttpURLConnection urlConnection = (HttpURLConnection) url1.openConnection();
// 
//         urlConnection.setRequestMethod("POST");
//         urlConnection.addRequestProperty("User-Agent", USER_AGENT);
//         urlConnection.addRequestProperty("Accept", Locale.getDefault().getLanguage());
//         urlConnection.setConnectTimeout(30000);
// 
//         final String params = getParams(parameters);
// 
//         String result = doRequest(url, urlConnection, params, false);
// 
//         return Optional.of(result);
//     } catch (IOException e) {
//         throw new RuntimeException(e);
//     }
// }


// Path: src/main/java/com/github/kennedyoliveira/pastebin4j/api/PasteBinApiImpl.java
import com.github.kennedyoliveira.pastebin4j.*;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.function.Function;
import static com.github.kennedyoliveira.pastebin4j.api.PasteBinApiParams.*;
import static com.github.kennedyoliveira.pastebin4j.api.ResponseUtils.requiresValidResponse;
import static com.github.kennedyoliveira.pastebin4j.api.StringUtils.isNotNullNorEmpty;
import static com.github.kennedyoliveira.pastebin4j.api.StringUtils.isNullOrEmpty;
import static com.github.kennedyoliveira.pastebin4j.api.WebUtils.get;
import static com.github.kennedyoliveira.pastebin4j.api.WebUtils.post;

                      params -> {
                          params.put(USER_KEY, accountCredentials.getUserSessionKey().get());
                          params.put(UNIQUE_PASTE_KEY, pasteKey);

                          return requiresValidResponse(post(PasteBinApiUrls.API_POST_URL, params))
                                  .filter("Paste Removed"::equalsIgnoreCase)
                                  .isPresent();
                      });
    }

    @Override
    public String getPasteContent(@NotNull Paste paste) {
        Objects.requireNonNull(paste);

        Map<Object, Object> params = new HashMap<>();

        params.put("i", paste.getKey());

        return requiresValidResponse(get(PasteBinApiUrls.PASTE_RAW_URL, params, true)).get();
    }

    @Override
    public String getPasteContent(@NotNull AccountCredentials accountCredentials, @NotNull Paste paste) {
        Objects.requireNonNull(paste);

        if (paste.getVisibility() == PasteVisibility.PRIVATE) {
            return doPost(accountCredentials, PasteBinApiOptions.SHOW_PASTE, params -> {
                params.put(USER_KEY, accountCredentials.getUserSessionKey().get());
                params.put(UNIQUE_PASTE_KEY, paste.getKey().toUpperCase());

                return requiresValidResponse(post(PasteBinApiUrls.API_PASTE_CONTENT_URL, params)).get();