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

com.twilio.sdk.resource.list.ipmessaging.ChannelList Maven / Gradle / Ivy

There is a newer version: 7.0.0-rc-10
Show newest version
package com.twilio.sdk.resource.list.ipmessaging;

import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioRestResponse;
import com.twilio.sdk.resource.NextGenListResource;
import com.twilio.sdk.resource.factory.ResourceFactory;
import com.twilio.sdk.resource.instance.ipmessaging.Channel;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;

import java.util.List;
import java.util.Map;

/**
 * Represents channels endpoint for ip messages
 */
public class ChannelList extends NextGenListResource
		implements ResourceFactory {

	private final String serviceSid;

	public ChannelList(TwilioIPMessagingClient client, String serviceSid) {
		this(client, serviceSid, null);
	}

	public ChannelList(TwilioIPMessagingClient client, String serviceSid, Map filters) {
		super(client, filters);

		if (StringUtils.isEmpty(serviceSid)) {
			throw new IllegalArgumentException("serviceSid cannot be null");
		}
		this.serviceSid = serviceSid;
	}

	@Override
	protected Channel makeNew(final TwilioIPMessagingClient client, final Map params) {
		return new Channel(client, params);
	}

	@Override
	protected String getResourceLocation() {
		return "/" + TwilioIPMessagingClient.DEFAULT_VERSION + "/Services/" + this.serviceSid + "/Channels";
	}

	@Override
	public Channel create(final Map params) throws TwilioRestException {
		TwilioRestResponse response = this.getClient().safeRequest(this.getResourceLocation(), "POST", params);
		return makeNew(this.getClient(), response.toMap());
	}

	@Override
	public Channel create(final List params) throws TwilioRestException {
		TwilioRestResponse response = this.getClient().safeRequest(this.getResourceLocation(), "POST", params);
		return makeNew(this.getClient(), response.toMap());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy