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

cl.transbank.util.HttpUtil Maven / Gradle / Ivy

The newest version!
package cl.transbank.util;

import cl.transbank.webpay.exception.WebpayException;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

/**
 * This interface provides methods for HTTP requests.
 */
public interface HttpUtil {
   T request(
    @NonNull URL url,
    RequestMethod method,
    Object request,
    Map headers,
    Class clazz
  ) throws IOException, WebpayException;
   List requestList(
    @NonNull URL url,
    RequestMethod method,
    Object request,
    Map headers,
    Class clazz
  ) throws IOException, WebpayException;
  String request(URL url, HttpUtil.RequestMethod method, String query)
    throws IOException, WebpayException;
  String request(
    URL url,
    HttpUtil.RequestMethod method,
    String query,
    HttpUtil.ContentType contentType
  ) throws IOException, WebpayException;
  String request(
    @NonNull URL url,
    RequestMethod method,
    String query,
    Map headers
  ) throws IOException, WebpayException;
  String request(
    @NonNull URL url,
    RequestMethod method,
    String query,
    ContentType contentType,
    Map headers
  ) throws IOException, WebpayException;

  @AllArgsConstructor
  enum ContentType {
    JSON("application/json");

    @Getter
    private String contentType;
  }

  enum RequestMethod {
    GET,
    POST,
    DELETE,
    PUT,
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy