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

com.twilio.sdk.resource.list.taskrouter.TaskList Maven / Gradle / Ivy

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

import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioRestResponse;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.NextGenListResource;
import com.twilio.sdk.resource.factory.taskrouter.TaskFactory;
import com.twilio.sdk.resource.instance.taskrouter.Task;
import org.apache.http.NameValuePair;

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

/**
 * TaskList to work with {@link com.twilio.sdk.resource.instance.taskrouter.Task}.
 */
public class TaskList extends NextGenListResource implements TaskFactory {

	private String workspaceSid;

	/**
	 * Instantiates a task list.
	 *
	 * @param client the client
	 * @param workspaceSid the workspace sid
	 */
	public TaskList(final TwilioTaskRouterClient client, final String workspaceSid) {
		super(client);
		this.workspaceSid = workspaceSid;
	}

	/**
	 * Instantiates a task list.
	 *
	 * @param client the client
	 * @param workspaceSid the workspace sid
	 * @param filters the filters
	 */
	public TaskList(final TwilioTaskRouterClient client, final String workspaceSid, final Map filters) {
		super(client, filters);
		this.workspaceSid = workspaceSid;
	}

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

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

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

	@Override
	protected String getResourceLocation() {
		return "/" + TwilioTaskRouterClient.DEFAULT_VERSION + "/Workspaces/" + workspaceSid + "/Tasks";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy