Package com.breachlock.helpers
Class ApiHelper
- java.lang.Object
-
- com.breachlock.helpers.ApiHelper
-
public class ApiHelper extends Object
- Author:
- mitchel.k@breachlock.com
-
-
Constructor Summary
Constructors Constructor Description ApiHelper()Create a new HTTP client
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetBasePath()Get the base path to the API.StringgetRequest()Perform a HTTP GET-request.org.json.simple.JSONArrayparseJSON(String json)Parse string as JSON.StringpostRequest()Perform a HTTP POT-request.voidsetEndpoint(String endpoint)Set and endpoint to for the base path.voidsetFormBody(okhttp3.RequestBody formBody)Set form content for POST requests.
-
-
-
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
-
-