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 verify v2 service access_token_service.ex
Raw

lib/twilio/verify/v2/service/access_token_service.ex

# File generated from Twilio's OpenAPI spec — do not edit manually
defmodule Twilio.Verify.V2.Service.AccessTokenService do
@moduledoc """
Service for AccessToken API operations.
Operations: `create`, `fetch`
"""
alias Twilio.Client
alias Twilio.Deserializer
@doc """
Create a new enrollment Access Token for the Entity
Operation: `CreateAccessToken` | Tags: VerifyV2AccessToken
## Required Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| `FactorType` | string | Values: `push` |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `Identity` | string | The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user's UUID, GUID, or SID. |
## Optional Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| `FactorFriendlyName` | string | The friendly name of the factor that is going to be created with this access token |
# credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
| `Ttl` | integer | How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60. |
"""
@spec create(Client.t(), String.t(), map(), keyword()) ::
{:ok, Twilio.Resources.Verify.V2.Service.AccessToken.t()}
| {:ok, map(), map()}
| :ok
| {:error, Twilio.Error.t()}
def create(client, service_sid, params \\ %{}, opts \\ []) do
with {:ok, data} <-
Client.request(client, :post, "/v2/Services/#{service_sid}/AccessTokens",
params: params,
opts: opts,
base_url: "https://verify.twilio.com",
content_type: :form
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Verify.V2.Service.AccessToken)}
end
end
@doc """
Fetch an Access Token for the Entity
Operation: `FetchAccessToken` | Tags: VerifyV2AccessToken
"""
@spec fetch(Client.t(), String.t(), String.t(), keyword()) ::
{:ok, Twilio.Resources.Verify.V2.Service.AccessToken.t()}
| {:ok, map(), map()}
| :ok
| {:error, Twilio.Error.t()}
def fetch(client, service_sid, sid, opts \\ []) do
with {:ok, data} <-
Client.request(client, :get, "/v2/Services/#{service_sid}/AccessTokens/#{sid}",
opts: opts,
base_url: "https://verify.twilio.com"
) do
{:ok, Deserializer.deserialize(data, Twilio.Resources.Verify.V2.Service.AccessToken)}
end
end
end