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 actionID
    MailjetRequest​(Resource res, java.lang.String id)
    In case of a simple view.
  • Method Summary

    Modifier and Type Method Description
    MailjetRequest append​(java.lang.String key, java.lang.Object value)
    Append a value to the body[key]
    java.lang.String buildUrl​(java.lang.String baseApiUrl)
    Build the call URL with query string parameters
    MailjetRequest filter​(java.lang.String key, int value)
    Add a String/int filter to the _filters hash
    MailjetRequest filter​(java.lang.String key, java.lang.String value)
    Add a String-String filter to the the _filters hash
    java.lang.String getBody()
    Body getter
    org.json.JSONObject getBodyJSON()
    Body JSON getter
    java.lang.String getContentType()
    Returns the appropriate Content-Type according to the resource/action
    MailjetRequest property​(java.lang.String key, java.lang.Object value)
    Add a property to the body JSONObject
    java.lang.String queryString()
    Build a query string using the _filters hash
    MailjetRequest setBody​(java.lang.String json)
    Pass a String formatted json as the request body
    MailjetRequest setBody​(java.util.HashMap<java.lang.String,​java.lang.Object> json)
    Use an HashMap to build the body
    MailjetRequest setBody​(org.json.JSONObject json)
    Pass a JSONObject formatted json as the request body
    MailjetRequest setData​(java.lang.String path)  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MailjetRequest

      public MailjetRequest​(Resource res)
      Make a Mailjet request with a single resource.
      Parameters:
      res -
    • MailjetRequest

      public MailjetRequest​(Resource res, long id)
      In case of a simple view. Call a single resource with a single ID
      Parameters:
      res -
      id -
    • MailjetRequest

      public MailjetRequest​(Resource res, java.lang.String id)
      In case of a simple view. Call a single resource with a single ID
      Parameters:
      res -
      id -
    • MailjetRequest

      public MailjetRequest​(Resource res, long id, long actionid)
      Build a Request with an actionID
      Parameters:
      res - the resource object
      id - the resource ID
      actionid - the resource action ID
  • Method Details

    • setData

      public MailjetRequest setData​(java.lang.String path) throws java.io.IOException
      Throws:
      java.io.IOException
    • setBody

      public MailjetRequest setBody​(java.lang.String json)
      Pass a String formatted json as the request body
      Parameters:
      json -
      Returns:
      the request itself
    • setBody

      public MailjetRequest setBody​(org.json.JSONObject json)
      Pass a JSONObject formatted json as the request body
      Parameters:
      json -
      Returns:
      the request itself
    • setBody

      public MailjetRequest setBody​(java.util.HashMap<java.lang.String,​java.lang.Object> json)
      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.UnsupportedEncodingException
      Build the call URL with query string parameters
      Returns:
      url
      Throws:
      java.io.UnsupportedEncodingException
    • append

      public MailjetRequest append​(java.lang.String key, java.lang.Object value)
      Append a value to the body[key]
      Parameters:
      key - the key
      value - the value to be pushed
      Returns:
      the Mailjet Request itslef
    • filter

      public MailjetRequest filter​(java.lang.String key, java.lang.String value)
      Add a String-String filter to the the _filters hash
      Parameters:
      key -
      value -
      Returns:
      the request itself
    • filter

      public MailjetRequest filter​(java.lang.String key, int value)
      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.UnsupportedEncodingException
      Build a query string using the _filters hash
      Returns:
      a query string
      Throws:
      java.io.UnsupportedEncodingException
    • property

      public MailjetRequest property​(java.lang.String key, java.lang.Object value)
      Add a property to the body JSONObject
      Parameters:
      key - property name
      value - property value
      Returns:
      the request itself
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object