com.mailgun.model.message.MailgunMimeMessage Maven / Gradle / Ivy
Show all versions of mailgun-java Show documentation
package com.mailgun.model.message;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.mailgun.util.CollectionUtil;
import com.mailgun.util.StringUtil;
import feign.form.FormProperty;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
/**
* The object is used for sending messages(emails) in MIME format using Mailgun API.
*
* @see field-explanation
*/
@Getter
@ToString
@EqualsAndHashCode
@Builder
public class MailgunMimeMessage {
/**
*
* Email address of the recipient(s).
*
*/
Set to;
/**
*
* Same as {@link #to} but for Bcc.
*
*/
File message;
/**
*
* Tag string.
*
*
* @see Tagging
*/
@FormProperty("o:tag") Set tag;
/**
*
* Desired time of delivery.
*
*
*
* Note: Messages can be scheduled for a maximum of 3 days in the future.
*
*/
@FormProperty("o:deliverytime")
String deliveryTime;
/**
*
* Enables/disables DKIM signatures on per-message basis.
*
*/
@FormProperty("o:dkim")
String dkim;
/**
*
* Enables sending in test mode.
*
*
* @see Sending in Test Mode
*/
@FormProperty("o:testmode")
String testMode;
/**
*
* Toggles tracking on a per-message basis.
*
*
* @see Tracking Messages
*/
@FormProperty("o:tracking")
String tracking;
/**
*
* Toggles clicks tracking on a per-message basis.
*
*
* Has higher priority than domain-level setting.
*
*
* Pass TRUE
, FALSE
or HTML_ONLY
*
*/
@FormProperty("o:tracking-clicks")
String trackingClicks;
/**
*
* Toggles opens tracking on a per-message basis.
*
*
* Has higher priority than domain-level setting.
*
*/
@FormProperty("o:tracking-opens")
String trackingOpens;
/**
*
* Specify Reply-To address
*
*/
@FormProperty("h:Reply-To")
String replyTo;
/**
*
* Allows to attach a custom JSON data to the message
*
*/
@FormProperty("v:my-var")
String myVar;
public static class MailgunMimeMessageBuilder {
/**
*
* Email address of the recipient
*
*
* @param to Email address of the recipient
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MailgunMimeMessage.MailgunMimeMessageBuilder to(String to) {
this.to = CollectionUtil.addToSet(this.to, to);
return this;
}
/**
*
* Email addresses of the recipient
*
*
* @param to Email addresses of the recipient
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MailgunMimeMessage.MailgunMimeMessageBuilder to(List to) {
this.to = CollectionUtil.addToSet(this.to, to);
return this;
}
/**
*
* Allows to attach a custom data to the message
*
*
* @param myVar dictionary
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MailgunMimeMessage.MailgunMimeMessageBuilder myVar(Map myVar) {
this.myVar = StringUtil.asJsonString(myVar);
return this;
}
}
}