// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java
// public class GitChangelogIntegrationException extends Exception {
// 
//   private static final long serialVersionUID = 4249741847365803709L;
// 
//   public GitChangelogIntegrationException(String message, Throwable throwable) {
//     super(message, throwable);
//   }
// 
//   public GitChangelogIntegrationException(String message) {
//     super(message);
//   }
// }


import static org.slf4j.LoggerFactory.getLogger;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
package se.bjurr.gitchangelog.internal.integrations.rest;



public class RestClient {
  private static Logger logger = getLogger(RestClient.class);
  private static RestClient mockedRestClient;
  private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>();
  private String basicAuthString;
  private String bearer;
  private Map<String, String> headers;

  public RestClient() {}

  public RestClient withBasicAuthCredentials(final String username, final String password) {
    try {
      this.basicAuthString =
          Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8"));
    } catch (final UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    return this;
  }

  public RestClient withTokenAuthCredentials(final String token) {
    this.basicAuthString = token;
    return this;
  }

  public RestClient withBearer(final String bearer) {
    this.bearer = bearer;
    return this;
  }

  public RestClient withHeaders(final Map<String, String> headers) {
    this.headers = headers;
    return this;
  }

// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java
// public class GitChangelogIntegrationException extends Exception {
// 
//   private static final long serialVersionUID = 4249741847365803709L;
// 
//   public GitChangelogIntegrationException(String message, Throwable throwable) {
//     super(message, throwable);
//   }
// 
//   public GitChangelogIntegrationException(String message) {
//     super(message);
//   }
// }


// Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/rest/RestClient.java
import static org.slf4j.LoggerFactory.getLogger;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;

package se.bjurr.gitchangelog.internal.integrations.rest;



public class RestClient {
  private static Logger logger = getLogger(RestClient.class);
  private static RestClient mockedRestClient;
  private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>();
  private String basicAuthString;
  private String bearer;
  private Map<String, String> headers;

  public RestClient() {}

  public RestClient withBasicAuthCredentials(final String username, final String password) {
    try {
      this.basicAuthString =
          Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8"));
    } catch (final UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    return this;
  }

  public RestClient withTokenAuthCredentials(final String token) {
    this.basicAuthString = token;
    return this;
  }

  public RestClient withBearer(final String bearer) {
    this.bearer = bearer;
    return this;
  }

  public RestClient withHeaders(final Map<String, String> headers) {
    this.headers = headers;
    return this;
  }

  public Optional<String> get(final String url) throws GitChangelogIntegrationException {