BlockBox (blockbox v1.2.1)
A tool used to generate slack UI blocks using elixir defined functions.
installation
Installation
def deps do
[
{:blockbox, "~> 1.1.2"}
]
end
usage
Usage
use BlockBox to access all the generator functions defined in other modules.
use BlockBox
Link to this section Summary
Functions
A quality-of-life function that takes in the values
key of the view response payload and generates a map from action_id
to the bottom level values.
Link to this section Functions
Link to this function
get_submission_values(values_payload, type \\ :action_id)
A quality-of-life function that takes in the values
key of the view response payload and generates a map from action_id
to the bottom level values.
By default, the function maps action_id
s to values (recommended approach) but by specifying :block_id
as the second argument, it will map block_id
s to values instead.
example
Example
iex> view_values_payload = %{
...> "attachments" => %{
...> "att_input" => %{
...> "type" => "multi_static_select",
...> "selected_options" => [%{"value" => "1"}, %{"value" => "2"}]
...> }
...> },
...> "description" => %{
...> "desc_input" => %{"type" => "plain_text_input", "value" => "description text"}
...> },
...> "labels" => %{
...> "label_input" => %{"type" => "plain_text_input", "value" => "label text"}
...> },
...> "priority" => %{
...> "pri_input" => %{
...> "selected_option" => %{
...> "text" => %{"emoji" => true, "text" => "P4", "type" => "plain_text"},
...> "value" => "9"
...> },
...> "type" => "static_select"
...> }
...> },
...> "summary" => %{
...> "summ_input" => %{"type" => "plain_text_input", "value" => "summary text"}
...> },
...> "watchers" => %{
...> "watch_input" => %{"type" => "multi_users_select", "selected_users" => ["11221", "12D123"]}
...> }
...>}
iex> BlockBox.get_submission_values(view_values_payload)
%{
"att_input" => ["1", "2"],
"desc_input" => "description text",
"label_input" => "label text",
"pri_input" => "9",
"summ_input" => "summary text",
"watch_input" => ["11221", "12D123"]
}
iex> BlockBox.get_submission_values(view_values_payload, :block_id)
%{
"attachments" => ["1", "2"],
"description" => "description text",
"labels" => "label text",
"priority" => "9",
"summary" => "summary text",
"watchers" => ["11221", "12D123"]
}