-module(kitazith@poll). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/kitazith/poll.gleam"). -export([new/2, with_duration/2, with_allow_multiselect/2, with_layout_type/2, new_poll_media/0, with_poll_media_text/2, with_poll_media_emoji/2, new_poll_emoji/0, with_poll_emoji_id/2, with_poll_emoji_name/2, to_json/1]). -export_type([poll/0, poll_question/0, poll_answer/0, poll_media/0, poll_emoji/0]). -type poll() :: {poll, poll_question(), list(poll_answer()), gleam@option:option(integer()), gleam@option:option(boolean()), gleam@option:option(integer())}. -type poll_question() :: {poll_question, binary()}. -type poll_answer() :: {poll_answer, poll_media()}. -type poll_media() :: {poll_media, gleam@option:option(binary()), gleam@option:option(poll_emoji())}. -type poll_emoji() :: {poll_emoji, gleam@option:option(kitazith@snowflake:snowflake()), gleam@option:option(binary())}. -file("src/kitazith/poll.gleam", 63). -spec new(poll_question(), list(poll_answer())) -> poll(). new(Question, Answers) -> {poll, Question, Answers, none, none, none}. -file("src/kitazith/poll.gleam", 76). -spec with_duration(poll(), integer()) -> poll(). with_duration(Poll, Duration) -> {poll, erlang:element(2, Poll), erlang:element(3, Poll), {some, Duration}, erlang:element(5, Poll), erlang:element(6, Poll)}. -file("src/kitazith/poll.gleam", 80). -spec with_allow_multiselect(poll(), boolean()) -> poll(). with_allow_multiselect(Poll, Allow_multiselect) -> {poll, erlang:element(2, Poll), erlang:element(3, Poll), erlang:element(4, Poll), {some, Allow_multiselect}, erlang:element(6, Poll)}. -file("src/kitazith/poll.gleam", 84). -spec with_layout_type(poll(), integer()) -> poll(). with_layout_type(Poll, Layout_type) -> {poll, erlang:element(2, Poll), erlang:element(3, Poll), erlang:element(4, Poll), erlang:element(5, Poll), {some, Layout_type}}. -file("src/kitazith/poll.gleam", 88). -spec new_poll_media() -> poll_media(). new_poll_media() -> {poll_media, none, none}. -file("src/kitazith/poll.gleam", 92). -spec with_poll_media_text(poll_media(), binary()) -> poll_media(). with_poll_media_text(Media, Text) -> {poll_media, {some, Text}, erlang:element(3, Media)}. -file("src/kitazith/poll.gleam", 96). -spec with_poll_media_emoji(poll_media(), poll_emoji()) -> poll_media(). with_poll_media_emoji(Media, Emoji) -> {poll_media, erlang:element(2, Media), {some, Emoji}}. -file("src/kitazith/poll.gleam", 100). -spec new_poll_emoji() -> poll_emoji(). new_poll_emoji() -> {poll_emoji, none, none}. -file("src/kitazith/poll.gleam", 104). -spec with_poll_emoji_id(poll_emoji(), kitazith@snowflake:snowflake()) -> poll_emoji(). with_poll_emoji_id(Emoji, Id) -> {poll_emoji, {some, Id}, erlang:element(3, Emoji)}. -file("src/kitazith/poll.gleam", 111). -spec with_poll_emoji_name(poll_emoji(), binary()) -> poll_emoji(). with_poll_emoji_name(Emoji, Name) -> {poll_emoji, erlang:element(2, Emoji), {some, Name}}. -file("src/kitazith/poll.gleam", 140). -spec poll_emoji_to_json(poll_emoji()) -> gleam@json:json(). poll_emoji_to_json(E) -> kitazith@internal@json_helper:object_omit_none( [kitazith@internal@json_helper:optional( <<"id"/utf8>>, erlang:element(2, E), fun kitazith@snowflake:to_json/1 ), kitazith@internal@json_helper:optional( <<"name"/utf8>>, erlang:element(3, E), fun gleam@json:string/1 )] ). -file("src/kitazith/poll.gleam", 133). -spec poll_media_to_json(poll_media()) -> gleam@json:json(). poll_media_to_json(M) -> kitazith@internal@json_helper:object_omit_none( [kitazith@internal@json_helper:optional( <<"text"/utf8>>, erlang:element(2, M), fun gleam@json:string/1 ), kitazith@internal@json_helper:optional( <<"emoji"/utf8>>, erlang:element(3, M), fun poll_emoji_to_json/1 )] ). -file("src/kitazith/poll.gleam", 129). -spec poll_answer_to_json(poll_answer()) -> gleam@json:json(). poll_answer_to_json(A) -> gleam@json:object( [{<<"poll_media"/utf8>>, poll_media_to_json(erlang:element(2, A))}] ). -file("src/kitazith/poll.gleam", 125). -spec poll_question_to_json(poll_question()) -> gleam@json:json(). poll_question_to_json(Q) -> gleam@json:object( [{<<"text"/utf8>>, gleam@json:string(erlang:element(2, Q))}] ). -file("src/kitazith/poll.gleam", 115). -spec to_json(poll()) -> gleam@json:json(). to_json(P) -> kitazith@internal@json_helper:object_omit_none( [{some, {<<"question"/utf8>>, poll_question_to_json(erlang:element(2, P))}}, {some, {<<"answers"/utf8>>, gleam@json:array( erlang:element(3, P), fun poll_answer_to_json/1 )}}, kitazith@internal@json_helper:optional( <<"duration"/utf8>>, erlang:element(4, P), fun gleam@json:int/1 ), kitazith@internal@json_helper:optional( <<"allow_multiselect"/utf8>>, erlang:element(5, P), fun gleam@json:bool/1 ), kitazith@internal@json_helper:optional( <<"layout_type"/utf8>>, erlang:element(6, P), fun gleam@json:int/1 )] ).