Class ApiHelper


  • public class ApiHelper
    extends Object
    Author:
    mitchel.k@breachlock.com
    • Constructor Detail

      • ApiHelper

        public ApiHelper()
        Create a new HTTP client
    • Method Detail

      • parseJSON

        public org.json.simple.JSONArray parseJSON​(String json)
        Parse string as JSON.
        Parameters:
        json - String of JSON data
        Returns:
        JSONArray
      • setEndpoint

        public void setEndpoint​(String endpoint)
        Set and endpoint to for the base path.
        Parameters:
        endpoint - Endpoint to visit
      • setFormBody

        public void setFormBody​(okhttp3.RequestBody formBody)
        Set form content for POST requests.
        Parameters:
        formBody - Build form data
      • getBasePath

        public String getBasePath()
        Get the base path to the API.
        Returns:
        Return path to the API
      • getRequest

        public String getRequest()
        Perform a HTTP GET-request.
        Returns:
        Parse body content
      • postRequest

        public String postRequest()
        Perform a HTTP POT-request.
        Returns:
        Parse body content