Created
November 14, 2014 23:13
-
-
Save demoore/6ac9f5a8afa32bc7a1ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
import com.sendwithus.SendWithUs; | |
import com.sendwithus.SendWithUsSendRequest; | |
import com.sendwithus.exception.SendWithUsException; | |
import com.sendwithus.model.DeactivatedDrips; | |
import com.sendwithus.model.Email; | |
import com.sendwithus.model.SendReceipt; | |
public class SendWithUsExample { | |
public static final String SENDWITHUS_API_KEY = "live_0c2b5084dc62c8ca7534b1315"; | |
public static final String EMAIL_ID_WELCOME_EMAIL = "tem_zq8QcRFjAasd4f"; | |
public static void main(String[] args) { | |
SendWithUs sendwithusAPI = new SendWithUs(SENDWITHUS_API_KEY); | |
// Send Welcome Email | |
Map<String, Object> recipientMap = new HashMap<String, Object>(); | |
recipientMap.put("name", "Dylan"); // optional | |
recipientMap.put("address", "[email protected]"); | |
// sender is optional | |
Map<String, Object> senderMap = new HashMap<String, Object>(); | |
senderMap.put("name", "Company"); // optional | |
senderMap.put("address", "[email protected]"); | |
senderMap.put("reply_to", "[email protected]"); // optional | |
// email data in to inject in the email template | |
Map<String, Object> emailDataMap = new HashMap<String, Object>(); | |
Map<String, Object> subMap = new HashMap<String, Object>(); | |
subMap.put("test", "hello"); | |
subMap.put("test2", "hello2"); | |
subMap.put("test3", "hello3"); | |
emailDataMap.put("first_name", "Brad"); | |
emailDataMap.put("link", "http://sendwithus.com/some_link"); | |
emailDataMap.put("items", subMap); | |
// Example sending a simple email | |
try { | |
SendReceipt sendReceipt = sendwithusAPI.send( | |
EMAIL_ID_WELCOME_EMAIL, | |
recipientMap, | |
senderMap, | |
emailDataMap | |
); | |
System.out.println(sendReceipt); | |
} catch (SendWithUsException e) { | |
System.out.println(e.toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment