Ltix.DeepLinking.ContentItem.Link (Ltix v0.2.0)

Copy Markdown View Source

A URL link content item for Deep Linking responses.

Use this for external URLs hosted outside your tool, such as articles, documentation, or third-party resources. For links that launch back into your tool via LTI, use Ltix.DeepLinking.ContentItem.LTIResourceLink.

Examples

iex> {:ok, link} = Ltix.DeepLinking.ContentItem.Link.new(
...>   url: "https://example.com/article",
...>   window: [target_name: "articles"]
...> )
iex> Ltix.DeepLinking.ContentItem.to_map(link)
%{"type" => "link", "url" => "https://example.com/article", "window" => %{"targetName" => "articles"}}

Options

  • :title (String.t/0) - Title for the content item.

  • :text (String.t/0) - Plain-text description.

  • :extensions (nil | map/0) - Required. Vendor-specific extension properties. The default value is %{}.

  • :embed (map/0)

  • :url (String.t/0) - Required. URL of the link.

  • :icon (map/0) - Icon or thumbnail for the link.

  • :thumbnail (map/0) - Icon or thumbnail for the link.

  • :window (map/0) - Window presentation for the link.

  • :iframe (map/0) - Iframe presentation for the link.

Summary

Functions

Create a new link content item.

Same as new/1 but raises on error.

Types

t()

@type t() :: %Ltix.DeepLinking.ContentItem.Link{
  embed: nil | %{html: binary()},
  extensions: nil | %{optional(binary() | atom()) => any()},
  icon:
    nil
    | %{
        optional(:width) => integer(),
        :url => binary(),
        optional(:height) => integer()
      },
  iframe:
    nil
    | %{
        optional(:width) => integer(),
        optional(:height) => integer(),
        src: binary()
      },
  text: nil | binary(),
  thumbnail:
    nil
    | %{
        optional(:width) => integer(),
        :url => binary(),
        optional(:height) => integer()
      },
  title: nil | binary(),
  url: binary(),
  window:
    nil
    | %{
        optional(:width) => integer(),
        optional(:height) => integer(),
        optional(:target_name) => binary(),
        optional(:window_features) => binary()
      }
}

Functions

new(opts)

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

Create a new link content item.

Takes the module's options as a keyword list or map, and nested options such as icon may also be keyword lists. Unknown or invalid options return an Ltix.Errors.Invalid.InvalidField error.

Examples

iex> {:ok, link} = Ltix.DeepLinking.ContentItem.Link.new(url: "https://example.com")
iex> link.url
"https://example.com"

iex> {:error, error} = Ltix.DeepLinking.ContentItem.Link.new([])
iex> Exception.message(error)
"Ltix.DeepLinking.ContentItem.Link field :url is required [DL §3.1]"

new!(opts)

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

Same as new/1 but raises on error.

Examples

iex> Ltix.DeepLinking.ContentItem.Link.new!(url: "https://example.com").url
"https://example.com"