ExLine.Message.Imagemap (ExLine v0.1.0)

Copy Markdown View Source

Builders for imagemap sub-objects: tappable areas and their actions, plus the base size, used by ExLine.Message.imagemap/5.

Ref: https://developers.line.biz/en/reference/messaging-api/#imagemap-message

Summary

Functions

A tappable area (pixels relative to baseUrl at baseSize).

Base size of the imagemap image.

Message imagemap action — sends text as the user when the area is tapped.

URI imagemap action — opens link_uri when the area is tapped.

Functions

area(x, y, width, height)

@spec area(integer(), integer(), integer(), integer()) :: map()

A tappable area (pixels relative to baseUrl at baseSize).

iex> ExLine.Message.Imagemap.area(0, 0, 520, 1040)
%{x: 0, y: 0, width: 520, height: 1040}

base_size(width, height)

@spec base_size(integer(), integer()) :: map()

Base size of the imagemap image.

iex> ExLine.Message.Imagemap.base_size(1040, 1040)
%{width: 1040, height: 1040}

message_action(text, area, opts \\ [])

@spec message_action(String.t(), map(), keyword()) :: map()

Message imagemap action — sends text as the user when the area is tapped.

iex> ExLine.Message.Imagemap.message_action("hello", ExLine.Message.Imagemap.area(0, 0, 1, 1))
%{type: "message", text: "hello", area: %{x: 0, y: 0, width: 1, height: 1}}

uri_action(link_uri, area, opts \\ [])

@spec uri_action(String.t(), map(), keyword()) :: map()

URI imagemap action — opens link_uri when the area is tapped.

iex> ExLine.Message.Imagemap.uri_action("https://x", ExLine.Message.Imagemap.area(0, 0, 1, 1))
%{type: "uri", linkUri: "https://x", area: %{x: 0, y: 0, width: 1, height: 1}}