Class Connector

java.lang.Object
com.testmonitor.api.Connector

public class Connector extends Object
  • Constructor Details

    • Connector

      public Connector(String domain, String token)
      Parameters:
      domain - The TestMonitor domain
      token - The auth token
  • Method Details

    • baseUrl

      protected String baseUrl()
      Returns:
      The TestMonitor API base url.
    • baseUrl

      protected String baseUrl(String path)
      Parameters:
      path - The path to concatenate
      Returns:
      The TestMonitor API base url.
    • get

      public org.json.JSONObject get(String uri) throws IOException
      Perform a GET request.
      Parameters:
      uri - A relative path
      Returns:
      The HTTP response as a JSONObject.
      Throws:
      IOException
    • get

      public org.json.JSONObject get(String uri, List<org.apache.hc.core5.http.NameValuePair> params) throws IOException, URISyntaxException
      Perform a GET request with GET parameters.
      Parameters:
      uri - A relative path
      params - Key/Value
      Returns:
      The HTTP response as a JSONObject.
      Throws:
      IOException
      URISyntaxException
    • post

      public org.json.JSONObject post(String uri, List<org.apache.hc.core5.http.NameValuePair> params) throws IOException
      Perform a POST request.
      Parameters:
      uri - A relative path
      params - The arguments to post
      Returns:
      The HTTP response as a JSONObject.
      Throws:
      IOException
    • put

      public org.json.JSONObject put(String uri, List<org.apache.hc.core5.http.NameValuePair> params) throws IOException
      Perform a PUT request.
      Parameters:
      uri - A relative path
      params - The arguments to put
      Returns:
      The HTTP response as a JSONObject.
      Throws:
      IOException
    • multiPartPost

      public org.json.JSONObject multiPartPost(String uri, List<org.apache.hc.core5.http.NameValuePair> params, HashMap<String,File> files) throws IOException
      Send a post request using multipart.
      Parameters:
      uri - A relative path
      params - The arguments to post
      files - The files to post
      Returns:
      The HTTP response as a JSONObject.
      Throws:
      IOException
    • postFile

      public org.json.JSONObject postFile(String uri, String name, File file) throws IOException
      Send an attachment.
      Parameters:
      uri - A relative path
      name - Field name
      file - The file attachment
      Returns:
      The HTTP response as a JSONObject.
      Throws:
      IOException
    • request

      public org.json.JSONObject request(org.apache.hc.client5.http.classic.methods.HttpUriRequestBase httpUriRequestBase) throws IOException
      Perform a request on teh TestMonitor API
      Parameters:
      httpUriRequestBase - The HTTP request
      Returns:
      HTTP response converted to JSON format
      Throws:
      IOException