Upload files to 'src/main/java/ca/mgamble/postman/api/message'
This commit is contained in:
parent
2500a571bd
commit
5e012fb5e0
43
src/main/java/ca/mgamble/postman/api/message/Header.java
Normal file
43
src/main/java/ca/mgamble/postman/api/message/Header.java
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
package ca.mgamble.postman.api.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mgamble
|
||||
*/
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Matthew M. Gamble https://www.mgamble.ca
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class Header {
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public Header(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
153
src/main/java/ca/mgamble/postman/api/message/PostmanMessage.java
Normal file
153
src/main/java/ca/mgamble/postman/api/message/PostmanMessage.java
Normal file
@ -0,0 +1,153 @@
|
||||
package ca.mgamble.postman.api.message;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mgamble
|
||||
*/
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Matthew M. Gamble https://www.mgamble.ca
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class PostmanMessage {
|
||||
|
||||
private List<String> to;
|
||||
private List<String> cc;
|
||||
private List<String> bcc;
|
||||
private List<Attachment> attachments;
|
||||
private List<EmbeddedImage> embeddedImages;
|
||||
|
||||
@SerializedName("Headers")
|
||||
private List<Header> headers;
|
||||
|
||||
private String from;
|
||||
private String subject;
|
||||
private String tag;
|
||||
private String reply_to;
|
||||
private String plain_body;
|
||||
private String html_body;
|
||||
private boolean bounce;
|
||||
|
||||
public PostmanMessage(List<String> to, List<String> cc, List<String> bcc, List<Attachment> attachments, List<EmbeddedImage> embeddedImages,
|
||||
List<Header> headers, String from, String subject, String tag, String reply_to, String plain_body, String html_body, boolean bounce) {
|
||||
this.to = to;
|
||||
this.cc = cc;
|
||||
this.bcc = bcc;
|
||||
this.attachments = attachments;
|
||||
this.embeddedImages = embeddedImages;
|
||||
this.headers = headers;
|
||||
this.from = from;
|
||||
this.subject = subject;
|
||||
this.tag = tag;
|
||||
this.reply_to = reply_to;
|
||||
this.plain_body = plain_body;
|
||||
this.html_body = html_body;
|
||||
this.bounce = bounce;
|
||||
}
|
||||
|
||||
public PostmanMessage() {
|
||||
this.to = new ArrayList<>();
|
||||
this.cc = new ArrayList<>();
|
||||
this.bcc = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addTo(String rcptTo) {
|
||||
if (this.to == null) {
|
||||
this.to = new ArrayList<>();
|
||||
}
|
||||
this.to.add(rcptTo);
|
||||
}
|
||||
|
||||
public void addCC(String rcptCC) {
|
||||
if (this.cc == null) {
|
||||
this.cc = new ArrayList<>();
|
||||
}
|
||||
this.cc.add(rcptCC);
|
||||
}
|
||||
|
||||
public void addBCC(String rcptBCC) {
|
||||
if (this.bcc == null) {
|
||||
this.bcc = new ArrayList<>();
|
||||
}
|
||||
this.bcc.add(rcptBCC);
|
||||
}
|
||||
|
||||
public void addAttachment(String name, String content_type, String data) {
|
||||
this.addAttachment(new Attachment(name, content_type, data));
|
||||
}
|
||||
|
||||
public void addAttachment(Attachment attachment) {
|
||||
if (this.attachments == null) {
|
||||
this.attachments = new ArrayList<>();
|
||||
}
|
||||
this.attachments.add(attachment);
|
||||
}
|
||||
|
||||
public void addEmbeddedImage(EmbeddedImage embeddedImage) {
|
||||
if (this.embeddedImages == null) {
|
||||
this.embeddedImages = new ArrayList<>();
|
||||
}
|
||||
this.embeddedImages.add(embeddedImage);
|
||||
}
|
||||
|
||||
public void addHeader(Header header) {
|
||||
if (this.headers == null) {
|
||||
this.headers = new ArrayList<>();
|
||||
}
|
||||
this.headers.add(header);
|
||||
}
|
||||
|
||||
public void addHeader(String key, String value) {
|
||||
this.addHeader(new Header(key, value));
|
||||
}
|
||||
|
||||
public String getReplyTo() {
|
||||
return reply_to;
|
||||
}
|
||||
|
||||
public void setReplyTo(String reply_to) {
|
||||
this.reply_to = reply_to;
|
||||
}
|
||||
|
||||
public String getPlainBody() {
|
||||
return plain_body;
|
||||
}
|
||||
|
||||
public void setPlainBody(String plain_body) {
|
||||
this.plain_body = plain_body;
|
||||
}
|
||||
|
||||
public String getHtmlBody() {
|
||||
return html_body;
|
||||
}
|
||||
|
||||
public void setHtmlBody(String html_body) {
|
||||
this.html_body = html_body;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package ca.mgamble.postman.api.message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PostmanMessageBuilder {
|
||||
|
||||
private List<String> to = new ArrayList<>();
|
||||
private List<String> cc = new ArrayList<>();
|
||||
private List<String> bcc = new ArrayList<>();
|
||||
private List<Attachment> attachments = new ArrayList<>();
|
||||
private List<EmbeddedImage> embeddedImages = new ArrayList<>();
|
||||
private List<Header> headers = new ArrayList<>();
|
||||
private String from;
|
||||
private String subject;
|
||||
private String tag;
|
||||
private String reply_to;
|
||||
private String plain_body;
|
||||
private String html_body;
|
||||
private boolean bounce;
|
||||
|
||||
public PostmanMessageBuilder to(String to) {
|
||||
this.to.add(to);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder cc(String cc) {
|
||||
this.cc.add(cc);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder bcc(String bcc) {
|
||||
this.bcc.add(bcc);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder addAttachment(Attachment attachment) {
|
||||
this.attachments.add(attachment);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder addEmbeddedImage(EmbeddedImage embeddedImage) {
|
||||
this.embeddedImages.add(embeddedImage);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder addHeader(Header header) {
|
||||
this.headers.add(header);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder from(String from) {
|
||||
this.from = from;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder withSubject(String subject) {
|
||||
this.subject = subject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder withTag(String tag) {
|
||||
this.tag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder withReplyTo(String reply_to) {
|
||||
this.reply_to = reply_to;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder withPlainBody(String plain_body) {
|
||||
this.plain_body = plain_body;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder withHtmlBody(String html_body) {
|
||||
this.html_body = html_body;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessageBuilder withBounce(boolean bounce) {
|
||||
this.bounce = bounce;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanMessage build() {
|
||||
return new PostmanMessage(to, cc, bcc, attachments, embeddedImages, headers, from, subject, tag, reply_to, plain_body, html_body, bounce);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package ca.mgamble.postman.api.message;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mgamble
|
||||
*/
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Matthew M. Gamble https://www.mgamble.ca
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PostmanRawMessage {
|
||||
private String mail_from;
|
||||
private List<String> rcpt_to;
|
||||
private String data;
|
||||
private boolean bounce;
|
||||
|
||||
public PostmanRawMessage(String from, String data, boolean bounce, List<String> rcpt_to) {
|
||||
this.mail_from = from;
|
||||
this.data = data;
|
||||
this.bounce = bounce;
|
||||
this.rcpt_to = rcpt_to;
|
||||
}
|
||||
|
||||
public void addTo(String rcptTo) {
|
||||
if (this.rcpt_to == null) {
|
||||
this.rcpt_to = new ArrayList<>();
|
||||
}
|
||||
this.rcpt_to.add(rcptTo);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package ca.mgamble.postman.api.message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PostmanRawMessageBuilder {
|
||||
private String mail_from;
|
||||
private String data;
|
||||
private boolean bounce;
|
||||
private List<String> rcpt_to;
|
||||
|
||||
public PostmanRawMessageBuilder from(String mail_from) {
|
||||
this.mail_from = mail_from;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanRawMessageBuilder withData(String data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanRawMessageBuilder withBounce(boolean bounce) {
|
||||
this.bounce = bounce;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanRawMessageBuilder to(String rcptTo) {
|
||||
if (this.rcpt_to == null) {
|
||||
this.rcpt_to = new ArrayList<>();
|
||||
}
|
||||
this.rcpt_to.add(rcptTo);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanRawMessageBuilder tos(List<String> tos) {
|
||||
this.rcpt_to = tos;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PostmanRawMessage build() {
|
||||
return new PostmanRawMessage(mail_from, data, bounce, rcpt_to);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user