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

Protocol for serializing content items in Deep Linking responses.

Ltix implements this protocol for the five standard content item types
and for plain maps (for one-off custom types).
Implement this protocol on your own struct when you need a reusable
custom content item type.

    defmodule MyApp.ProctoredExam do
      defstruct [:url, :title, :duration_minutes]

      defimpl Ltix.DeepLinking.ContentItem do
        def to_map(item) do
          %{
            "type" => "https://myapp.example.com/proctored_exam",
            "url" => item.url,
            "title" => item.title,
            "https://myapp.example.com/duration" => item.duration_minutes
          }
        end
      end
    end

The platform's `accept_types` must include the `"type"` your `to_map/1`
returns.

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `to_map`

```elixir
@spec to_map(t()) :: %{required(String.t()) =&gt; any()}
```

Serialize the content item to a JSON-compatible map.

Plain maps with a `"type"` key serialize as they are.

## Examples

    iex> Ltix.DeepLinking.ContentItem.to_map(%{"type" => "https://vendor.example.com/poll", "question" => "Ready?"})
    %{"type" => "https://vendor.example.com/poll", "question" => "Ready?"}

---

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