Current section
Files
Jump to
Current section
Files
lib/twilio/taskrouter/v1/workspace_service.ex
# File generated from Twilio's OpenAPI spec — do not edit manually
defmodule Twilio.Taskrouter.V1.WorkspaceService do
@moduledoc """
Service for Workspace API operations.
Operations: `list`, `create`, `fetch`, `update`, `delete`
"""
alias Twilio.Client
alias Twilio.Deserializer
@doc """
Operation: `ListWorkspace` | Tags: TaskrouterV1Workspace
## Query Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `FriendlyName` | string | The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`. |
"""
@spec list(Client.t(), map(), keyword()) ::
{:ok, Twilio.Page.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()}
def list(client, params \\ %{}, opts \\ []) do
case Client.request(client, :get, "/v1/Workspaces",
params: params,
opts: opts,
base_url: "https://taskrouter.twilio.com"
) do
{:ok, data} ->
page = Twilio.Page.from_response(data, "workspaces")
{:ok,
%{
page
| items:
Deserializer.deserialize_list(page.items, Twilio.Resources.Taskrouter.V1.Workspace)
}}
error ->
error
end
end
@doc "Stream: (lazy auto-pagination)."
@spec stream(Client.t(), map(), keyword()) :: Enumerable.t()
def stream(client, params \\ %{}, opts \\ []) do
Twilio.Page.stream(
fn page_opts ->
list(client, Map.merge(params, page_opts), opts)
end,
"workspaces"
)
end
@doc """
Operation: `CreateWorkspace` | Tags: TaskrouterV1Workspace
## Required Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `FriendlyName` | string | A descriptive string that you create to describe the Workspace resource. It can be up to 64 characters long. For example: `Customer Support` or `2014 Election Campaign`. |
## Optional Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `EventCallbackUrl` | string (uri) | The URL we should call when an event occurs. If provided, the Workspace will publish events to this URL, for example, to collect data for reporting. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides). |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `EventsFilter` | string | The list of Workspace events for which to call event_callback_url. For example, if `EventsFilter=task.created, task.canceled, worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated. |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `MultiTaskEnabled` | boolean | Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be created as multi-tasking. The default is `true`. Multi-tasking allows Workers to handle multiple Tasks simultaneously. When enabled (`true`), each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking). |
| `PrioritizeQueueOrder` | string | Values: `FIFO`, `LIFO` |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `Template` | string | An available template name. Can be: `NONE` or `FIFO` and the default is `NONE`. Pre-configures the Workspace with the Workflow and Activities specified in the template. `NONE` will create a Workspace with only a set of default activities. `FIFO` will configure TaskRouter with a set of default activities and a single TaskQueue for first-in, first-out distribution, which can be useful when you are getting started with TaskRouter. |
"""
@spec create(Client.t(), map(), keyword()) ::
{:ok, Twilio.Resources.Taskrouter.V1.Workspace.t()}
| {:ok, map(), map()}
| :ok
| {:error, Twilio.Error.t()}
def create(client, params \\ %{}, opts \\ []) do
with {:ok, data} <-
Client.request(client, :post, "/v1/Workspaces",
params: params,
opts: opts,
base_url: "https://taskrouter.twilio.com",
content_type: :form
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Taskrouter.V1.Workspace)}
end
end
@doc """
Operation: `FetchWorkspace` | Tags: TaskrouterV1Workspace
"""
@spec fetch(Client.t(), String.t(), keyword()) ::
{:ok, Twilio.Resources.Taskrouter.V1.Workspace.t()}
| {:ok, map(), map()}
| :ok
| {:error, Twilio.Error.t()}
def fetch(client, sid, opts \\ []) do
with {:ok, data} <-
Client.request(client, :get, "/v1/Workspaces/#{sid}",
opts: opts,
base_url: "https://taskrouter.twilio.com"
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Taskrouter.V1.Workspace)}
end
end
@doc """
Operation: `UpdateWorkspace` | Tags: TaskrouterV1Workspace
## Optional Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `DefaultActivitySid` | string | The SID of the Activity that will be used when new Workers are created in the Workspace. |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `EventCallbackUrl` | string (uri) | The URL we should call when an event occurs. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides). |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `EventsFilter` | string | The list of Workspace events for which to call event_callback_url. For example if `EventsFilter=task.created,task.canceled,worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated. |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `FriendlyName` | string | A descriptive string that you create to describe the Workspace resource. For example: `Sales Call Center` or `Customer Support Team`. |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `MultiTaskEnabled` | boolean | Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be maintained as multi-tasking. There is no default when omitting this parameter. A multi-tasking Workspace can't be updated to single-tasking unless it is not a Flex Project and another (legacy) single-tasking Workspace exists. Multi-tasking allows Workers to handle multiple Tasks simultaneously. In multi-tasking mode, each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking). |
| `PrioritizeQueueOrder` | string | Values: `FIFO`, `LIFO` |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `TimeoutActivitySid` | string | The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response. |
"""
@spec update(Client.t(), String.t(), map(), keyword()) ::
{:ok, Twilio.Resources.Taskrouter.V1.Workspace.t()}
| {:ok, map(), map()}
| :ok
| {:error, Twilio.Error.t()}
def update(client, sid, params \\ %{}, opts \\ []) do
with {:ok, data} <-
Client.request(client, :post, "/v1/Workspaces/#{sid}",
params: params,
opts: opts,
base_url: "https://taskrouter.twilio.com",
content_type: :form
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Taskrouter.V1.Workspace)}
end
end
@doc """
Operation: `DeleteWorkspace` | Tags: TaskrouterV1Workspace
"""
@spec delete(Client.t(), String.t(), keyword()) ::
{:ok, map()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()}
def delete(client, sid, opts \\ []) do
Client.request(client, :delete, "/v1/Workspaces/#{sid}",
opts: opts,
base_url: "https://taskrouter.twilio.com"
)
end
end