diff --git a/src/main/com/sailthru/client/params/Send.java b/src/main/com/sailthru/client/params/Send.java index cc218f4..b02df98 100644 --- a/src/main/com/sailthru/client/params/Send.java +++ b/src/main/com/sailthru/client/params/Send.java @@ -16,9 +16,11 @@ public class Send extends AbstractApiParams implements ApiParams { public static final String PARAM_SEND_ID = "send_id"; - protected String send_id; + protected String send_id; protected String template; protected String email; + protected SendKey key; + protected String id; protected Map vars; protected Object schedule_time; protected Map options; @@ -38,6 +40,16 @@ public Send setEmail(String email) { return this; } + public Send setKey(SendKey key) { + this.key = key; + return this; + } + + public Send setId(String id) { + this.id = id; + return this; + } + public Send setTemplate(String template) { this.template = template; return this; diff --git a/src/main/com/sailthru/client/params/SendKey.java b/src/main/com/sailthru/client/params/SendKey.java new file mode 100644 index 0000000..de7a6d8 --- /dev/null +++ b/src/main/com/sailthru/client/params/SendKey.java @@ -0,0 +1,9 @@ +package com.sailthru.client.params; + +import com.google.gson.annotations.SerializedName; + +public enum SendKey { + @SerializedName("profile_id") PROFILE_ID, + @SerializedName("sid") SID, + @SerializedName("device_id") DEVICE_ID +} diff --git a/src/test/com/sailthru/client/params/SendTest.java b/src/test/com/sailthru/client/params/SendTest.java index a30db60..cec5f11 100644 --- a/src/test/com/sailthru/client/params/SendTest.java +++ b/src/test/com/sailthru/client/params/SendTest.java @@ -205,6 +205,33 @@ public void testSetBehalfEmail(){ assertEquals(expected, result); } + @Test + public void testSetKeyProfileId() { + send.setKey(SendKey.PROFILE_ID).setId("507f1f77bcf86cd799439011"); + + String expected = "{\"key\":\"profile_id\",\"id\":\"507f1f77bcf86cd799439011\",\"options\":{}}"; + String result = gson.toJson(send); + assertEquals(expected, result); + } + + @Test + public void testSetKeySid() { + send.setKey(SendKey.SID).setId("507f1f77bcf86cd799439011"); + + String expected = "{\"key\":\"sid\",\"id\":\"507f1f77bcf86cd799439011\",\"options\":{}}"; + String result = gson.toJson(send); + assertEquals(expected, result); + } + + @Test + public void testSetKeyDeviceId() { + send.setKey(SendKey.DEVICE_ID).setId("abc123devicetoken"); + + String expected = "{\"key\":\"device_id\",\"id\":\"abc123devicetoken\",\"options\":{}}"; + String result = gson.toJson(send); + assertEquals(expected, result); + } + @Test public void testSetOptions(){ Map options = new HashMap();