Ltix.LaunchClaims.MembershipsEndpoint (Ltix v0.2.0)

Copy Markdown View Source

Memberships service endpoint claim.

Provides a URL for retrieving context membership. All fields are optional when parsed from launch claims. An absolute HTTPS context_memberships_url is required when constructing an endpoint manually via new/1.

Examples

iex> Ltix.LaunchClaims.MembershipsEndpoint.from_json(%{"context_memberships_url" => "https://example.com/members"})
{:ok, %Ltix.LaunchClaims.MembershipsEndpoint{context_memberships_url: "https://example.com/members", service_versions: nil}}

Summary

Functions

Parse a memberships endpoint claim from a JSON map.

Create a memberships endpoint from a URL string.

Same as new/1 but raises on an invalid URL.

Types

t()

@type t() :: %Ltix.LaunchClaims.MembershipsEndpoint{
  context_memberships_url: nil | binary(),
  service_versions: nil | [binary()]
}

Functions

from_json(json)

@spec from_json(map()) :: {:ok, t()} | {:error, Exception.t()}

Parse a memberships endpoint claim from a JSON map.

Examples

iex> Ltix.LaunchClaims.MembershipsEndpoint.from_json(%{})
{:ok, %Ltix.LaunchClaims.MembershipsEndpoint{context_memberships_url: nil, service_versions: nil}}

new(url)

@spec new(String.t() | nil) :: {:ok, t()} | {:error, Exception.t()}

Create a memberships endpoint from a URL string.

Examples

iex> Ltix.LaunchClaims.MembershipsEndpoint.new("https://lms.example.com/memberships")
{:ok, %Ltix.LaunchClaims.MembershipsEndpoint{context_memberships_url: "https://lms.example.com/memberships", service_versions: nil}}

Ltix.LaunchClaims.MembershipsEndpoint.new("http://lms.example.com/memberships")
#=> {:error, %Ltix.Errors.Invalid.InvalidField{field: :context_memberships_url}}

new!(url)

@spec new!(String.t()) :: t()

Same as new/1 but raises on an invalid URL.

Examples

iex> Ltix.LaunchClaims.MembershipsEndpoint.new!("https://lms.example.com/memberships")
%Ltix.LaunchClaims.MembershipsEndpoint{context_memberships_url: "https://lms.example.com/memberships", service_versions: nil}