Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</parent>

<properties>
<java-version>1.6</java-version>
<java-version>1.8</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -81,10 +81,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.8.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -172,7 +172,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version> <!-- 2.5 is the last version to support java 1.6 -->
<version>2.7</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand All @@ -199,7 +199,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public MandrillTemplatesApi(final String key, final String url) {
this.key = key;
this.rootUrl = url;
}

public MandrillTemplatesApi(final String key) {
this(key, MandrillApi.rootUrl);
}
Expand Down Expand Up @@ -314,7 +314,7 @@ public String render(final String name,
params.put("template_name", name);
if(templateContent != null && !templateContent.isEmpty()) {
final ArrayList<MandrillContentWrapper> contents =
new ArrayList<MandrillContentWrapper>(templateContent.size());
new ArrayList<>(templateContent.size());
for(String cName : templateContent.keySet()) {
contents.add( MandrillContentWrapper.create(
cName, templateContent.get(cName)) );
Expand All @@ -323,7 +323,7 @@ public String render(final String name,
}
if(mergeVars != null && !mergeVars.isEmpty()) {
final ArrayList<MandrillContentWrapper> vars =
new ArrayList<MandrillContentWrapper>(mergeVars.size());
new ArrayList<>(mergeVars.size());
for(String cName : mergeVars.keySet()) {
vars.add( MandrillContentWrapper.create(
cName, mergeVars.get(cName)) );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
*
*/
package com.microtripit.mandrillapp.lutung.controller;

Expand All @@ -21,12 +21,12 @@ final class MandrillUtil {
* @return
*/
protected static final HashMap<String,Object> paramsWithKey(final String key) {
final HashMap<String,Object> params = new HashMap<String,Object>();
final HashMap<String,Object> params = new HashMap<>();
params.put("key",key);
return params;

}

/**
* @param url
* @param params
Expand All @@ -35,13 +35,13 @@ protected static final HashMap<String,Object> paramsWithKey(final String key) {
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
protected static final <OUT> OUT query(final String url,
final Map<String,Object> params, Class<OUT> responseType)
protected static final <OUT> OUT query(final String url,
final Map<String,Object> params, Class<OUT> responseType)
throws MandrillApiError, IOException {
final MandrillRequest<OUT> requestModel =
new MandrillRequest<OUT>(url, params, responseType);

final MandrillRequest<OUT> requestModel =
new MandrillRequest<>(url, params, responseType);
return MandrillRequestDispatcher.execute(requestModel);

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
*
*/
package com.microtripit.mandrillapp.lutung.controller;

Expand All @@ -24,158 +24,158 @@ public MandrillWebhooksApi(final String key, final String url) {
this.key = key;
this.rootUrl = url;
}

public MandrillWebhooksApi(final String key) {
this(key, MandrillApi.rootUrl);
}

/**
* <p>Get the list of all webhooks defined for this account.</p>
* @return An array of {@link MandrillWebhook} objects.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook[] list() throws MandrillApiError,
public MandrillWebhook[] list() throws MandrillApiError,
IOException {

return MandrillUtil.query(
rootUrl+ "webhooks/list.json",
MandrillUtil.paramsWithKey(key),
rootUrl+ "webhooks/list.json",
MandrillUtil.paramsWithKey(key),
MandrillWebhook[].class);

}

/**
* <p>Add a new webhook.</p>
* @param url The URL to POST batches of events.
* @param event An optional event that will be posted
* @param event An optional event that will be posted
* to the webhook. You can use
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* as valid events.
* @return A {@link MandrillWebhook} object with info about the new webhook.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook add(final String url, final String event)
public MandrillWebhook add(final String url, final String event)
throws MandrillApiError, IOException {
final ArrayList<String> events = new ArrayList<String>(1);

final ArrayList<String> events = new ArrayList<>(1);
events.add(event);
return add(url, null, events);

}

/**
* <p>Add a new webhook.</p>
* @param url The URL to POST batches of events.
* @param events An optional collection of events
* @param events An optional collection of events
* that will be posted to the webhook. You can use
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* as valid events.
* @return A {@link MandrillWebhook} object with info about the new webhook.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook add(final String url,
final Collection<String> events) throws MandrillApiError,
public MandrillWebhook add(final String url,
final Collection<String> events) throws MandrillApiError,
IOException {

return add(url, null, events);

}

/**
* <p>Add a new webhook.</p>
* @param url The URL to POST batches of events.
* @param description An optional description of the webhook.
* @param events An optional array of events that will
* @param events An optional array of events that will
* be posted to the webhook. You can use
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* as valid events.
* @return A {@link MandrillWebhook} object with info about the new webhook.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook add(final String url, final String description,
public MandrillWebhook add(final String url, final String description,
final Collection<String> events) throws MandrillApiError, IOException {

final HashMap<String,Object> params = MandrillUtil.paramsWithKey(key);
params.put("url", url);
params.put("description", description);
params.put("events", events);
return MandrillUtil.query(rootUrl+ "webhooks/add.json",
return MandrillUtil.query(rootUrl+ "webhooks/add.json",
params, MandrillWebhook.class);

}

/**
* <p>Get the data about an existing webhook.</p>
* @param id The unique identifier of a webhook belonging to this account.
* @return A {@link MandrillWebhook} object with info about the webhook.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook info(final Integer id)
public MandrillWebhook info(final Integer id)
throws MandrillApiError, IOException {

final HashMap<String,Object> params = MandrillUtil.paramsWithKey(key);
params.put("id", id);
return MandrillUtil.query(rootUrl+ "webhooks/info.json",
return MandrillUtil.query(rootUrl+ "webhooks/info.json",
params, MandrillWebhook.class);

}

/**
* <p>Update an existing webhook.</p>
* @param id The unique identifier of a webhook belonging to this account.
* @param url The URL to POST batches of events.
* @param event An optional events that will be posted to the webhook. You can use
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* {@link MandrillWebhook#SEND}, {@link MandrillWebhook#HARD_BOUNCE},
* {@link MandrillWebhook#SOFT_BOUNCE}, {@link MandrillWebhook#OPEN},
* {@link MandrillWebhook#CLICK}, {@link MandrillWebhook#SPAM},
* {@link MandrillWebhook#UNSUB} and {@link MandrillWebhook#REJECT}
* as valid events.
* @return A {@link MandrillWebhook} object with info about the webhook.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook update(final Integer id,
final String url, final String event)
public MandrillWebhook update(final Integer id,
final String url, final String event)
throws MandrillApiError, IOException {
final ArrayList<String> events = new ArrayList<String>(1);

final ArrayList<String> events = new ArrayList<>(1);
events.add(event);
return update(id, url, events);

}

/**
* <p>Update an existing webhook.</p>
* @param id The unique identifier of a webhook
* @param id The unique identifier of a webhook
* belonging to this account.
* @param url The URL to POST batches of events.
* @param events An optional collection of events that will be posted to the webhook.
* @return A {@link MandrillWebhook} object with info about the webhook.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook update(final Integer id,
final String url, final Collection<String> events)
public MandrillWebhook update(final Integer id,
final String url, final Collection<String> events)
throws MandrillApiError, IOException {

return update(id, url, null, events);

}

/**
* <p>Update an existing webhook.</p>
* @param id The unique identifier of a webhook belonging to this account.
Expand All @@ -186,34 +186,34 @@ public MandrillWebhook update(final Integer id,
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook update(final Integer id, final String url,
final String description, final Collection<String> events)
public MandrillWebhook update(final Integer id, final String url,
final String description, final Collection<String> events)
throws MandrillApiError, IOException {

final HashMap<String,Object> params = MandrillUtil.paramsWithKey(key);
params.put("id", id);
params.put("url", url);
params.put("description", description);
params.put("events", events);
return MandrillUtil.query(rootUrl+ "webhooks/update.json",
return MandrillUtil.query(rootUrl+ "webhooks/update.json",
params, MandrillWebhook.class);

}

/**
* <p>Delete an existing webhook.</p>
* @param id The unique identifier of a webhook belonging to this account.
* @return A {@link MandrillWebhook} object with info about the just deleted webhook.
* @throws MandrillApiError Mandrill API Error
* @throws IOException IO Error
*/
public MandrillWebhook delete(final Integer id)
public MandrillWebhook delete(final Integer id)
throws MandrillApiError, IOException {

final HashMap<String,Object> params = MandrillUtil.paramsWithKey(key);
params.put("id", id);
return MandrillUtil.query(rootUrl+ "webhooks/delete.json",
return MandrillUtil.query(rootUrl+ "webhooks/delete.json",
params, MandrillWebhook.class);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final Date deserialize(final JsonElement json,

if(!json.isJsonPrimitive()) {
throw new JsonParseException(
"Unexpected type for date: " +json.toString());
Comment thread
dnovitski marked this conversation as resolved.
"Unexpected type for date: " + json);

}
try {
Expand Down Expand Up @@ -118,7 +118,7 @@ public final MandrillMessage.Recipient.Type deserialize(

if(!json.isJsonPrimitive()) {
throw new JsonParseException(
"Unexpected type for recipient type: " +json.toString());
"Unexpected type for recipient type: " + json);
}

return MandrillMessage.Recipient.Type.valueOf(
Expand Down
Loading