# `Ltix.DeepLinking.ContentItem.LTIResourceLink`
[🔗](https://github.com/DecoyLex/ltix/blob/main/lib/ltix/deep_linking/content_item/lti_resource_link.ex#L1)

An LTI resource link content item for Deep Linking responses.

All fields are optional. The platform can use the tool's base URL when
no `url` is provided. Include a `line_item` to have the platform
auto-create a gradebook column for the link.

See [Building Content Items](cookbooks/building-content-items.md) for
common patterns including line items, custom parameters, and
availability windows.

## Examples

    iex> {:ok, link} = Ltix.DeepLinking.ContentItem.LTIResourceLink.new(
    ...>   url: "https://tool.example.com/quizzes/7",
    ...>   line_item: [score_maximum: 100]
    ...> )
    iex> Ltix.DeepLinking.ContentItem.to_map(link)
    %{"type" => "ltiResourceLink", "url" => "https://tool.example.com/quizzes/7", "lineItem" => %{"scoreMaximum" => 100}}

## Options

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

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

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

* `:available` (`t:map/0`)

* `:url` (`t:String.t/0`) - Launch URL for the resource link.

* `:line_item` (`t:map/0`) - Gradebook column for the platform to create, as a keyword list, map, or `Ltix.GradeService.LineItem`.

* `:submission` (`t:map/0`)

* `:custom` (`t:map/0`) - Custom parameter key-value pairs.

* `:icon` (`t:map/0`) - Icon or thumbnail for the LTI resource link.

* `:thumbnail` (`t:map/0`) - Icon or thumbnail for the LTI resource link.

* `:window` (`t:map/0`) - Window presentation for the LTI resource link.

* `:iframe` (`t:map/0`)

# `t`

```elixir
@type t() :: %Ltix.DeepLinking.ContentItem.LTIResourceLink{
  available:
    nil
    | %{
        optional(:start_date_time) =&gt; DateTime.t(),
        optional(:end_date_time) =&gt; DateTime.t()
      },
  custom: nil | %{optional(binary() | atom()) =&gt; binary()},
  extensions: nil | %{optional(binary() | atom()) =&gt; any()},
  icon:
    nil
    | %{
        optional(:width) =&gt; integer(),
        :url =&gt; binary(),
        optional(:height) =&gt; integer()
      },
  iframe:
    nil | %{optional(:width) =&gt; integer(), optional(:height) =&gt; integer()},
  line_item:
    nil
    | %{
        optional(:label) =&gt; binary(),
        optional(:tag) =&gt; binary(),
        :score_maximum =&gt; number(),
        optional(:resource_id) =&gt; binary(),
        optional(:grades_released) =&gt; boolean()
      },
  submission:
    nil
    | %{
        optional(:start_date_time) =&gt; DateTime.t(),
        optional(:end_date_time) =&gt; DateTime.t()
      },
  text: nil | binary(),
  thumbnail:
    nil
    | %{
        optional(:width) =&gt; integer(),
        :url =&gt; binary(),
        optional(:height) =&gt; integer()
      },
  title: nil | binary(),
  url: nil | binary(),
  window:
    nil
    | %{
        optional(:width) =&gt; integer(),
        optional(:height) =&gt; integer(),
        optional(:target_name) =&gt; binary(),
        optional(:window_features) =&gt; binary()
      }
}
```

# `new`

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

Create a new LTI resource 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.LTIResourceLink.new([])
    iex> link.url
    nil

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

# `new!`

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

Same as `new/1` but raises on error.

## Examples

    iex> Ltix.DeepLinking.ContentItem.LTIResourceLink.new!(title: "Quiz 1").title
    "Quiz 1"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
