Package cloud.metaapi.sdk.clients
Class HttpRequestOptions
- java.lang.Object
-
- cloud.metaapi.sdk.clients.HttpRequestOptions
-
public class HttpRequestOptions extends Object
Options for HttpClient requests
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpRequestOptions.FileStreamFieldFile field wrapper for use in form data body.static classHttpRequestOptions.MethodRepresents HTTP request methods supported by HttpClient
-
Constructor Summary
Constructors Constructor Description HttpRequestOptions(String url, HttpRequestOptions.Method method)Constructs HttpRequestOptions instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Map<String,Object>>getBodyFields()Returns fields of the request form data bodyOptional<Object>getBodyJson()Returns the json body of a requestMap<String,String>getHeaders()Returns headers of request.HttpRequestOptions.MethodgetMethod()Returns HTTP method used for requestMap<String,Object>getQueryParameters()Returns query parameters of request.StringgetUrl()Returns URL used for requestvoidsetBody(Object jsonBody)Sets the json body of a request.voidsetBody(Map<String,Object> fields)Sets the form data body of a request.voidsetMethod(HttpRequestOptions.Method method)Sets HTTP method used for requestvoidsetUrl(String url)Sets URL used for request
-
-
-
Constructor Detail
-
HttpRequestOptions
public HttpRequestOptions(String url, HttpRequestOptions.Method method)
Constructs HttpRequestOptions instance- Parameters:
url- request URLmethod- request method
-
-
Method Detail
-
setUrl
public void setUrl(String url)
Sets URL used for request- Parameters:
url- new request URL
-
getUrl
public String getUrl()
Returns URL used for request- Returns:
- request URL
-
setMethod
public void setMethod(HttpRequestOptions.Method method)
Sets HTTP method used for request- Parameters:
method- supported by HttpClient HTTP method
-
getMethod
public HttpRequestOptions.Method getMethod()
Returns HTTP method used for request- Returns:
- request method
-
getQueryParameters
public Map<String,Object> getQueryParameters()
Returns query parameters of request. The returned value can be used for setting parameters.- Returns:
- map of query parameters where the key is the parameter name and the value is its
parsable into a string value. The value cal also be a
Collectionof parsable into a string values.
-
getHeaders
public Map<String,String> getHeaders()
Returns headers of request. The returned value can be used for setting parameters.- Returns:
- map of headers where the key is the header name and the value is the header value
-
setBody
public void setBody(Object jsonBody)
Sets the json body of a request. If there already is a form data body, it will be erased.- Parameters:
jsonBody- object that will be automatically converted into a json string
-
setBody
public void setBody(Map<String,Object> fields)
Sets the form data body of a request. If there already is a json body, it will erased.- Parameters:
fields- map of form fields where the key is the name of a field and the value should be an object that can be parsed as a string, but for files you should useHttpRequestOptions.FileStreamField
-
getBodyJson
public Optional<Object> getBodyJson()
Returns the json body of a request- Returns:
- optional object that can contain json body of a request in its object form
-
-