# `KapsoEx.WhatsApp.TemplateComponents`
[🔗](https://github.com/rocket4ce/kapso_ex/blob/v0.1.0/lib/kapso_ex/whatsapp/template_components.ex#L1)

Builders for the `components` list sent with a template message.

Parameter values may be strings (sent as `text` parameters) or full
parameter maps, such as `%{type: "currency", currency: %{...}}`.

## Examples

    alias KapsoEx.WhatsApp.TemplateComponents, as: C

    # Positional parameters ({{1}}, {{2}})
    C.body(["Ana", "#1234"])

    # Named parameters ({{first_name}})
    C.body(first_name: "Ana", order_number: "#1234")

    Messages.send_template(client, phone_number_id, "56961567267", "seasonal_promotion", "en_US",
      components: [
        C.header_media(:image, "https://example.com/sale.jpg"),
        C.body(sale_name: "Summer Sale"),
        C.button_url(0, "summer2024"),
        C.button_quick_reply(1, "unsubscribe")
      ]
    )

# `value`

```elixir
@type value() :: String.t() | map()
```

# `authentication`

```elixir
@spec authentication(String.t()) :: [map()]
```

Components for an authentication (OTP) template: the code in the body and
in the copy code / one-tap button.

    Messages.send_template(client, phone_number_id, "56961567267", "login_code", "es",
      components: TemplateComponents.authentication("482913"))

# `body`

```elixir
@spec body([value()] | keyword() | map()) :: map()
```

Body parameters: a list of values (positional) or a keyword list / map of
`parameter_name => value` (named).

# `button_copy_code`

```elixir
@spec button_copy_code(non_neg_integer(), String.t()) :: map()
```

Coupon code for the copy code button at `index`.

# `button_flow`

```elixir
@spec button_flow(non_neg_integer(), map()) :: map()
```

Action for the flow button at `index`, such as
`%{flow_token: "...", flow_action_data: %{...}}`.

# `button_quick_reply`

```elixir
@spec button_quick_reply(non_neg_integer(), String.t()) :: map()
```

Payload returned when the quick reply button at `index` is tapped.

# `button_url`

```elixir
@spec button_url(non_neg_integer(), value()) :: map()
```

Dynamic suffix for the URL button at `index`.

# `header_location`

```elixir
@spec header_location(map() | keyword()) :: map()
```

Location header with `:latitude`, `:longitude`, `:name` and `:address`.

# `header_media`

```elixir
@spec header_media(:image | :video | :document, String.t() | map()) :: map()
```

Media header. `type` is `:image`, `:video` or `:document`; `media` is a
URL, an uploaded media ID or a map such as `%{id: ..., filename: ...}`.

# `header_text`

```elixir
@spec header_text(value()) :: map()
```

Text header with one parameter, optionally named.

# `header_text`

```elixir
@spec header_text(atom() | String.t(), value()) :: map()
```

---

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