A file content item for Deep Linking responses.
File URLs are short-lived. The platform downloads the file shortly after receiving the response, so the URL only needs to remain valid for a few minutes.
Examples
iex> {:ok, file} = Ltix.DeepLinking.ContentItem.File.new(
...> url: "https://example.com/syllabus.pdf",
...> media_type: "application/pdf"
...> )
iex> Ltix.DeepLinking.ContentItem.to_map(file)
%{"type" => "file", "url" => "https://example.com/syllabus.pdf", "mediaType" => "application/pdf"}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%{}.:url(String.t/0) - Required. URL to download the file.:expires_at(DateTime.t/0) - When the download URL expires.:media_type(String.t/0) - MIME type of the file (e.g."application/pdf").:icon(map/0) - Icon or thumbnail for the file.:thumbnail(map/0) - Icon or thumbnail for the file.
Summary
Types
@type t() :: %Ltix.DeepLinking.ContentItem.File{ expires_at: nil | DateTime.t(), extensions: nil | %{optional(binary() | atom()) => any()}, icon: nil | %{ optional(:width) => integer(), :url => binary(), optional(:height) => integer() }, media_type: nil | binary(), text: nil | binary(), thumbnail: nil | %{ optional(:width) => integer(), :url => binary(), optional(:height) => integer() }, title: nil | binary(), url: binary() }
Functions
@spec new(keyword() | map()) :: {:ok, t()} | {:error, Exception.t()}
Create a new file 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, file} = Ltix.DeepLinking.ContentItem.File.new(url: "https://example.com/doc.pdf")
iex> file.url
"https://example.com/doc.pdf"
iex> {:error, error} = Ltix.DeepLinking.ContentItem.File.new([])
iex> Exception.message(error)
"Ltix.DeepLinking.ContentItem.File field :url is required [DL §3.3]"
Same as new/1 but raises on error.
Examples
iex> Ltix.DeepLinking.ContentItem.File.new!(url: "https://example.com/doc.pdf").url
"https://example.com/doc.pdf"