Class APIUtils

java.lang.Object
io.github.the_sdet.api.APIUtils

public class APIUtils extends Object
This class handles all API related Utilities and Helper methods
Author:
Pabitra Swain ([email protected])
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.restassured.response.Response
    deleteRequest(String url, io.restassured.http.ContentType contentType)
    Sends a DELETE request to the specified URL and returns the response.
    static io.restassured.response.Response
    deleteRequest(String baseURI, String endpoint, io.restassured.http.ContentType contentType)
    Sends a DELETE request to the specified URL with base URI and endpoint, and returns the response.
    static io.restassured.response.Response
    deleteRequest(String baseURI, String endpoint, Map<String,String> headers, io.restassured.http.ContentType contentType)
    Sends a DELETE request to the specified URL with base URI, endpoint, custom headers, and content type, and returns the response.
    static io.restassured.response.Response
    deleteRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
    Sends a DELETE request to the specified URL and returns the response.
    static io.restassured.response.Response
    getRequest(String url, io.restassured.http.ContentType contentType)
    Sends a GET request to the specified URL and returns the response.
    static io.restassured.response.Response
    getRequest(String url, io.restassured.http.ContentType contentType, Map<String,String> queryParams)
    Sends a GET request with query parameters to the specified URL and returns the response.
    static io.restassured.response.Response
    getRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
    Sends a GET request to the specified URL with custom headers and returns the response.
    static io.restassured.response.Response
    getRequest(String url, Map<String,String> headers, Map<String,String> queryParams, io.restassured.http.ContentType contentType)
    Sends a GET request with query parameters to the specified URL and returns the response.
    static io.restassured.response.Response
    headRequest(String url, io.restassured.http.ContentType contentType)
    Sends a HEAD request to the specified URL and returns the response.
    static io.restassured.response.Response
    headRequest(String baseURI, String endpoint, io.restassured.http.ContentType contentType)
    Sends a HEAD request to the specified URL with base URI and endpoint and returns the response.
    static io.restassured.response.Response
    headRequest(String baseURI, String endpoint, Map<String,String> headers, io.restassured.http.ContentType contentType)
    Sends a HEAD request to the specified URL with base URI, endpoint, custom headers, and returns the response.
    static io.restassured.response.Response
    headRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
    Sends a HEAD request to the specified URL with custom headers and returns the response.
    static io.restassured.response.Response
    optionsRequest(String url, io.restassured.http.ContentType contentType)
    Sends an OPTIONS request to the specified URL and returns the response.
    static io.restassured.response.Response
    optionsRequest(String baseURI, String endpoint, io.restassured.http.ContentType contentType)
    Sends an OPTIONS request to the specified URL with base URI and endpoint and returns the response.
    static io.restassured.response.Response
    optionsRequest(String baseURI, String endpoint, Map<String,String> headers, io.restassured.http.ContentType contentType)
    Sends an OPTIONS request to the specified URL with base URI, endpoint, custom headers, and returns the response.
    static io.restassured.response.Response
    optionsRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
    Sends an OPTIONS request to the specified URL with custom headers and returns the response.
    static io.restassured.response.Response
    patchRequest(String url, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PATCH request to the specified URL with the given request body and returns the response.
    static io.restassured.response.Response
    patchRequest(String baseURI, String endpoint, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PATCH request to the specified URL with base URI and endpoint, the given request body, and returns the response.
    static io.restassured.response.Response
    patchRequest(String baseURI, String endpoint, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PATCH request to the specified URL with base URI, endpoint, custom headers, request body, and content type, and returns the response.
    static io.restassured.response.Response
    patchRequest(String url, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PATCH request to the specified URL with custom headers and returns the response.
    static io.restassured.response.Response
    postRequest(String url, String requestBody, io.restassured.http.ContentType contentType)
    Sends a POST request to the specified URL with the given request body and returns the response.
    static io.restassured.response.Response
    postRequest(String baseURI, String endpoint, String requestBody, io.restassured.http.ContentType contentType)
    Sends a POST request to the specified URL with base URI, endpoint, and the given request body, and returns the response.
    static io.restassured.response.Response
    postRequest(String baseURI, String endpoint, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
    Sends a POST request to the specified URL with base URI, endpoint, custom headers, request body, and content type, and returns the response.
    static io.restassured.response.Response
    postRequest(String url, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
    Sends a POST request to the specified URL with custom headers and returns the response.
    static io.restassured.response.Response
    putRequest(String url, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PUT request to the specified URL with the given request body and returns the response.
    static io.restassured.response.Response
    putRequest(String baseURI, String endpoint, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PUT request to the specified URL with base URI, endpoint, and the given request body, and returns the response.
    static io.restassured.response.Response
    putRequest(String baseURI, String endpoint, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PUT request to the specified URL with base URI, endpoint, custom headers, request body, and content type, and returns the response.
    static io.restassured.response.Response
    putRequest(String url, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
    Sends a PUT request to the specified URL with custom headers and returns the response.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • APIUtils

      public APIUtils()
  • Method Details

    • getRequest

      public static io.restassured.response.Response getRequest(String url, io.restassured.http.ContentType contentType)
      Sends a GET request to the specified URL and returns the response.
      Parameters:
      url - The URL to send the request to
      contentType - Content Type
      Returns:
      The response received
    • getRequest

      public static io.restassured.response.Response getRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
      Sends a GET request to the specified URL with custom headers and returns the response.
      Parameters:
      url - The URL to send the request to
      headers - The headers to include in the request
      contentType - Content Type
      Returns:
      The response received Pabitra Swain ([email protected])
    • getRequest

      public static io.restassured.response.Response getRequest(String url, io.restassured.http.ContentType contentType, Map<String,String> queryParams)
      Sends a GET request with query parameters to the specified URL and returns the response.
      Parameters:
      url - The base URL to send the request to
      queryParams - The query parameters to include in the request
      contentType - Content Type
      Returns:
      The response received
    • getRequest

      public static io.restassured.response.Response getRequest(String url, Map<String,String> headers, Map<String,String> queryParams, io.restassured.http.ContentType contentType)
      Sends a GET request with query parameters to the specified URL and returns the response.
      Parameters:
      url - The base URL to send the request to
      headers - The headers to include in the request
      queryParams - The query parameters to include in the request
      contentType - Content Type
      Returns:
      The response received
    • postRequest

      public static io.restassured.response.Response postRequest(String url, String requestBody, io.restassured.http.ContentType contentType)
      Sends a POST request to the specified URL with the given request body and returns the response.
      Parameters:
      url - The URL to send the request to
      requestBody - The request body to send
      contentType - Content Type
      Returns:
      The response received
    • postRequest

      public static io.restassured.response.Response postRequest(String url, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
      Sends a POST request to the specified URL with custom headers and returns the response.
      Parameters:
      url - The URL to send the request to
      headers - The headers to include in the request
      requestBody - The request body to send
      contentType - Content Type
      Returns:
      The response received
    • postRequest

      public static io.restassured.response.Response postRequest(String baseURI, String endpoint, String requestBody, io.restassured.http.ContentType contentType)
      Sends a POST request to the specified URL with base URI, endpoint, and the given request body, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      requestBody - The request body to send
      contentType - The content type of the request
      Returns:
      The response received
    • postRequest

      public static io.restassured.response.Response postRequest(String baseURI, String endpoint, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
      Sends a POST request to the specified URL with base URI, endpoint, custom headers, request body, and content type, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      headers - The headers to include in the request
      requestBody - The request body to send
      contentType - The content type of the request
      Returns:
      The response received
    • putRequest

      public static io.restassured.response.Response putRequest(String url, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PUT request to the specified URL with the given request body and returns the response.
      Parameters:
      url - The URL to send the request to
      requestBody - The request body to send
      contentType - Content Type
      Returns:
      The response received
    • putRequest

      public static io.restassured.response.Response putRequest(String url, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PUT request to the specified URL with custom headers and returns the response.
      Parameters:
      url - The URL to send the request to
      headers - The headers to include in the request
      requestBody - The request body to send
      contentType - Content Type
      Returns:
      The response received
    • putRequest

      public static io.restassured.response.Response putRequest(String baseURI, String endpoint, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PUT request to the specified URL with base URI, endpoint, and the given request body, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      requestBody - The request body to send
      contentType - The content type of the request
      Returns:
      The response received
    • putRequest

      public static io.restassured.response.Response putRequest(String baseURI, String endpoint, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PUT request to the specified URL with base URI, endpoint, custom headers, request body, and content type, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      headers - The headers to include in the request
      requestBody - The request body to send
      contentType - The content type of the request
      Returns:
      The response received
    • deleteRequest

      public static io.restassured.response.Response deleteRequest(String url, io.restassured.http.ContentType contentType)
      Sends a DELETE request to the specified URL and returns the response.
      Parameters:
      url - The URL to send the request to
      contentType - Content Type
      Returns:
      The response received
    • deleteRequest

      public static io.restassured.response.Response deleteRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
      Sends a DELETE request to the specified URL and returns the response.
      Parameters:
      url - The URL to send the request to
      headers - Headers
      contentType - Content Type
      Returns:
      The response received
    • deleteRequest

      public static io.restassured.response.Response deleteRequest(String baseURI, String endpoint, io.restassured.http.ContentType contentType)
      Sends a DELETE request to the specified URL with base URI and endpoint, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      contentType - The content type of the request
      Returns:
      The response received
    • deleteRequest

      public static io.restassured.response.Response deleteRequest(String baseURI, String endpoint, Map<String,String> headers, io.restassured.http.ContentType contentType)
      Sends a DELETE request to the specified URL with base URI, endpoint, custom headers, and content type, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      headers - The headers to include in the request
      contentType - The content type of the request
      Returns:
      The response received
    • patchRequest

      public static io.restassured.response.Response patchRequest(String url, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PATCH request to the specified URL with the given request body and returns the response.
      Parameters:
      url - The URL to send the request to
      requestBody - The request body to send
      contentType - Content Type
      Returns:
      The response received
    • patchRequest

      public static io.restassured.response.Response patchRequest(String url, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PATCH request to the specified URL with custom headers and returns the response.
      Parameters:
      url - The URL to send the request to
      headers - The headers to include in the request
      requestBody - The request body to send
      contentType - Content Type
      Returns:
      The response received Pabitra Swain ([email protected])
    • patchRequest

      public static io.restassured.response.Response patchRequest(String baseURI, String endpoint, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PATCH request to the specified URL with base URI and endpoint, the given request body, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      requestBody - The request body to send
      contentType - The content type of the request
      Returns:
      The response received
    • patchRequest

      public static io.restassured.response.Response patchRequest(String baseURI, String endpoint, Map<String,String> headers, String requestBody, io.restassured.http.ContentType contentType)
      Sends a PATCH request to the specified URL with base URI, endpoint, custom headers, request body, and content type, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      headers - The headers to include in the request
      requestBody - The request body to send
      contentType - The content type of the request
      Returns:
      The response received
    • headRequest

      public static io.restassured.response.Response headRequest(String url, io.restassured.http.ContentType contentType)
      Sends a HEAD request to the specified URL and returns the response.
      Parameters:
      url - The URL to send the request to
      contentType - The content type of the request
      Returns:
      The response received
    • headRequest

      public static io.restassured.response.Response headRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
      Sends a HEAD request to the specified URL with custom headers and returns the response.
      Parameters:
      url - The URL to send the request to
      headers - The headers to include in the request
      contentType - The content type of the request
      Returns:
      The response received
    • headRequest

      public static io.restassured.response.Response headRequest(String baseURI, String endpoint, io.restassured.http.ContentType contentType)
      Sends a HEAD request to the specified URL with base URI and endpoint and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      contentType - The content type of the request\
      Returns:
      The response received
    • headRequest

      public static io.restassured.response.Response headRequest(String baseURI, String endpoint, Map<String,String> headers, io.restassured.http.ContentType contentType)
      Sends a HEAD request to the specified URL with base URI, endpoint, custom headers, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      headers - The headers to include in the request
      contentType - The content type of the request
      Returns:
      The response received
    • optionsRequest

      public static io.restassured.response.Response optionsRequest(String url, io.restassured.http.ContentType contentType)
      Sends an OPTIONS request to the specified URL and returns the response.
      Parameters:
      url - The URL to send the request to
      contentType - The content type of the request
      Returns:
      The response received
    • optionsRequest

      public static io.restassured.response.Response optionsRequest(String url, Map<String,String> headers, io.restassured.http.ContentType contentType)
      Sends an OPTIONS request to the specified URL with custom headers and returns the response.
      Parameters:
      url - The URL to send the request to
      headers - The headers to include in the request
      contentType - The content type of the request
      Returns:
      The response received
    • optionsRequest

      public static io.restassured.response.Response optionsRequest(String baseURI, String endpoint, io.restassured.http.ContentType contentType)
      Sends an OPTIONS request to the specified URL with base URI and endpoint and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      contentType - The content type of the request
      Returns:
      The response received
    • optionsRequest

      public static io.restassured.response.Response optionsRequest(String baseURI, String endpoint, Map<String,String> headers, io.restassured.http.ContentType contentType)
      Sends an OPTIONS request to the specified URL with base URI, endpoint, custom headers, and returns the response.
      Parameters:
      baseURI - The base URI of the API
      endpoint - The endpoint of the API
      headers - The headers to include in the request
      contentType - The content type of the request
      Returns:
      The response received