Ltix.LaunchClaims.AGSEndpoint (Ltix v0.2.0)

Copy Markdown View Source

Assignment and Grade Services (AGS) endpoint claim.

Provides URLs for managing line items and scores. :scopes lists the grade service scopes the tool may request, :line_items is the URL of the line items container, and :line_item is the URL of the line item coupled to the resource link.

Launches include this claim. To call the grade service outside a launch, build the endpoint with new/1 from the URLs and scopes you saved.

Examples

iex> Ltix.LaunchClaims.AGSEndpoint.from_json(%{"lineitems" => "https://example.com/lineitems"})
{:ok, %Ltix.LaunchClaims.AGSEndpoint{scopes: nil, line_items: "https://example.com/lineitems", line_item: nil}}

Summary

Functions

Parse an AGS endpoint claim from a JSON map.

Build an endpoint from a keyword list or a map.

Same as new/1 but raises on error.

Types

t()

@type t() :: %Ltix.LaunchClaims.AGSEndpoint{
  line_item: nil | binary(),
  line_items: nil | binary(),
  scopes: nil | [binary()]
}

Functions

from_json(json)

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

Parse an AGS endpoint claim from a JSON map.

Examples

iex> Ltix.LaunchClaims.AGSEndpoint.from_json(%{})
{:ok, %Ltix.LaunchClaims.AGSEndpoint{scopes: nil, line_items: nil, line_item: nil}}

new(attributes)

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

Build an endpoint from a keyword list or a map.

:scopes is required. :line_items and :line_item are optional absolute HTTPS URLs that may be nil.

Examples

iex> Ltix.LaunchClaims.AGSEndpoint.new(
...>   line_item: "https://lms.example.com/lineitems/1",
...>   scopes: ["https://purl.imsglobal.org/spec/lti-ags/scope/score"]
...> )
{:ok, %Ltix.LaunchClaims.AGSEndpoint{scopes: ["https://purl.imsglobal.org/spec/lti-ags/scope/score"], line_items: nil, line_item: "https://lms.example.com/lineitems/1"}}

iex> {:error, error} = Ltix.LaunchClaims.AGSEndpoint.new(line_item: "https://lms.example.com/lineitems/1")
iex> Exception.message(error)
"Ltix.LaunchClaims.AGSEndpoint field :scopes is required [AGS §3.1]"

new!(attributes)

@spec new!(keyword() | map()) :: t()

Same as new/1 but raises on error.