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

com.ning.api.client.access.BroadcastMessages Maven / Gradle / Ivy

There is a newer version: 0.5.1
Show newest version
package com.ning.api.client.access;

import com.ning.api.client.NingClientConfig;
import com.ning.api.client.access.impl.DefaultCreator;
import com.ning.api.client.action.Creator;
import com.ning.api.client.http.NingHttpPost;
import com.ning.api.client.item.*;

public class BroadcastMessages extends Items
{
    public BroadcastMessages(NingConnection connection, NingClientConfig config)
    {
        super(connection, config, "BroadcastMessage", BroadcastMessage.class, BroadcastMessageField.class);
    }

    /*
    ///////////////////////////////////////////////////////////////////////
    // Public API: constructing request builders
    ///////////////////////////////////////////////////////////////////////
     */

    public Creator creator(BroadcastMessage message) {
        return new BroadcastMessageCreator(connection, config, endpointForPOST(), message);
    }

    public static class BroadcastMessageCreator extends DefaultCreator
    {
        protected final String subject;
        protected final String body;
        protected final String messageId;
        
        public BroadcastMessageCreator(NingConnection connection, NingClientConfig config, String endpoint,
                BroadcastMessage message)
        {
            super(connection, config, endpoint);
            subject = message.getSubject();
            body = message.getBody();
            messageId = message.getMessageId();
        }

        @Override
        protected NingHttpPost addCreateParameters(NingHttpPost create)
        {
            return create.addFormParameter("subject", subject)
                .addFormParameter("body", body)
                .addFormParameter("messageId", messageId)
                ;
        }
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy