SendWithUs { public SendReceipt send(String emailId, Map<String, Object> recipient, Map<String, Object> emailData) throws SendWithUsException { return this.send(emailId, recipient, null, emailData); } SendWithUs(String apiKey);  SendWithUs(String apiKey, SendWithUsApiLocation sendWithUsApiLocation); @Deprecated Email[] emails(); Email[] templates(); Email template(String templateId); Email template(String templateId, String locale); TemplateVersionDetails templateVersion(String templateId, String versionId); TemplateVersionDetails templateVersion(String templateId, String versionId, String locale); SendReceipt send(String emailId, Map<String, Object> recipient,
            Map<String, Object> emailData); SendReceipt send(String emailId, Map<String, Object> recipient,
            Map<String, Object> sender, Map<String, Object> emailData); SendReceipt send(String emailId, Map<String, Object> recipient,
            Map<String, Object> sender, Map<String, Object> emailData,
            Map<String, Object>[] cc); SendReceipt send(String emailId, Map<String, Object> recipient,
            Map<String, Object> sender, Map<String, Object> emailData,
            Map<String, Object>[] cc, Map<String, Object>[] bcc); SendReceipt send(String emailId, Map<String, Object> recipient,
            Map<String, Object> sender, Map<String, Object> emailData,
            Map<String, Object>[] cc, Map<String, Object>[] bcc,
            String[] attachment_paths); SendReceipt send(String emailId, Map<String, Object> recipient,
            Map<String, Object> sender, Map<String, Object> emailData,
            Map<String, Object>[] cc, Map<String, Object>[] bcc,
            String[] attachment_paths, String espAccount); SendReceipt send(String emailId, Map<String, Object> recipient,
                            Map<String, Object> sender, Map<String, Object> emailData,
                            Map<String, Object>[] cc, Map<String, Object>[] bcc,
                            String[] attachment_paths, String espAccount,
                            String locale); SendReceipt send(String emailId, Map<String, Object> recipient,
                            Map<String, Object> sender, Map<String, Object> emailData,
                            Map<String, Object>[] cc, Map<String, Object>[] bcc,
                            String[] attachment_paths, String espAccount,
                            String locale, Map<String, String> headers); SendReceipt send(SendWithUsSendRequest request); RenderedTemplate render(String templateId,
            Map<String, Object> templateData); ActivatedDrip startOnDripCampaign(String dripCampaignId, SendWithUsDripRequest dripRequest); DeactivatedDrip removeFromDripCampaign(String customerEmailAddress, String dripCampaignId ); DeactivatedDrips deactivateDrips(String customerEmailAddress); CustomerReceipt createUpdateCustomer(String customerEmailAddress,
            Map<String, Object> customerData); SendReceipt resend(String logId); Snippet[] getSnippets(); Snippet getSnippet(String snippetId); SnippetReceipt createSnippet(String name, String body); SnippetReceipt updateSnippet(String snippetId, String name, String body); APIReceipt deleteSnippet(String snippetId); static final String CLIENT_VERSION; static final String CLIENT_LANG; static final String SWU_API_HEADER; static final String SWU_CLIENT_HEADER; }
@Test public void testSendWithHeaders() throws SendWithUsException { Map<String, String> headers = new HashMap<String, String>(); headers.put("X-Auto-Response-Suppress", "header-value"); SendWithUsSendRequest request = new SendWithUsSendRequest() .setEmailId(EMAIL_ID).setRecipient(defaultRecipientParams) .setSender(defaultSenderParams).setEmailData(defaultDataParams) .setHeaders(headers); SendReceipt sendReceipt = sendwithusAPI.send(request); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSendWithSWURequestObject() throws SendWithUsException { String espAccount = ""; SendWithUsSendRequest request = new SendWithUsSendRequest() .setEmailId(EMAIL_ID).setRecipient(defaultRecipientParams) .setSender(defaultSenderParams).setEmailData(defaultDataParams) .setEspAccount(espAccount); SendReceipt sendReceipt = sendwithusAPI.send(request); assertSuccessfulAPIReceipt(sendReceipt); }
@Test(expected = SendWithUsException.class) public void testSendIncomplete() throws SendWithUsException { sendwithusAPI.send(EMAIL_ID, invalidRecipientParams, defaultDataParams); }
@Test(expected = SendWithUsException.class) public void testSendInvalidAPIKey() throws SendWithUsException { SendWithUs invalidAPI = new SendWithUs("SWUTEST_INVALID_KEY"); invalidAPI.send(EMAIL_ID, defaultRecipientParams, defaultDataParams); }
@Test(expected = SendWithUsException.class) public void testSendInvalidEmailId() throws SendWithUsException { sendwithusAPI.send("SWUTEST_INVALID_EMAIL_ID", defaultRecipientParams, defaultDataParams); }
@Test public void testSendArrayInData() throws SendWithUsException { defaultDataParams.put("array", new String[] { "send", "with", "us" }); SendReceipt sendReceipt = sendwithusAPI.send(EMAIL_ID, defaultRecipientParams, defaultDataParams); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSendArrayListInData() throws SendWithUsException { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("send"); arrayList.add("with"); arrayList.add("us"); defaultDataParams.put("arrayList", arrayList); SendReceipt sendReceipt = sendwithusAPI.send(EMAIL_ID, defaultRecipientParams, defaultDataParams); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSimpleSend() throws SendWithUsException { SendReceipt sendReceipt = sendwithusAPI.send(EMAIL_ID, defaultRecipientParams, defaultDataParams); assertSuccessfulAPIReceipt(sendReceipt); assertNotNull(sendReceipt.getEmail()); assertEquals(sendReceipt.getEmail().getLocale(), "en-US"); }
@Test public void testSendWithSender() throws SendWithUsException { SendReceipt sendReceipt = sendwithusAPI.send(EMAIL_ID, defaultRecipientParams, defaultSenderParams, defaultDataParams); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSendWithAttachment() throws SendWithUsException { String[] str = { "test.png", "test.png" }; SendReceipt sendReceipt = sendwithusAPI.send(EMAIL_ID, defaultRecipientParams, defaultSenderParams, defaultDataParams, null, null, str); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSendWithEmptyAttachment() throws SendWithUsException { String[] str = {}; SendReceipt sendReceipt = sendwithusAPI.send(EMAIL_ID, defaultRecipientParams, defaultSenderParams, defaultDataParams, null, null, str); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSendWithEspAccount() throws SendWithUsException { String espAccount = ""; SendReceipt sendReceipt = sendwithusAPI.send(EMAIL_ID, defaultRecipientParams, defaultSenderParams, defaultDataParams, null, null, null, espAccount); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSendWithVersionName() throws SendWithUsException { String versionName = ""; SendWithUsSendRequest request = new SendWithUsSendRequest() .setEmailId(EMAIL_ID).setRecipient(defaultRecipientParams) .setSender(defaultSenderParams).setEmailData(defaultDataParams) .setVersionName(versionName); SendReceipt sendReceipt = sendwithusAPI.send(request); assertSuccessfulAPIReceipt(sendReceipt); }
@Test public void testSendWithLocale() throws SendWithUsException { String locale = "en-US"; SendWithUsSendRequest request = new SendWithUsSendRequest() .setEmailId(EMAIL_ID).setRecipient(defaultRecipientParams) .setSender(defaultSenderParams).setEmailData(defaultDataParams) .setLocale(locale); SendReceipt sendReceipt = sendwithusAPI.send(request); assertSuccessfulAPIReceipt(sendReceipt); }