Packages

Complete Twilio SDK for Elixir — 37 products, 494 services, 467 resources. Auto-generated from official OpenAPI specs. Finch HTTP/2, retries with jitter, webhooks, TwiML, telemetry, streaming pagination.

Current section

Files

Jump to
twilio_elixir lib twilio api v2010 outgoing_caller_id_service.ex
Raw

lib/twilio/api/v2010/outgoing_caller_id_service.ex

# File generated from Twilio's OpenAPI spec — do not edit manually
defmodule Twilio.Api.V2010.OutgoingCallerIdService do
@moduledoc """
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
An OutgoingCallerId resource represents a single verified number that may be used as a caller ID when making outgoing calls via the REST API and within the TwiML `<Dial>` verb.
Operations: `list`, `create`, `fetch`, `update`, `delete`
"""
alias Twilio.Client
alias Twilio.Deserializer
@doc """
Retrieve a list of outgoing-caller-ids belonging to the account used to make the request
Operation: `ListOutgoingCallerId` | Tags: Api20100401OutgoingCallerId
## Query Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| `PhoneNumber` | string (phone-number) | The phone number of the OutgoingCallerId resources to read. |
| `FriendlyName` | string | The string that identifies the OutgoingCallerId resources to read. |
"""
@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}/OutgoingCallerIds.json",
params: params,
opts: opts,
base_url: "https://api.twilio.com"
) do
{:ok, data} ->
page = Twilio.Page.from_response(data, "outgoing_caller_ids")
{:ok,
%{
page
| items:
Deserializer.deserialize_list(
page.items,
Twilio.Resources.Api.V2010.OutgoingCallerId
)
}}
error ->
error
end
end
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
@doc "Stream: Retrieve a list of outgoing-caller-ids 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,
"outgoing_caller_ids"
)
end
@doc """
Operation: `CreateValidationRequest` | Tags: Api20100401ValidationRequest
## Required Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `PhoneNumber` | string (phone-number) | The phone number to verify in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. |
## Optional Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `CallDelay` | integer | The number of seconds to delay before initiating the verification call. Can be an integer between `0` and `60`, inclusive. The default is `0`. |
| `Extension` | string | The digits to dial after connecting the verification call. |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `FriendlyName` | string | A descriptive string that you create to describe the new caller ID resource. It can be up to 64 characters long. The default value is a formatted version of the phone number. |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `StatusCallback` | string (uri) | The URL we should call using the `status_callback_method` to send status information about the verification process to your application. |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `StatusCallbackMethod` | string (http-method) | The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`, and the default is `POST`. Values: `GET`, `POST` |
"""
@spec create(Client.t(), map(), keyword()) ::
{:ok, Twilio.Resources.Api.V2010.OutgoingCallerId.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}/OutgoingCallerIds.json",
params: params,
opts: opts,
base_url: "https://api.twilio.com",
content_type: :form
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Api.V2010.OutgoingCallerId)}
end
end
@doc """
Fetch an outgoing-caller-id belonging to the account used to make the request
Operation: `FetchOutgoingCallerId` | Tags: Api20100401OutgoingCallerId
"""
@spec fetch(Client.t(), String.t(), keyword()) ::
{:ok, Twilio.Resources.Api.V2010.OutgoingCallerId.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}/OutgoingCallerIds/#{sid}.json",
opts: opts,
base_url: "https://api.twilio.com"
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Api.V2010.OutgoingCallerId)}
end
end
@doc """
Updates the caller-id
Operation: `UpdateOutgoingCallerId` | Tags: Api20100401OutgoingCallerId
## Optional Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `FriendlyName` | string | A descriptive string that you create to describe the resource. It can be up to 64 characters long. |
"""
@spec update(Client.t(), String.t(), map(), keyword()) ::
{:ok, Twilio.Resources.Api.V2010.OutgoingCallerId.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}/OutgoingCallerIds/#{sid}.json",
params: params,
opts: opts,
base_url: "https://api.twilio.com",
content_type: :form
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Api.V2010.OutgoingCallerId)}
end
end
@doc """
Delete the caller-id specified from the account
Operation: `DeleteOutgoingCallerId` | Tags: Api20100401OutgoingCallerId
"""
@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}/OutgoingCallerIds/#{sid}.json",
opts: opts,
base_url: "https://api.twilio.com"
)
end
end