-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor (Mailgun/Emails): Apply common SDKs naming to 'Emails'
- Loading branch information
Showing
7 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,26 @@ | |
import com.sinch.sample.BaseApplication; | ||
import com.sinch.sdk.domains.mailgun.api.v1.EmailsService; | ||
import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendEmailRequest; | ||
import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendEmailRequest.TrackingEnum; | ||
import com.sinch.sdk.domains.mailgun.models.v1.emails.response.SendEmailResponse; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.time.Instant; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.Arrays; | ||
import java.util.logging.Logger; | ||
|
||
public class Send extends BaseApplication { | ||
public class SendEmail extends BaseApplication { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(Send.class.getName()); | ||
private static final Logger LOGGER = Logger.getLogger(SendEmail.class.getName()); | ||
|
||
public Send() throws IOException {} | ||
public SendEmail() throws IOException {} | ||
|
||
public static void main(String[] args) { | ||
try { | ||
new Send().run(); | ||
new SendEmail().run(); | ||
} catch (Exception e) { | ||
LOGGER.severe(e.getMessage()); | ||
e.printStackTrace(); | ||
|
@@ -30,11 +33,11 @@ public void run() { | |
|
||
EmailsService service = client.mailgun().v1().emails(); | ||
|
||
LOGGER.info("Send message with Mailgun to: " + mailgunTo); | ||
LOGGER.info("Send email with Mailgun to: " + mailgunTo); | ||
|
||
SendEmailRequest parameters = createTextEmail(); | ||
|
||
SendEmailResponse response = service.send(mailgunDomain, parameters); | ||
SendEmailResponse response = service.sendEmail(mailgunDomain, parameters); | ||
|
||
LOGGER.info("Response: " + response); | ||
} | ||
|
@@ -70,13 +73,15 @@ SendEmailRequest createTextEmail() { | |
|
||
return SendEmailRequest.builder() | ||
.setFrom(mailgunFrom) | ||
.setTo(Arrays.asList(mailgunTo, "[email protected]")) | ||
.setTo(Arrays.asList(mailgunTo)) | ||
.setText("\uD83D\uDCE7 Text sent with Sinch SDK Java") | ||
.setHtml("📧 HTML sent with <bold>Sinch SDK Java</bold>") | ||
.setAttachment(Arrays.asList(tempFile, tempFile2)) | ||
.setSubject("\uD83D\uDCE7 Hello from Sinch SDK Java") | ||
.setTag(Arrays.asList("my tag 1", "my tag 2")) | ||
// .setTestMode(TestMode.YES) | ||
.setTracking(TrackingEnum.YES) | ||
.setDeliveryTime(Instant.now().plus(10, ChronoUnit.SECONDS)) | ||
.put("v:myvarkey", "myvar-value") | ||
.build(); | ||
} | ||
} |
This file contains 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