Ltix.LaunchClaims.Context (Ltix v0.2.0)

Copy Markdown View Source

The context (e.g. course or section) in which the launch occurs.

id is required and uniquely identifies the context within a deployment.

Examples

iex> Ltix.LaunchClaims.Context.from_json(%{"id" => "ctx-1", "label" => "CS101"})
{:ok, %Ltix.LaunchClaims.Context{id: "ctx-1", label: "CS101", title: nil, type: nil}}

Summary

Functions

Parse a context claim from a JSON map.

Serialize a context to a map with the claim's JSON keys, omitting fields that are nil.

Types

t()

@type t() :: %Ltix.LaunchClaims.Context{
  id: binary(),
  label: nil | binary(),
  title: nil | binary(),
  type: nil | [binary()]
}

Functions

from_json(json)

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

Parse a context claim from a JSON map.

Examples

iex> Ltix.LaunchClaims.Context.from_json(%{"id" => "ctx-1"})
{:ok, %Ltix.LaunchClaims.Context{id: "ctx-1", label: nil, title: nil, type: nil}}

to_map(context)

@spec to_map(t()) :: map()

Serialize a context to a map with the claim's JSON keys, omitting fields that are nil.

Examples

iex> Ltix.LaunchClaims.Context.to_map(%Ltix.LaunchClaims.Context{id: "ctx-1", label: "CS101"})
%{"id" => "ctx-1", "label" => "CS101"}