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

com.alogient.cameleon.sdk.community.interspire.request.impl.CreateSubscribersRequest Maven / Gradle / Ivy

The newest version!
package com.alogient.cameleon.sdk.community.interspire.request.impl;

import com.alogient.cameleon.sdk.community.interspire.jaxb.Details;
import com.alogient.cameleon.sdk.community.interspire.jaxb.Item;
import com.alogient.cameleon.sdk.community.interspire.jaxb.XmlRequest;
import com.alogient.cameleon.sdk.community.interspire.jaxb.type.Confirmed;
import com.alogient.cameleon.sdk.community.interspire.jaxb.type.EmailFormat;
import com.alogient.cameleon.sdk.community.interspire.jaxb.type.RequestMethod;
import com.alogient.cameleon.sdk.community.interspire.jaxb.type.RequestType;
import com.alogient.cameleon.sdk.community.interspire.request.ISubscribersRequest;
import com.alogient.cameleon.sdk.community.interspire.response.IResponse;
import com.alogient.cameleon.sdk.community.interspire.response.SubscriberResponse;


/**
 * Used to subscribe to a list 
 *
 * User: jmirc
 * Date: 27-Jan-2010
 * Time: 5:25:13 PM
 */
public class CreateSubscribersRequest extends BaseRequest implements ISubscribersRequest {

    /**
     * The XML request
     */
    private XmlRequest xmlRequest;

    /**
     * Details
     */
    private Details details = new Details();

    /**
     * Contructor.
     * JABX needs a default contructor.
     */
    public CreateSubscribersRequest() {
        super(null, SubscriberResponse.class);
    }

    /**
     * Default constructor
     *
     * @param username the Interspire username
     * @param userToken  the Interspire token
     * @param interspireURL  The URL of the Interspire server
     */
    public CreateSubscribersRequest(String username, String userToken,
            String interspireURL) {

        super(interspireURL, SubscriberResponse.class);
        
        this.xmlRequest = new XmlRequest();
        xmlRequest.setUserName(username);
        xmlRequest.setUserToken(userToken);
        xmlRequest.setRequestType(RequestType.SUBSCRIBERS);
        xmlRequest.setRequestMethod(RequestMethod.ADD_SUBSCRIBER_TO_LIST);
        xmlRequest.setDetails(details);
    }

    @Override
    public XmlRequest getXmlRequest() {
        return xmlRequest;
    }

    @Override
    public void setEmailAddress(String emailAddress) {
        details.setEmailAddress(emailAddress);
    }

    @Override
    public void setMailingList(String mailingList) {
        details.setMailingList(mailingList);
    }

    @Override
    public void setEmailFormat(EmailFormat emailFormat) {
        details.setEmailFormat(emailFormat);
    }

    @Override
    public void setConfirmed(Confirmed confirmed) {
        details.setConfirmed(confirmed);
    }

    @Override
    public void addCustomField(String id, String value) {
        Item item = new Item();
        item.setFieldId(id);
        item.setValue(value);

        details.addItem(item);
    }

    @Override
    public IResponse sendRequest() throws Exception {
        return super.send(xmlRequest);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy