Skip to content
Open
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
14 changes: 13 additions & 1 deletion src/main/com/sailthru/client/params/Send.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> vars;
protected Object schedule_time;
protected Map<String, Object> options;
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/main/com/sailthru/client/params/SendKey.java
Original file line number Diff line number Diff line change
@@ -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
}
27 changes: 27 additions & 0 deletions src/test/com/sailthru/client/params/SendTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> options = new HashMap<String, Object>();
Expand Down