# File generated from Twilio's OpenAPI spec — do not edit manually defmodule Twilio.Api.V2010.QueueService do @moduledoc """ Queues of calls Operations: `list`, `create`, `fetch`, `update`, `delete` """ alias Twilio.Client alias Twilio.Deserializer @doc """ Retrieve a list of queues belonging to the account used to make the request Operation: `ListQueue` | Tags: Api20100401Queue """ @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, "/2010-04-01/Accounts/#{client.account_sid}/Queues.json", params: params, opts: opts, base_url: "https://api.twilio.com" ) do {:ok, data} -> page = Twilio.Page.from_response(data, "queues") {:ok, %{ page | items: Deserializer.deserialize_list(page.items, Twilio.Resources.Api.V2010.Queue) }} error -> error end end @doc "Stream: Retrieve a list of queues belonging to the account used to make the request (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, "queues" ) end @doc """ Create a queue Operation: `CreateQueue` | Tags: Api20100401Queue ## Required Parameters | Parameter | Type | Description | |-----------|------|-------------| # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `FriendlyName` | string | A descriptive string that you created to describe this resource. It can be up to 64 characters long. | ## Optional Parameters | Parameter | Type | Description | |-----------|------|-------------| # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `MaxSize` | integer | The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000. | """ @spec create(Client.t(), map(), keyword()) :: {:ok, Twilio.Resources.Api.V2010.Queue.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def create(client, params \\ %{}, opts \\ []) do with {:ok, data} <- Client.request(client, :post, "/2010-04-01/Accounts/#{client.account_sid}/Queues.json", params: params, opts: opts, base_url: "https://api.twilio.com", content_type: :form ) do {:ok, Deserializer.deserialize(data, Twilio.Resources.Api.V2010.Queue)} end end @doc """ Fetch an instance of a queue identified by the QueueSid Operation: `FetchQueue` | Tags: Api20100401Queue """ @spec fetch(Client.t(), String.t(), keyword()) :: {:ok, Twilio.Resources.Api.V2010.Queue.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def fetch(client, sid, opts \\ []) do with {:ok, data} <- Client.request( client, :get, "/2010-04-01/Accounts/#{client.account_sid}/Queues/#{sid}.json", opts: opts, base_url: "https://api.twilio.com" ) do {:ok, Deserializer.deserialize(data, Twilio.Resources.Api.V2010.Queue)} end end @doc """ Update the queue with the new parameters Operation: `UpdateQueue` | Tags: Api20100401Queue ## Optional Parameters | Parameter | Type | Description | |-----------|------|-------------| # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `FriendlyName` | string | A descriptive string that you created to describe this resource. It can be up to 64 characters long. | # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `MaxSize` | integer | The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000. | """ @spec update(Client.t(), String.t(), map(), keyword()) :: {:ok, Twilio.Resources.Api.V2010.Queue.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def update(client, sid, params \\ %{}, opts \\ []) do with {:ok, data} <- Client.request( client, :post, "/2010-04-01/Accounts/#{client.account_sid}/Queues/#{sid}.json", params: params, opts: opts, base_url: "https://api.twilio.com", content_type: :form ) do {:ok, Deserializer.deserialize(data, Twilio.Resources.Api.V2010.Queue)} end end @doc """ Remove an empty queue Operation: `DeleteQueue` | Tags: Api20100401Queue """ @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, "/2010-04-01/Accounts/#{client.account_sid}/Queues/#{sid}.json", opts: opts, base_url: "https://api.twilio.com" ) end end