Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#33 Refactor methods according to Java convention #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public Email toEmail() {

Collections.addAll(email.tags, tags);

email.AddRecipient(recipient.toRecipient());
email.addRecipient(recipient.toRecipient());

return email;
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/mailersend/sdk/emails/Attachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@ public class Attachment {

@SerializedName("id")
public String id;



/**
* Reads a file, encodes it to base64 and sets it as an attachment
*
* @param path a {@link java.lang.String} object.
* @throws java.io.IOException
*/
public void AddAttachmentFromFile(String path) throws IOException {
public void addAttachmentFromFile(String path) throws IOException {
File file = new File(path);
this.content = Base64.getEncoder().encodeToString(FileUtils.readFileToByteArray(file));
this.filename = file.getName();
}



/**
* Sets an attachments contents and filename
*
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/mailersend/sdk/emails/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void addRecipient(String name, String email) {
*
* @param recipient a {@link com.mailersend.sdk.Recipient} object.
*/
public void AddRecipient(Recipient recipient) {
public void addRecipient(Recipient recipient) {

this.recipients.add(recipient);
}
Expand All @@ -109,7 +109,7 @@ public void AddRecipient(Recipient recipient) {
*
* @param recipients an array of {@link com.mailersend.sdk.Recipient} objects.
*/
public void AddRecipients(Recipient[] recipients) {
public void addRecipients(Recipient[] recipients) {

this.recipients.addAll( Arrays.asList( recipients ) );
}
Expand All @@ -121,7 +121,7 @@ public void AddRecipients(Recipient[] recipients) {
* @param name a {@link java.lang.String} object.
* @param email a {@link java.lang.String} object.
*/
public void AddCc(String name, String email) {
public void addCc(String name, String email) {

Recipient recipient = new Recipient(name, email);
this.cc.add(recipient);
Expand All @@ -133,7 +133,7 @@ public void AddCc(String name, String email) {
*
* @param recipient a {@link com.mailersend.sdk.Recipient} object.
*/
public void AddCc(Recipient recipient) {
public void addCc(Recipient recipient) {

this.cc.add(recipient);
}
Expand All @@ -145,7 +145,7 @@ public void AddCc(Recipient recipient) {
* @param name a {@link java.lang.String} object.
* @param email a {@link java.lang.String} object.
*/
public void AddBcc(String name, String email) {
public void addBcc(String name, String email) {

Recipient recipient = new Recipient(name, email);
this.bcc.add(recipient);
Expand All @@ -157,7 +157,7 @@ public void AddBcc(String name, String email) {
*
* @param recipient a {@link com.mailersend.sdk.Recipient} object.
*/
public void AddBcc(Recipient recipient) {
public void addBcc(Recipient recipient) {

this.bcc.add(recipient);
}
Expand All @@ -168,7 +168,7 @@ public void AddBcc(Recipient recipient) {
*
* @param replyTo a {@link com.mailersend.sdk.Recipient} object.
*/
public void AddReplyTo(Recipient replyTo) {
public void addReplyTo(Recipient replyTo) {

this.replyTo = replyTo;
}
Expand All @@ -180,7 +180,7 @@ public void AddReplyTo(Recipient replyTo) {
* @param name a {@link java.lang.String} object.
* @param email a {@link java.lang.String} object.
*/
public void AddReplyTo(String name, String email) {
public void addReplyTo(String name, String email) {

this.replyTo = new Recipient(name, email);
}
Expand Down Expand Up @@ -317,7 +317,7 @@ public void addPersonalization(String name, Object value) {
* @param variable a {@link java.lang.String} object.
* @param value a {@link java.lang.String} object.
*/
public void AddVariable(Recipient recipient, String variable, String value) {
public void addVariable(Recipient recipient, String variable, String value) {

// check if there is already a variable object for this recipient
Variable var = null;
Expand Down Expand Up @@ -351,7 +351,7 @@ public void AddVariable(Recipient recipient, String variable, String value) {
* @param name a {@link java.lang.String} object.
* @param value a {@link java.lang.String} object.
*/
public void AddVariable(String name, String value) {
public void addVariable(String name, String value) {

this.allRecipientsSubstitutions.put(name, value);
}
Expand All @@ -362,7 +362,7 @@ public void AddVariable(String name, String value) {
*
* @param tag a {@link java.lang.String} object.
*/
public void AddTag(String tag) {
public void addTag(String tag) {

tags.add(tag);
}
Expand All @@ -377,7 +377,7 @@ public void AddTag(String tag) {
public void attachFile(String path) throws IOException {

Attachment attachment = new Attachment();
attachment.AddAttachmentFromFile(path);
attachment.addAttachmentFromFile(path);

this.attachments.add(attachment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ public void TestMultipleRecipientsPersonalization() {
Email email = new Email();

Recipient firstRecipient = new Recipient(TestHelper.toName, TestHelper.toEmail);
email.AddRecipient(firstRecipient);
email.addRecipient(firstRecipient);

Recipient secondRecipient = new Recipient(recipient2Name, recipient2Email);
email.AddRecipient(secondRecipient);
email.addRecipient(secondRecipient);

email.addPersonalization(firstRecipient, personalizationName, personalizationValue);
email.addPersonalization(secondRecipient, secondPName, secondPValue);
Expand Down Expand Up @@ -180,15 +180,15 @@ public void TestCcRecipients() {
Email email = TestHelper.createBasicEmail(false);

// test adding the recipient directly
email.AddCc(ccRecipient1.name, ccRecipient1.email);
email.addCc(ccRecipient1.name, ccRecipient1.email);

assertEquals(email.cc.size(), 1);

assertTrue(email.cc.get(0).name.equals(ccRecipient1.name));
assertTrue(email.cc.get(0).email.equals(ccRecipient1.email));

// test adding the recipient object
email.AddCc(ccRecipient2);
email.addCc(ccRecipient2);

assertEquals(email.cc.size(), 2);

Expand All @@ -209,15 +209,15 @@ public void TestBccRecipients() {
Email email = TestHelper.createBasicEmail(false);

// test adding the recipient directly
email.AddBcc(bccRecipient1.name, bccRecipient1.email);
email.addBcc(bccRecipient1.name, bccRecipient1.email);

assertEquals(email.bcc.size(), 1);

assertTrue(email.bcc.get(0).name.equals(bccRecipient1.name));
assertTrue(email.bcc.get(0).email.equals(bccRecipient1.email));

// test adding the recipient object
email.AddBcc(bccRecipient2);
email.addBcc(bccRecipient2);

assertEquals(email.bcc.size(), 2);

Expand Down
10 changes: 4 additions & 6 deletions src/test/java/com/mailersend/sdk/tests/EmailSendTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import java.util.Calendar;
import java.util.Date;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
Expand Down Expand Up @@ -118,7 +116,7 @@ public void TestSimpleSend() {
email.text = TestHelper.text;

email.addRecipient(TestHelper.toName, TestHelper.toEmail);
email.AddReplyTo(new Recipient(TestHelper.fromName, TestHelper.emailFrom));
email.addReplyTo(new Recipient(TestHelper.fromName, TestHelper.emailFrom));

email.setFrom(TestHelper.fromName, TestHelper.emailFrom);

Expand Down Expand Up @@ -172,7 +170,7 @@ public void TestCcSend() {

Email email = TestHelper.createBasicEmail(false);

email.AddCc(TestHelper.ccName, TestHelper.ccEmail);
email.addCc(TestHelper.ccName, TestHelper.ccEmail);

MailerSend ms = new MailerSend();
ms.setToken(TestHelper.validToken);
Expand All @@ -197,7 +195,7 @@ public void TestBccSend() {

Email email = TestHelper.createBasicEmail(false);

email.AddBcc(TestHelper.bccName, TestHelper.bccEmail);
email.addBcc(TestHelper.bccName, TestHelper.bccEmail);

MailerSend ms = new MailerSend();
ms.setToken(TestHelper.validToken);
Expand Down Expand Up @@ -305,7 +303,7 @@ public void ScheduleEmailTest() {
email.text = TestHelper.text;

email.addRecipient(TestHelper.toName, TestHelper.toEmail);
email.AddReplyTo(new Recipient(TestHelper.fromName, TestHelper.emailFrom));
email.addReplyTo(new Recipient(TestHelper.fromName, TestHelper.emailFrom));

email.setFrom(TestHelper.fromName, TestHelper.emailFrom);

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"6b15cf69672ee532a9f601876778851cc4ca3135":{"body":"","headers":{":status":["202"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["755442149ddbeea0-ATH"],"content-type":["text/html; charset\u003dUTF-8"],"date":["Wed, 05 Oct 2022 06:56:34 GMT"],"server":["cloudflare"],"strict-transport-security":["max-age\u003d15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-10-06T00:00:00Z"],"x-message-id":["633d2aa226762ac1d30457e0"],"x-ratelimit-limit":["120"],"x-ratelimit-remaining":["118"]},"statusCode":202}}
{"a895c62474a5d22ca26885242d4fe4ed4963b39a":{"body":"{\"message\":\"Unauthenticated.\"}","headers":{":status":["401"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["785b700b5d89b9ba-BRU"],"content-type":["application/json"],"date":["Sat, 07 Jan 2023 08:49:00 GMT"],"server":["cloudflare"],"strict-transport-security":["max-age\u003d15724800; includeSubDomains"],"x-ratelimit-limit":["120"],"x-ratelimit-remaining":["119"]},"statusCode":401},"6b15cf69672ee532a9f601876778851cc4ca3135":{"body":"","headers":{":status":["202"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["755442149ddbeea0-ATH"],"content-type":["text/html; charset\u003dUTF-8"],"date":["Wed, 05 Oct 2022 06:56:34 GMT"],"server":["cloudflare"],"strict-transport-security":["max-age\u003d15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-10-06T00:00:00Z"],"x-message-id":["633d2aa226762ac1d30457e0"],"x-ratelimit-limit":["120"],"x-ratelimit-remaining":["118"]},"statusCode":202}}