Package com.mailjet.client
Class MailjetRequest
java.lang.Object
com.mailjet.client.MailjetRequest
public class MailjetRequest
extends java.lang.Object
- Author:
- Guillaume Badi - Mailjet
-
Constructor Summary
Constructors Constructor Description MailjetRequest(Resource res)Make a Mailjet request with a single resource.MailjetRequest(Resource res, long id)In case of a simple view.MailjetRequest(Resource res, long id, long actionid)Build a Request with an actionIDMailjetRequest(Resource res, java.lang.String id)In case of a simple view. -
Method Summary
Modifier and Type Method Description MailjetRequestappend(java.lang.String key, java.lang.Object value)Append a value to the body[key]java.lang.StringbuildUrl(java.lang.String baseApiUrl)Build the call URL with query string parametersMailjetRequestfilter(java.lang.String key, int value)Add a String/int filter to the _filters hashMailjetRequestfilter(java.lang.String key, java.lang.String value)Add a String-String filter to the the _filters hashjava.lang.StringgetBody()Body getterorg.json.JSONObjectgetBodyJSON()Body JSON getterjava.lang.StringgetContentType()Returns the appropriate Content-Type according to the resource/actionMailjetRequestproperty(java.lang.String key, java.lang.Object value)Add a property to the body JSONObjectjava.lang.StringqueryString()Build a query string using the _filters hashMailjetRequestsetBody(java.lang.String json)Pass a String formatted json as the request bodyMailjetRequestsetBody(java.util.HashMap<java.lang.String,java.lang.Object> json)Use an HashMap to build the bodyMailjetRequestsetBody(org.json.JSONObject json)Pass a JSONObject formatted json as the request bodyMailjetRequestsetData(java.lang.String path)java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
MailjetRequest
Make a Mailjet request with a single resource.- Parameters:
res-
-
MailjetRequest
In case of a simple view. Call a single resource with a single ID- Parameters:
res-id-
-
MailjetRequest
In case of a simple view. Call a single resource with a single ID- Parameters:
res-id-
-
MailjetRequest
Build a Request with an actionID- Parameters:
res- the resource objectid- the resource IDactionid- the resource action ID
-
-
Method Details
-
setData
- Throws:
java.io.IOException
-
setBody
Pass a String formatted json as the request body- Parameters:
json-- Returns:
- the request itself
-
setBody
Pass a JSONObject formatted json as the request body- Parameters:
json-- Returns:
- the request itself
-
setBody
Use an HashMap to build the body- Parameters:
json-- Returns:
- the request itself
-
getBody
public java.lang.String getBody()Body getter- Returns:
- the stringified body
-
getBodyJSON
public org.json.JSONObject getBodyJSON()Body JSON getter- Returns:
- the body as JSONObject
-
getContentType
public java.lang.String getContentType()Returns the appropriate Content-Type according to the resource/action- Returns:
- Content-Type
-
buildUrl
public java.lang.String buildUrl(java.lang.String baseApiUrl) throws java.io.UnsupportedEncodingExceptionBuild the call URL with query string parameters- Returns:
- url
- Throws:
java.io.UnsupportedEncodingException
-
append
Append a value to the body[key]- Parameters:
key- the keyvalue- the value to be pushed- Returns:
- the Mailjet Request itslef
-
filter
Add a String-String filter to the the _filters hash- Parameters:
key-value-- Returns:
- the request itself
-
filter
Add a String/int filter to the _filters hash- Parameters:
key-value-- Returns:
- the request itself
-
queryString
public java.lang.String queryString() throws java.io.UnsupportedEncodingExceptionBuild a query string using the _filters hash- Returns:
- a query string
- Throws:
java.io.UnsupportedEncodingException
-
property
Add a property to the body JSONObject- Parameters:
key- property namevalue- property value- Returns:
- the request itself
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-