All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.createsend.models.transactional.request.ClassicEmailRequest Maven / Gradle / Ivy

Go to download

A Java library which implements the complete functionality of the Campaign Monitor API.

There is a newer version: 7.0.1
Show newest version
/**
 * Copyright (c) 2015 Richard Bremner
 *
 *  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.
 */
package com.createsend.models.transactional.request;

import com.createsend.models.subscribers.ConsentToTrack;
import com.createsend.models.transactional.EmailContent;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Contains the request body for Transactional Send Classic email in the Campaign Monitor API.
 */
public class ClassicEmailRequest {
    /**
     * The Subject of the email.
     */
    private String subject;

    /**
     * The From address of the email.
     */
    private String from;

    /**
     * The Reply To address of the email.
     */
    private String replyTo;

    /**
     * The list of To recipients of the email.
     */
    private List to = new ArrayList<>();

    /**
     * The list of Cc recipients of the email.
     */
    private List cc = new ArrayList<>();

    /**
     * The list of Bcc recipients of the email.
     */
    private List bcc = new ArrayList<>();

    /**
     * The list of Attachments to be sent with the email.
     */
    private List attachments = new ArrayList<>();

    /**
     * The Text version of the message content.
     */
    private String text;

    /**
     * The Html version of the message content.
     */
    private String html;

    /**
     * The Group to tag the message with. This allows you to group similar messages for reporting purposes.
     */
    private String group;

    /**
     * The ListID to add recipients to.
     */
    private String addRecipientsToListID;

    /**
     * Should Css be automatically inlined.
     */
    private boolean inlineCss;

    /**
     * Should Opens be tracked.
     */
    private boolean trackOpens;

    /**
     * Should Clicks be tracked.
     */
    private boolean trackClicks;

    /**
     * The Consent to track value of the recipients
     */
    private ConsentToTrack consentToTrack;

    public ClassicEmailRequest(String to, ConsentToTrack consentToTrack) {
        if (to == null || to.length() == 0) {
            throw new IllegalArgumentException("Must supply a TO address");
        }

        if (consentToTrack == null) {
            throw new IllegalArgumentException("Must supply a ConsentToTrack value");
        }

        this.to.add(to);
        this.consentToTrack = consentToTrack;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getSubject() {
        return subject;
    }

    public void setContent(EmailContent content) {
        this.text = content.getText();
        this.html = content.getHtml();
        this.inlineCss = content.isInlineCss();
        this.trackOpens = content.isTrackOpens();
        this.trackClicks = content.isTrackClicks();
    }

    public String getText() {
        return text;
    }

    public String getHtml() {
        return html;
    }

    public boolean isInlineCss() {
        return inlineCss;
    }

    public boolean isTrackClicks() {
        return trackClicks;
    }

    public boolean isTrackOpens() {
        return trackOpens;
    }

    public void addTo(String recipient) {
        to.add(recipient);
    }

    public Iterator getTo() {
        return to.iterator();
    }

    public void addCc(String recipient) {
        cc.add(recipient);
    }

    public void addBcc(String recipient) {
        bcc.add(recipient);
    }

    public void addAttachment(Attachment attachment) {
        attachments.add(attachment);
    }

    public List getAttachments() {
        return attachments;
    }

    public void setAddRecipientsToListID(String addRecipientsToListID) {
        this.addRecipientsToListID = addRecipientsToListID;
    }

    public String getAddRecipientsToListID() {
        return addRecipientsToListID;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getReplyTo() {
        return replyTo;
    }

    public void setReplyTo(String replyTo) {
        this.replyTo = replyTo;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public ConsentToTrack getConsentToTrack() {
        return consentToTrack;
    }

    public void setConsentToTrack(ConsentToTrack consentToTrack) {
        this.consentToTrack = consentToTrack;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy