Class Connector

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

public class Connector extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Connector(String domain, String token)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
     
    protected String
     
    org.json.JSONObject
    get(String uri)
    Perform a GET request.
    org.json.JSONObject
    get(String uri, List<org.apache.hc.core5.http.NameValuePair> params)
    Perform a GET request with GET parameters.
    org.json.JSONObject
    post(String uri, List<org.apache.hc.core5.http.NameValuePair> params)
    Perform a POST request.
    org.json.JSONObject
    Send an attachment.
    org.json.JSONObject
    put(String uri, List<org.apache.hc.core5.http.NameValuePair> params)
    Perform a PUT request.
    org.json.JSONObject
    request(org.apache.hc.client5.http.classic.methods.HttpUriRequestBase httpUriRequestBase)
    Perform a request on teh TestMonitor API

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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
    • postAttachment

      public org.json.JSONObject postAttachment(String uri, File file) throws IOException
      Send an attachment.
      Parameters:
      uri - A relative path
      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