
com.twilio.rest.taskrouter.v1.WorkspaceUpdater Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of twilio Show documentation
Show all versions of twilio Show documentation
Twilio Java Helper Library
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
package com.twilio.rest.taskrouter.v1;
import com.twilio.base.Updater;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
import com.twilio.http.HttpMethod;
import com.twilio.http.Request;
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
import java.net.URI;
public class WorkspaceUpdater extends Updater {
private final String pathSid;
private String defaultActivitySid;
private URI eventCallbackUrl;
private String eventsFilter;
private String friendlyName;
private Boolean multiTaskEnabled;
private String timeoutActivitySid;
private Workspace.QueueOrder prioritizeQueueOrder;
/**
* Construct a new WorkspaceUpdater.
*
* @param pathSid The sid
*/
public WorkspaceUpdater(final String pathSid) {
this.pathSid = pathSid;
}
/**
* The ID of the Activity that will be used when new Workers are created in this
* Workspace..
*
* @param defaultActivitySid The ID of the Activity that will be used when new
* Workers are created in this Workspace.
* @return this
*/
public WorkspaceUpdater setDefaultActivitySid(final String defaultActivitySid) {
this.defaultActivitySid = defaultActivitySid;
return this;
}
/**
* The Workspace will publish events to this URL. You can use this to gather
* data for reporting. See [Events][/docs/taskrouter/api/events] for more
* information..
*
* @param eventCallbackUrl The Workspace will publish events to this URL.
* @return this
*/
public WorkspaceUpdater setEventCallbackUrl(final URI eventCallbackUrl) {
this.eventCallbackUrl = eventCallbackUrl;
return this;
}
/**
* The Workspace will publish events to this URL. You can use this to gather
* data for reporting. See [Events][/docs/taskrouter/api/events] for more
* information..
*
* @param eventCallbackUrl The Workspace will publish events to this URL.
* @return this
*/
public WorkspaceUpdater setEventCallbackUrl(final String eventCallbackUrl) {
return setEventCallbackUrl(Promoter.uriFromString(eventCallbackUrl));
}
/**
* Use this parameter to receive webhooks on EventCallbackUrl for specific
* events on a workspace. For example if
* 'EventsFilter=task.created,task.canceled,worker.activity.update', then
* TaskRouter will webhook to EventCallbackUrl only when a task is created,
* canceled or a worker activity is updated..
*
* @param eventsFilter Use this parameter to receive webhooks on
* EventCallbackUrl for specific events on a workspace.
* @return this
*/
public WorkspaceUpdater setEventsFilter(final String eventsFilter) {
this.eventsFilter = eventsFilter;
return this;
}
/**
* Human readable description of this workspace (for example "Sales Call Center"
* or "Customer Support Team").
*
* @param friendlyName Human readable description of this workspace
* @return this
*/
public WorkspaceUpdater setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
/**
* Enable or Disable Multitasking by passing either *true* or *False* with the
* POST request. Learn more by visiting
* [Multitasking][/docs/taskrouter/multitasking]..
*
* @param multiTaskEnabled Enable or Disable Multitasking by passing either
* true or False with the POST request.
* @return this
*/
public WorkspaceUpdater setMultiTaskEnabled(final Boolean multiTaskEnabled) {
this.multiTaskEnabled = multiTaskEnabled;
return this;
}
/**
* The ID of the Activity that will be assigned to a Worker when a Task
* reservation times out without a response..
*
* @param timeoutActivitySid The ID of the Activity that will be assigned to a
* Worker when a Task reservation times out without a
* response.
* @return this
*/
public WorkspaceUpdater setTimeoutActivitySid(final String timeoutActivitySid) {
this.timeoutActivitySid = timeoutActivitySid;
return this;
}
/**
* Use this parameter to configure whether to prioritize LIFO or FIFO when
* workers are receiving Tasks from combination of LIFO and FIFO TaskQueues.
* Default is FIFO. [Click
* here][/docs/taskrouter/queue-ordering-last-first-out-lifo] to learn more
* about LIFO and the use of the parameter..
*
* @param prioritizeQueueOrder Use this parameter to configure whether to
* prioritize LIFO or FIFO when workers are
* receiving Tasks from combination of LIFO and FIFO
* TaskQueues.
* @return this
*/
public WorkspaceUpdater setPrioritizeQueueOrder(final Workspace.QueueOrder prioritizeQueueOrder) {
this.prioritizeQueueOrder = prioritizeQueueOrder;
return this;
}
/**
* Make the request to the Twilio API to perform the update.
*
* @param client TwilioRestClient with which to make the request
* @return Updated Workspace
*/
@Override
@SuppressWarnings("checkstyle:linelength")
public Workspace update(final TwilioRestClient client) {
Request request = new Request(
HttpMethod.POST,
Domains.TASKROUTER.toString(),
"/v1/Workspaces/" + this.pathSid + "",
client.getRegion()
);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
throw new ApiConnectionException("Workspace update failed: Unable to connect to server");
} else if (!TwilioRestClient.SUCCESS.apply(response.getStatusCode())) {
RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
if (restException == null) {
throw new ApiException("Server Error, no content");
}
throw new ApiException(
restException.getMessage(),
restException.getCode(),
restException.getMoreInfo(),
restException.getStatus(),
null
);
}
return Workspace.fromJson(response.getStream(), client.getObjectMapper());
}
/**
* Add the requested post parameters to the Request.
*
* @param request Request to add post params to
*/
private void addPostParams(final Request request) {
if (defaultActivitySid != null) {
request.addPostParam("DefaultActivitySid", defaultActivitySid);
}
if (eventCallbackUrl != null) {
request.addPostParam("EventCallbackUrl", eventCallbackUrl.toString());
}
if (eventsFilter != null) {
request.addPostParam("EventsFilter", eventsFilter);
}
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
}
if (multiTaskEnabled != null) {
request.addPostParam("MultiTaskEnabled", multiTaskEnabled.toString());
}
if (timeoutActivitySid != null) {
request.addPostParam("TimeoutActivitySid", timeoutActivitySid);
}
if (prioritizeQueueOrder != null) {
request.addPostParam("PrioritizeQueueOrder", prioritizeQueueOrder.toString());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy