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

com.twilio.twiml.MessagingResponse Maven / Gradle / Ivy

The newest version!
package com.twilio.twiml;

import com.google.common.collect.Lists;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

/**
 * TwiML wrapper for @see https://www.twilio.com/docs/api/twiml/sms/your_response.
 */
@XmlRootElement(name = "Response")
public class MessagingResponse extends TwiML {

    @SuppressWarnings("checkstyle:indentation")
    @XmlElements({
        @XmlElement(name = "Message", type = Message.class),
        @XmlElement(name = "Redirect", type = Redirect.class)
    })
    private final List actions;

    // For XML Serialization
    private MessagingResponse() {
        this(new Builder());
    }

    private MessagingResponse(Builder b) {
        this.actions = Lists.newArrayList(b.actions);
    }

    public List getActions() {
        return actions;
    }

    public static class Builder {
        private List actions = Lists.newArrayList();

        public Builder message(Message message) {
            this.actions.add(message);
            return this;
        }

        public Builder redirect(Redirect redirect) {
            this.actions.add(redirect);
            return this;
        }

        public MessagingResponse build() {
            return new MessagingResponse(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy