-module(telega@model). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([decode_bot_command/1, default_botcommand_parameters/0, bot_commands_from/1, decode_user/1, decode_message_entity/1, new_send_message_parameters/2, set_send_message_parameters_reply_markup/2, decode_keyboard_button_request_users/1, new_send_dice_parameters/1, decode_webhook_info/1, decode_web_app_info/1, decode_web_app_data/1, decode_login_url/1, decode_switch_inline_query_chosen_chat/1, decode_inline_button/1, decode_inline_markup/1, decode_inaccessible_message/1, default_edit_message_text_parameters/0, new_answer_callback_query_parameters/1, decode_message/1, decode_maybe_inaccessible_message/1, decode_callback_query/1, decode_update/1, decode_edit_message_text_result/1, bot_command_scope_to_json/1, encode_botcommand_parameters/1, encode_user/1, encode_message_entity/1, encode_keyboard_button_request_users/1, encode_keyboard_button_poll_type/1, encode_reply_parameters/1, encode_send_dice_parameters/1, encode_web_app_info/1, encode_login_url/1, encode_switch_inline_query_chosen_chat/1, encode_inline_keyboard_button/1, encode_inline_keyboard_markup/1, encode_chat_administrator_rights/1, encode_keyboard_button_request_chat/1, encode_keyboard_button/1, encode_reply_markup/1, encode_link_preview_options/1, encode_send_message_parameters/1, encode_edit_message_text_parameters/1, encode_forward_message_parameters/1, encode_answer_callback_query_parameters/1, encode_set_webhook_parameters/1]). -export_type([update/0, chat/0, message/0, bot_command/0, bot_command_scope/0, bot_command_parameters/0, user/0, message_entity/0, send_message_parameters/0, inline_keyboard_button/0, inline_keyboard_markup/0, keyboard_button/0, keyboard_button_request_users/0, keyboard_button_request_chat/0, keyboard_button_poll_type/0, reply_parameters/0, reply_markup/0, send_dice_parameters/0, webhook_info/0, web_app_info/0, web_app_data/0, login_url/0, switch_inline_query_chosen_chat/0, chat_administrator_rights/0, link_preview_options/0, callback_query/0, inaccessible_message/0, maybe_inaccessible_message/0, edit_message_text_parameters/0, edit_message_text_result/0, forward_message_parameters/0, answer_callback_query_parameters/0, set_webhook_parameters/0, int_or_string/0]). -type update() :: {update, integer(), gleam@option:option(message()), gleam@option:option(message()), gleam@option:option(callback_query())}. -type chat() :: {chat, integer(), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(boolean())}. -type message() :: {message, integer(), gleam@option:option(integer()), gleam@option:option(user()), gleam@option:option(chat()), gleam@option:option(integer()), integer(), chat(), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(message()), gleam@option:option(user()), gleam@option:option(integer()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(list(message_entity())), gleam@option:option(binary()), gleam@option:option(list(message_entity())), gleam@option:option(boolean()), gleam@option:option(list(user())), gleam@option:option(user()), gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(integer()), gleam@option:option(integer()), gleam@option:option(binary()), gleam@option:option(web_app_data()), gleam@option:option(inline_keyboard_markup())}. -type bot_command() :: {bot_command, binary(), binary()}. -type bot_command_scope() :: bot_command_default_scope | bot_command_all_private_chats_scope | bot_command_scope_all_group_chats | bot_command_scope_all_chat_administrators | {bot_command_scope_chat, integer()} | {bot_command_scope_chat_string, int_or_string()} | {bot_command_scope_chat_administrators, int_or_string()} | {bot_command_scope_chat_member, int_or_string(), integer()}. -type bot_command_parameters() :: {bot_command_parameters, gleam@option:option(bot_command_scope()), gleam@option:option(binary())}. -type user() :: {user, integer(), boolean(), binary(), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(boolean())}. -type message_entity() :: {message_entity, binary(), integer(), integer(), gleam@option:option(binary()), gleam@option:option(user()), gleam@option:option(binary()), gleam@option:option(binary())}. -type send_message_parameters() :: {send_message_parameters, gleam@option:option(binary()), int_or_string(), gleam@option:option(integer()), binary(), gleam@option:option(binary()), gleam@option:option(list(message_entity())), gleam@option:option(link_preview_options()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(reply_parameters()), gleam@option:option(reply_markup())}. -type inline_keyboard_button() :: {inline_keyboard_button, binary(), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(web_app_info()), gleam@option:option(login_url()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(switch_inline_query_chosen_chat()), gleam@option:option(boolean())}. -type inline_keyboard_markup() :: {inline_keyboard_markup, list(list(inline_keyboard_button()))}. -type keyboard_button() :: {keyboard_button, binary(), gleam@option:option(keyboard_button_request_users()), gleam@option:option(keyboard_button_request_chat()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(keyboard_button_poll_type()), gleam@option:option(web_app_info())}. -type keyboard_button_request_users() :: {keyboard_button_request_users, integer(), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(integer()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean())}. -type keyboard_button_request_chat() :: {keyboard_button_request_chat, integer(), boolean(), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(chat_administrator_rights()), gleam@option:option(chat_administrator_rights()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean())}. -type keyboard_button_poll_type() :: {keyboard_button_poll_type, gleam@option:option(binary())}. -type reply_parameters() :: {reply_parameters, integer(), gleam@option:option(int_or_string()), gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(list(message_entity())), gleam@option:option(integer())}. -type reply_markup() :: {reply_inline_keyboard_markup, list(list(inline_keyboard_button()))} | {reply_keyboard_markup, list(list(keyboard_button())), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(boolean())} | {reply_keyboard_remove, boolean(), gleam@option:option(boolean())} | {force_reply, boolean(), binary(), boolean()}. -type send_dice_parameters() :: {send_dice_parameters, int_or_string(), gleam@option:option(integer()), gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(reply_parameters())}. -type webhook_info() :: {webhook_info, binary(), boolean(), integer(), gleam@option:option(binary()), gleam@option:option(integer()), gleam@option:option(binary()), gleam@option:option(integer()), gleam@option:option(integer()), gleam@option:option(list(binary()))}. -type web_app_info() :: {web_app_info, binary()}. -type web_app_data() :: {web_app_data, binary(), binary()}. -type login_url() :: {login_url, binary(), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(boolean())}. -type switch_inline_query_chosen_chat() :: {switch_inline_query_chosen_chat, gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean())}. -type chat_administrator_rights() :: {chat_administrator_rights, boolean(), boolean(), boolean(), boolean(), boolean(), boolean(), boolean(), boolean(), boolean(), boolean(), boolean(), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean())}. -type link_preview_options() :: {link_preview_options, gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(boolean())}. -type callback_query() :: {callback_query, binary(), user(), gleam@option:option(maybe_inaccessible_message()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary())}. -type inaccessible_message() :: {inaccessible_message, chat(), integer(), integer()}. -type maybe_inaccessible_message() :: {maybe_inaccessible_message_message, message()} | {maybe_inaccessible_message_inaccessible, inaccessible_message()}. -type edit_message_text_parameters() :: {edit_message_text_parameters, gleam@option:option(int_or_string()), gleam@option:option(integer()), gleam@option:option(binary()), binary(), gleam@option:option(binary()), gleam@option:option(list(message_entity())), gleam@option:option(link_preview_options()), gleam@option:option(inline_keyboard_markup())}. -type edit_message_text_result() :: {edit_message_text_message, message()} | {edit_message_text_bool, boolean()}. -type forward_message_parameters() :: {forward_message_parameters, int_or_string(), int_or_string(), integer(), gleam@option:option(boolean()), gleam@option:option(integer()), gleam@option:option(boolean())}. -type answer_callback_query_parameters() :: {answer_callback_query_parameters, binary(), gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(integer())}. -type set_webhook_parameters() :: {set_webhook_parameters, binary(), gleam@option:option(integer()), gleam@option:option(binary()), gleam@option:option(list(binary())), gleam@option:option(boolean()), gleam@option:option(binary())}. -type int_or_string() :: {inted, integer()} | {stringed, binary()}. -spec decode_chat(gleam@dynamic:dynamic_()) -> {ok, chat()} | {error, list(gleam@dynamic:decode_error())}. decode_chat(Json) -> _pipe = Json, (gleam@dynamic:decode5( fun(Field@0, Field@1, Field@2, Field@3, Field@4) -> {chat, Field@0, Field@1, Field@2, Field@3, Field@4} end, gleam@dynamic:field(<<"id"/utf8>>, fun gleam@dynamic:int/1), gleam@dynamic:optional_field( <<"username"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"first_name"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"last_name"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"is_forum"/utf8>>, fun gleam@dynamic:bool/1 ) ))(_pipe). -spec decode_bot_command(gleam@dynamic:dynamic_()) -> {ok, list(bot_command())} | {error, list(gleam@dynamic:decode_error())}. decode_bot_command(Json) -> _pipe = Json, (gleam@dynamic:list( gleam@dynamic:decode2( fun(Field@0, Field@1) -> {bot_command, Field@0, Field@1} end, gleam@dynamic:field(<<"command"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:field( <<"description"/utf8>>, fun gleam@dynamic:string/1 ) ) ))(_pipe). -spec default_botcommand_parameters() -> bot_command_parameters(). default_botcommand_parameters() -> {bot_command_parameters, none, none}. -spec bot_commands_from(list({binary(), binary()})) -> list(bot_command()). bot_commands_from(Commands) -> _pipe = Commands, gleam@list:map( _pipe, fun(Command) -> {Command@1, Description} = Command, {bot_command, Command@1, Description} end ). -spec decode_user(gleam@dynamic:dynamic_()) -> {ok, user()} | {error, list(gleam@dynamic:decode_error())}. decode_user(Json) -> _pipe = Json, (gleam@dynamic:decode8( fun(Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6, Field@7) -> {user, Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6, Field@7} end, gleam@dynamic:field(<<"id"/utf8>>, fun gleam@dynamic:int/1), gleam@dynamic:field(<<"is_bot"/utf8>>, fun gleam@dynamic:bool/1), gleam@dynamic:field(<<"first_name"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:optional_field( <<"last_name"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"username"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"language_code"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"is_premium"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"added_to_attachment_menu"/utf8>>, fun gleam@dynamic:bool/1 ) ))(_pipe). -spec decode_message_entity(gleam@dynamic:dynamic_()) -> {ok, message_entity()} | {error, list(gleam@dynamic:decode_error())}. decode_message_entity(Json) -> _pipe = Json, (gleam@dynamic:decode7( fun(Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6) -> {message_entity, Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6} end, gleam@dynamic:field(<<"type"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:field(<<"offset"/utf8>>, fun gleam@dynamic:int/1), gleam@dynamic:field(<<"length"/utf8>>, fun gleam@dynamic:int/1), gleam@dynamic:optional_field(<<"url"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:optional_field(<<"user"/utf8>>, fun decode_user/1), gleam@dynamic:optional_field( <<"language"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"custom_emoji_id"/utf8>>, fun gleam@dynamic:string/1 ) ))(_pipe). -spec new_send_message_parameters(int_or_string(), binary()) -> send_message_parameters(). new_send_message_parameters(Chat_id, Text) -> {send_message_parameters, none, Chat_id, none, Text, none, none, none, none, none, none, none}. -spec set_send_message_parameters_reply_markup( send_message_parameters(), reply_markup() ) -> send_message_parameters(). set_send_message_parameters_reply_markup(Params, Reply_markup) -> erlang:setelement(12, Params, {some, Reply_markup}). -spec decode_keyboard_button_request_users(gleam@dynamic:dynamic_()) -> {ok, keyboard_button_request_users()} | {error, list(gleam@dynamic:decode_error())}. decode_keyboard_button_request_users(Json) -> _pipe = Json, (gleam@dynamic:decode7( fun(Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6) -> {keyboard_button_request_users, Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6} end, gleam@dynamic:field(<<"request_id"/utf8>>, fun gleam@dynamic:int/1), gleam@dynamic:optional_field( <<"user_is_bot"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"user_is_premium"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"max_quantity"/utf8>>, fun gleam@dynamic:int/1 ), gleam@dynamic:optional_field( <<"request_name"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"request_username"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"request_photo"/utf8>>, fun gleam@dynamic:bool/1 ) ))(_pipe). -spec new_send_dice_parameters(int_or_string()) -> send_dice_parameters(). new_send_dice_parameters(Chat_id) -> {send_dice_parameters, Chat_id, none, none, none, none, none}. -spec decode_webhook_info(gleam@dynamic:dynamic_()) -> {ok, webhook_info()} | {error, list(gleam@dynamic:decode_error())}. decode_webhook_info(Json) -> _pipe = Json, (gleam@dynamic:decode9( fun(Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6, Field@7, Field@8) -> {webhook_info, Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6, Field@7, Field@8} end, gleam@dynamic:field(<<"url"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:field( <<"has_custom_certificate"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:field( <<"pending_update_count"/utf8>>, fun gleam@dynamic:int/1 ), gleam@dynamic:optional_field( <<"ip_address"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"last_error_date"/utf8>>, fun gleam@dynamic:int/1 ), gleam@dynamic:optional_field( <<"last_error_message"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"last_synchronization_error_date"/utf8>>, fun gleam@dynamic:int/1 ), gleam@dynamic:optional_field( <<"max_connections"/utf8>>, fun gleam@dynamic:int/1 ), gleam@dynamic:optional_field( <<"allowed_updates"/utf8>>, gleam@dynamic:list(fun gleam@dynamic:string/1) ) ))(_pipe). -spec decode_web_app_info(gleam@dynamic:dynamic_()) -> {ok, web_app_info()} | {error, list(gleam@dynamic:decode_error())}. decode_web_app_info(Json) -> _pipe = Json, (gleam@dynamic:decode1( fun(Field@0) -> {web_app_info, Field@0} end, gleam@dynamic:field(<<"url"/utf8>>, fun gleam@dynamic:string/1) ))(_pipe). -spec decode_web_app_data(gleam@dynamic:dynamic_()) -> {ok, web_app_data()} | {error, list(gleam@dynamic:decode_error())}. decode_web_app_data(Json) -> _pipe = Json, (gleam@dynamic:decode2( fun(Field@0, Field@1) -> {web_app_data, Field@0, Field@1} end, gleam@dynamic:field(<<"data"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:field(<<"button_text"/utf8>>, fun gleam@dynamic:string/1) ))(_pipe). -spec decode_login_url(gleam@dynamic:dynamic_()) -> {ok, login_url()} | {error, list(gleam@dynamic:decode_error())}. decode_login_url(Json) -> _pipe = Json, (gleam@dynamic:decode4( fun(Field@0, Field@1, Field@2, Field@3) -> {login_url, Field@0, Field@1, Field@2, Field@3} end, gleam@dynamic:field(<<"url"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:optional_field( <<"forward_text"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"bot_username"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"request_write_access"/utf8>>, fun gleam@dynamic:bool/1 ) ))(_pipe). -spec decode_switch_inline_query_chosen_chat(gleam@dynamic:dynamic_()) -> {ok, switch_inline_query_chosen_chat()} | {error, list(gleam@dynamic:decode_error())}. decode_switch_inline_query_chosen_chat(Json) -> _pipe = Json, (gleam@dynamic:decode5( fun(Field@0, Field@1, Field@2, Field@3, Field@4) -> {switch_inline_query_chosen_chat, Field@0, Field@1, Field@2, Field@3, Field@4} end, gleam@dynamic:optional_field( <<"query"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"allow_user_chats"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"allow_bot_chats"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"allow_group_chats"/utf8>>, fun gleam@dynamic:bool/1 ), gleam@dynamic:optional_field( <<"allow_channel_chats"/utf8>>, fun gleam@dynamic:bool/1 ) ))(_pipe). -spec decode_inline_button(gleam@dynamic:dynamic_()) -> {ok, inline_keyboard_button()} | {error, list(gleam@dynamic:decode_error())}. decode_inline_button(Json) -> _pipe = Json, (gleam@dynamic:decode9( fun(Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6, Field@7, Field@8) -> {inline_keyboard_button, Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6, Field@7, Field@8} end, gleam@dynamic:field(<<"text"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:optional_field(<<"url"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:optional_field( <<"callback_data"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"web_app"/utf8>>, fun decode_web_app_info/1 ), gleam@dynamic:optional_field( <<"login_url"/utf8>>, fun decode_login_url/1 ), gleam@dynamic:optional_field( <<"switch_inline_query"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"switch_inline_query_current_chat"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"switch_inline_query_chosen_chat"/utf8>>, fun decode_switch_inline_query_chosen_chat/1 ), gleam@dynamic:optional_field(<<"pay"/utf8>>, fun gleam@dynamic:bool/1) ))(_pipe). -spec decode_inline_markup(gleam@dynamic:dynamic_()) -> {ok, inline_keyboard_markup()} | {error, list(gleam@dynamic:decode_error())}. decode_inline_markup(Json) -> _pipe = Json, (gleam@dynamic:decode1( fun(Field@0) -> {inline_keyboard_markup, Field@0} end, gleam@dynamic:field( <<"inline_keyboard"/utf8>>, gleam@dynamic:list(gleam@dynamic:list(fun decode_inline_button/1)) ) ))(_pipe). -spec decode_inaccessible_message(gleam@dynamic:dynamic_()) -> {ok, inaccessible_message()} | {error, list(gleam@dynamic:decode_error())}. decode_inaccessible_message(Json) -> _pipe = Json, (gleam@dynamic:decode3( fun(Field@0, Field@1, Field@2) -> {inaccessible_message, Field@0, Field@1, Field@2} end, gleam@dynamic:field(<<"chat"/utf8>>, fun decode_chat/1), gleam@dynamic:field(<<"message_id"/utf8>>, fun gleam@dynamic:int/1), gleam@dynamic:field(<<"date"/utf8>>, fun gleam@dynamic:int/1) ))(_pipe). -spec default_edit_message_text_parameters() -> edit_message_text_parameters(). default_edit_message_text_parameters() -> {edit_message_text_parameters, none, none, none, <<""/utf8>>, none, none, none, none}. -spec new_answer_callback_query_parameters(binary()) -> answer_callback_query_parameters(). new_answer_callback_query_parameters(Callback_query_id) -> {answer_callback_query_parameters, Callback_query_id, none, none, none, none}. -spec encode_int_or_string(int_or_string()) -> gleam@json:json(). encode_int_or_string(Value) -> case Value of {inted, Value@1} -> gleam@json:int(Value@1); {stringed, Value@2} -> gleam@json:string(Value@2) end. -spec all_errors({ok, any()} | {error, list(gleam@dynamic:decode_error())}) -> list(gleam@dynamic:decode_error()). all_errors(Result) -> case Result of {ok, _} -> []; {error, Errors} -> Errors end. -spec decode_message(gleam@dynamic:dynamic_()) -> {ok, message()} | {error, list(gleam@dynamic:decode_error())}. decode_message(Json) -> Decode_message_id = gleam@dynamic:field( <<"message_id"/utf8>>, fun gleam@dynamic:int/1 ), Decode_message_thread_id = gleam@dynamic:optional_field( <<"message_thread_id"/utf8>>, fun gleam@dynamic:int/1 ), Decode_from = gleam@dynamic:optional_field( <<"from"/utf8>>, fun decode_user/1 ), Decode_sender_chat = gleam@dynamic:optional_field( <<"sender_chat"/utf8>>, fun decode_chat/1 ), Decode_sender_boost_count = gleam@dynamic:optional_field( <<"sender_boost_count"/utf8>>, fun gleam@dynamic:int/1 ), Decode_date = gleam@dynamic:field(<<"date"/utf8>>, fun gleam@dynamic:int/1), Decode_chat = gleam@dynamic:field(<<"chat"/utf8>>, fun decode_chat/1), Decode_is_topic_message = gleam@dynamic:optional_field( <<"is_topic_message"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_is_automatic_forward = gleam@dynamic:optional_field( <<"is_automatic_forward"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_reply_to_message = gleam@dynamic:optional_field( <<"reply_to_message"/utf8>>, fun decode_message/1 ), Decode_via_bot = gleam@dynamic:optional_field( <<"via_bot"/utf8>>, fun decode_user/1 ), Decode_edit_date = gleam@dynamic:optional_field( <<"edit_date"/utf8>>, fun gleam@dynamic:int/1 ), Decode_has_protected_content = gleam@dynamic:optional_field( <<"has_protected_content"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_media_group_id = gleam@dynamic:optional_field( <<"media_group_id"/utf8>>, fun gleam@dynamic:string/1 ), Decode_author_signature = gleam@dynamic:optional_field( <<"author_signature"/utf8>>, fun gleam@dynamic:string/1 ), Decode_text = gleam@dynamic:optional_field( <<"text"/utf8>>, fun gleam@dynamic:string/1 ), Decode_entities = gleam@dynamic:optional_field( <<"entities"/utf8>>, gleam@dynamic:list(fun decode_message_entity/1) ), Decode_caption = gleam@dynamic:optional_field( <<"caption"/utf8>>, fun gleam@dynamic:string/1 ), Decode_caption_entities = gleam@dynamic:optional_field( <<"caption_entities"/utf8>>, gleam@dynamic:list(fun decode_message_entity/1) ), Decode_has_media_spoiler = gleam@dynamic:optional_field( <<"has_media_spoiler"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_new_chat_members = gleam@dynamic:optional_field( <<"new_chat_members"/utf8>>, gleam@dynamic:list(fun decode_user/1) ), Decode_left_chat_member = gleam@dynamic:optional_field( <<"left_chat_member"/utf8>>, fun decode_user/1 ), Decode_new_chat_title = gleam@dynamic:optional_field( <<"new_chat_title"/utf8>>, fun gleam@dynamic:string/1 ), Decode_delete_chat_photo = gleam@dynamic:optional_field( <<"delete_chat_photo"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_group_chat_created = gleam@dynamic:optional_field( <<"group_chat_created"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_supergroup_chat_created = gleam@dynamic:optional_field( <<"supergroup_chat_created"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_channel_chat_created = gleam@dynamic:optional_field( <<"channel_chat_created"/utf8>>, fun gleam@dynamic:bool/1 ), Decode_migrate_to_chat_id = gleam@dynamic:optional_field( <<"migrate_to_chat_id"/utf8>>, fun gleam@dynamic:int/1 ), Decode_migrate_from_chat_id = gleam@dynamic:optional_field( <<"migrate_from_chat_id"/utf8>>, fun gleam@dynamic:int/1 ), Decode_connected_website = gleam@dynamic:optional_field( <<"connected_website"/utf8>>, fun gleam@dynamic:string/1 ), Decode_inline_keyboard_markup = gleam@dynamic:optional_field( <<"reply_markup"/utf8>>, fun decode_inline_markup/1 ), Decode_web_app_data = gleam@dynamic:optional_field( <<"web_app_data"/utf8>>, fun decode_web_app_data/1 ), Decode_is_from_offline = gleam@dynamic:optional_field( <<"is_from_offline"/utf8>>, fun gleam@dynamic:bool/1 ), case {Decode_message_id(Json), Decode_message_thread_id(Json), Decode_from(Json), Decode_sender_chat(Json), Decode_sender_boost_count(Json), Decode_date(Json), Decode_chat(Json), Decode_is_topic_message(Json), Decode_is_automatic_forward(Json), Decode_reply_to_message(Json), Decode_via_bot(Json), Decode_edit_date(Json), Decode_has_protected_content(Json), Decode_media_group_id(Json), Decode_author_signature(Json), Decode_text(Json), Decode_entities(Json), Decode_caption(Json), Decode_caption_entities(Json), Decode_has_media_spoiler(Json), Decode_new_chat_members(Json), Decode_left_chat_member(Json), Decode_new_chat_title(Json), Decode_delete_chat_photo(Json), Decode_group_chat_created(Json), Decode_supergroup_chat_created(Json), Decode_channel_chat_created(Json), Decode_migrate_to_chat_id(Json), Decode_migrate_from_chat_id(Json), Decode_connected_website(Json), Decode_inline_keyboard_markup(Json), Decode_web_app_data(Json), Decode_is_from_offline(Json)} of {{ok, Message_id}, {ok, Message_thread_id}, {ok, From}, {ok, Sender_chat}, {ok, Sender_boost_count}, {ok, Date}, {ok, Chat}, {ok, Is_topic_message}, {ok, Is_automatic_forward}, {ok, Reply_to_message}, {ok, Via_bot}, {ok, Edit_date}, {ok, Has_protected_content}, {ok, Media_group_id}, {ok, Author_signature}, {ok, Text}, {ok, Entities}, {ok, Caption}, {ok, Caption_entities}, {ok, Has_media_spoiler}, {ok, New_chat_members}, {ok, Left_chat_member}, {ok, New_chat_title}, {ok, Delete_chat_photo}, {ok, Group_chat_created}, {ok, Supergroup_chat_created}, {ok, Channel_chat_created}, {ok, Migrate_to_chat_id}, {ok, Migrate_from_chat_id}, {ok, Connected_website}, {ok, Inline_keyboard_markup}, {ok, Web_app_data}, {ok, Is_from_offline}} -> {ok, {message, Message_id, Message_thread_id, From, Sender_chat, Sender_boost_count, Date, Chat, Is_topic_message, Is_automatic_forward, Reply_to_message, Via_bot, Edit_date, Has_protected_content, Is_from_offline, Media_group_id, Author_signature, Text, Entities, Caption, Caption_entities, Has_media_spoiler, New_chat_members, Left_chat_member, New_chat_title, Delete_chat_photo, Group_chat_created, Supergroup_chat_created, Channel_chat_created, Migrate_to_chat_id, Migrate_from_chat_id, Connected_website, Web_app_data, Inline_keyboard_markup}}; {Message_id@1, Message_thread_id@1, From@1, Sender_chat@1, Sender_boost_count@1, Date@1, Chat@1, Is_topic_message@1, Is_automatic_forward@1, Reply_to_message@1, Via_bot@1, Edit_date@1, Has_protected_content@1, Media_group_id@1, Author_signature@1, Text@1, Entities@1, Caption@1, Caption_entities@1, Has_media_spoiler@1, New_chat_members@1, Left_chat_member@1, New_chat_title@1, Delete_chat_photo@1, Group_chat_created@1, Supergroup_chat_created@1, Channel_chat_created@1, Migrate_to_chat_id@1, Migrate_from_chat_id@1, Connected_website@1, Inline_keyboard_markup@1, Web_app_data@1, Is_from_offline@1} -> {error, gleam@list:concat( [all_errors(Message_id@1), all_errors(Message_thread_id@1), all_errors(From@1), all_errors(Sender_chat@1), all_errors(Sender_boost_count@1), all_errors(Date@1), all_errors(Chat@1), all_errors(Is_topic_message@1), all_errors(Is_automatic_forward@1), all_errors(Reply_to_message@1), all_errors(Via_bot@1), all_errors(Edit_date@1), all_errors(Has_protected_content@1), all_errors(Is_from_offline@1), all_errors(Media_group_id@1), all_errors(Author_signature@1), all_errors(Text@1), all_errors(Entities@1), all_errors(Caption@1), all_errors(Caption_entities@1), all_errors(Has_media_spoiler@1), all_errors(New_chat_members@1), all_errors(Left_chat_member@1), all_errors(New_chat_title@1), all_errors(Delete_chat_photo@1), all_errors(Group_chat_created@1), all_errors(Supergroup_chat_created@1), all_errors(Channel_chat_created@1), all_errors(Migrate_to_chat_id@1), all_errors(Migrate_from_chat_id@1), all_errors(Connected_website@1), all_errors(Inline_keyboard_markup@1), all_errors(Web_app_data@1)] )} end. -spec decode_maybe_inaccessible_message(gleam@dynamic:dynamic_()) -> {ok, maybe_inaccessible_message()} | {error, list(gleam@dynamic:decode_error())}. decode_maybe_inaccessible_message(Json) -> case begin _pipe = Json, (gleam@dynamic:field(<<"date"/utf8>>, fun gleam@dynamic:int/1))(_pipe) end of {ok, Date} -> case Date =:= 0 of true -> case decode_inaccessible_message(Json) of {ok, Inaccessible_message} -> {ok, {maybe_inaccessible_message_inaccessible, Inaccessible_message}}; {error, Errors} -> {error, Errors} end; false -> case decode_message(Json) of {ok, Message} -> {ok, {maybe_inaccessible_message_message, Message}}; {error, Errors@1} -> {error, Errors@1} end end; {error, Errors@2} -> {error, Errors@2} end. -spec decode_callback_query(gleam@dynamic:dynamic_()) -> {ok, callback_query()} | {error, list(gleam@dynamic:decode_error())}. decode_callback_query(Json) -> _pipe = Json, (gleam@dynamic:decode7( fun(Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6) -> {callback_query, Field@0, Field@1, Field@2, Field@3, Field@4, Field@5, Field@6} end, gleam@dynamic:field(<<"id"/utf8>>, fun gleam@dynamic:string/1), gleam@dynamic:field(<<"from"/utf8>>, fun decode_user/1), gleam@dynamic:optional_field( <<"message"/utf8>>, fun decode_maybe_inaccessible_message/1 ), gleam@dynamic:optional_field( <<"inline_message_id"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"chat_instance"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"data"/utf8>>, fun gleam@dynamic:string/1 ), gleam@dynamic:optional_field( <<"game_short_name"/utf8>>, fun gleam@dynamic:string/1 ) ))(_pipe). -spec decode_update(gleam@dynamic:dynamic_()) -> {ok, update()} | {error, list(gleam@dynamic:decode_error())}. decode_update(Json) -> _pipe = Json, (gleam@dynamic:decode4( fun(Field@0, Field@1, Field@2, Field@3) -> {update, Field@0, Field@1, Field@2, Field@3} end, gleam@dynamic:field(<<"update_id"/utf8>>, fun gleam@dynamic:int/1), gleam@dynamic:optional_field(<<"message"/utf8>>, fun decode_message/1), gleam@dynamic:optional_field( <<"edited_message"/utf8>>, fun decode_message/1 ), gleam@dynamic:optional_field( <<"callback_query"/utf8>>, fun decode_callback_query/1 ) ))(_pipe). -spec decode_edit_message_text_result(gleam@dynamic:dynamic_()) -> {ok, edit_message_text_result()} | {error, list(gleam@dynamic:decode_error())}. decode_edit_message_text_result(Json) -> case gleam@dynamic:bool(Json) of {ok, Bool} -> {ok, {edit_message_text_bool, Bool}}; {error, _} -> _pipe = decode_message(Json), gleam@result:map( _pipe, fun(Field@0) -> {edit_message_text_message, Field@0} end ) end. -spec json_object_filter_nulls(list({binary(), gleam@json:json()})) -> gleam@json:json(). json_object_filter_nulls(Entries) -> Null = gleam@json:null(), _pipe = Entries, _pipe@1 = gleam@list:filter( _pipe, fun(Entry) -> {_, Value} = Entry, case Value =:= Null of true -> false; false -> true end end ), gleam@json:object(_pipe@1). -spec bot_command_scope_to_json(bot_command_scope()) -> gleam@json:json(). bot_command_scope_to_json(Scope) -> case Scope of bot_command_default_scope -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"default"/utf8>>)}] ); bot_command_all_private_chats_scope -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"all_private_chats"/utf8>>)}] ); bot_command_scope_all_group_chats -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"all_group_chats"/utf8>>)}] ); bot_command_scope_all_chat_administrators -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"all_chat_administrators"/utf8>>)}] ); {bot_command_scope_chat, Chat_id} -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"chat"/utf8>>)}, {<<"chat_id"/utf8>>, gleam@json:int(Chat_id)}] ); {bot_command_scope_chat_string, Chat_id@1} -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"chat"/utf8>>)}, {<<"chat_id"/utf8>>, encode_int_or_string(Chat_id@1)}] ); {bot_command_scope_chat_administrators, Chat_id@2} -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"chat_administrators"/utf8>>)}, {<<"chat_id"/utf8>>, encode_int_or_string(Chat_id@2)}] ); {bot_command_scope_chat_member, Chat_id@3, User_id} -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:string(<<"chat_member"/utf8>>)}, {<<"chat_id"/utf8>>, encode_int_or_string(Chat_id@3)}, {<<"user_id"/utf8>>, gleam@json:int(User_id)}] ) end. -spec encode_botcommand_parameters(bot_command_parameters()) -> list({binary(), gleam@json:json()}). encode_botcommand_parameters(Params) -> [{<<"scope"/utf8>>, gleam@json:nullable( erlang:element(2, Params), fun bot_command_scope_to_json/1 )}, {<<"language_code"/utf8>>, gleam@json:nullable( erlang:element(3, Params), fun gleam@json:string/1 )}]. -spec encode_user(user()) -> gleam@json:json(). encode_user(User) -> Id = {<<"id"/utf8>>, gleam@json:int(erlang:element(2, User))}, Is_bot = {<<"is_bot"/utf8>>, gleam@json:bool(erlang:element(3, User))}, First_name = {<<"first_name"/utf8>>, gleam@json:string(erlang:element(4, User))}, Last_name = {<<"last_name"/utf8>>, gleam@json:nullable(erlang:element(5, User), fun gleam@json:string/1)}, Username = {<<"username"/utf8>>, gleam@json:nullable(erlang:element(6, User), fun gleam@json:string/1)}, Language_code = {<<"language_code"/utf8>>, gleam@json:nullable(erlang:element(7, User), fun gleam@json:string/1)}, Is_premium = {<<"is_premium"/utf8>>, gleam@json:nullable(erlang:element(8, User), fun gleam@json:bool/1)}, Added_to_attachment_menu = {<<"added_to_attachment_menu"/utf8>>, gleam@json:nullable(erlang:element(9, User), fun gleam@json:bool/1)}, json_object_filter_nulls( [Id, Is_bot, First_name, Last_name, Username, Language_code, Is_premium, Added_to_attachment_menu] ). -spec encode_message_entity(message_entity()) -> gleam@json:json(). encode_message_entity(Message_entity) -> Entity_type = {<<"entity_type"/utf8>>, gleam@json:string(erlang:element(2, Message_entity))}, Offset = {<<"offset"/utf8>>, gleam@json:int(erlang:element(3, Message_entity))}, Length = {<<"length"/utf8>>, gleam@json:int(erlang:element(4, Message_entity))}, Url = {<<"url"/utf8>>, gleam@json:nullable( erlang:element(5, Message_entity), fun gleam@json:string/1 )}, User = {<<"user"/utf8>>, gleam@json:nullable( erlang:element(6, Message_entity), fun encode_user/1 )}, Language = {<<"language"/utf8>>, gleam@json:nullable( erlang:element(7, Message_entity), fun gleam@json:string/1 )}, Custom_emoji_id = {<<"custom_emoji_id"/utf8>>, gleam@json:nullable( erlang:element(8, Message_entity), fun gleam@json:string/1 )}, json_object_filter_nulls( [Entity_type, Offset, Length, Url, User, Language, Custom_emoji_id] ). -spec encode_keyboard_button_request_users(keyboard_button_request_users()) -> gleam@json:json(). encode_keyboard_button_request_users(Keyboard_button_request_users) -> Request_id = {<<"request_id"/utf8>>, gleam@json:int(erlang:element(2, Keyboard_button_request_users))}, User_is_bot = {<<"user_is_bot"/utf8>>, gleam@json:nullable( erlang:element(3, Keyboard_button_request_users), fun gleam@json:bool/1 )}, User_is_premium = {<<"user_is_premium"/utf8>>, gleam@json:nullable( erlang:element(4, Keyboard_button_request_users), fun gleam@json:bool/1 )}, Max_quantity = {<<"max_quantity"/utf8>>, gleam@json:nullable( erlang:element(5, Keyboard_button_request_users), fun gleam@json:int/1 )}, Request_name = {<<"request_name"/utf8>>, gleam@json:nullable( erlang:element(6, Keyboard_button_request_users), fun gleam@json:bool/1 )}, Request_username = {<<"request_username"/utf8>>, gleam@json:nullable( erlang:element(7, Keyboard_button_request_users), fun gleam@json:bool/1 )}, Request_photo = {<<"request_photo"/utf8>>, gleam@json:nullable( erlang:element(8, Keyboard_button_request_users), fun gleam@json:bool/1 )}, json_object_filter_nulls( [Request_id, User_is_bot, User_is_premium, Max_quantity, Request_name, Request_username, Request_photo] ). -spec encode_keyboard_button_poll_type(keyboard_button_poll_type()) -> gleam@json:json(). encode_keyboard_button_poll_type(Keyboard_button_poll_type) -> json_object_filter_nulls( [{<<"type"/utf8>>, gleam@json:nullable( erlang:element(2, Keyboard_button_poll_type), fun gleam@json:string/1 )}] ). -spec encode_reply_parameters(reply_parameters()) -> gleam@json:json(). encode_reply_parameters(Reply_parameters) -> Message_id = {<<"message_id"/utf8>>, gleam@json:int(erlang:element(2, Reply_parameters))}, Chat_id = {<<"chat_id"/utf8>>, gleam@json:nullable( erlang:element(3, Reply_parameters), fun encode_int_or_string/1 )}, Allow_sending_without_reply = {<<"allow_sending_without_reply"/utf8>>, gleam@json:nullable( erlang:element(4, Reply_parameters), fun gleam@json:bool/1 )}, Quote = {<<"quote"/utf8>>, gleam@json:nullable( erlang:element(5, Reply_parameters), fun gleam@json:string/1 )}, Quote_parse_mode = {<<"quote_parse_mode"/utf8>>, gleam@json:nullable( erlang:element(6, Reply_parameters), fun gleam@json:string/1 )}, Quote_entities = {<<"quote_entities"/utf8>>, gleam@json:nullable( erlang:element(7, Reply_parameters), fun(_capture) -> gleam@json:array(_capture, fun encode_message_entity/1) end )}, Quote_position = {<<"quote_position"/utf8>>, gleam@json:nullable( erlang:element(8, Reply_parameters), fun gleam@json:int/1 )}, json_object_filter_nulls( [Message_id, Chat_id, Allow_sending_without_reply, Quote, Quote_parse_mode, Quote_entities, Quote_position] ). -spec encode_send_dice_parameters(send_dice_parameters()) -> gleam@json:json(). encode_send_dice_parameters(Params) -> Chat_id = {<<"chat_id"/utf8>>, encode_int_or_string(erlang:element(2, Params))}, Message_thread_id = {<<"message_thread_id"/utf8>>, gleam@json:nullable(erlang:element(3, Params), fun gleam@json:int/1)}, Emoji = {<<"emoji"/utf8>>, gleam@json:nullable(erlang:element(4, Params), fun gleam@json:string/1)}, Disable_notification = {<<"disable_notification"/utf8>>, gleam@json:nullable(erlang:element(5, Params), fun gleam@json:bool/1)}, Protect_content = {<<"protect_content"/utf8>>, gleam@json:nullable(erlang:element(6, Params), fun gleam@json:bool/1)}, Reply_parameters = {<<"reply_parameters"/utf8>>, gleam@json:nullable( erlang:element(7, Params), fun encode_reply_parameters/1 )}, json_object_filter_nulls( [Chat_id, Message_thread_id, Emoji, Disable_notification, Protect_content, Reply_parameters] ). -spec encode_web_app_info(web_app_info()) -> gleam@json:json(). encode_web_app_info(Info) -> json_object_filter_nulls( [{<<"url"/utf8>>, gleam@json:string(erlang:element(2, Info))}] ). -spec encode_login_url(login_url()) -> gleam@json:json(). encode_login_url(Login_url) -> Url = {<<"url"/utf8>>, gleam@json:string(erlang:element(2, Login_url))}, Forward_text = {<<"forward_text"/utf8>>, gleam@json:nullable( erlang:element(3, Login_url), fun gleam@json:string/1 )}, Bot_username = {<<"bot_username"/utf8>>, gleam@json:nullable( erlang:element(4, Login_url), fun gleam@json:string/1 )}, Request_write_access = {<<"request_write_access"/utf8>>, gleam@json:nullable(erlang:element(5, Login_url), fun gleam@json:bool/1)}, json_object_filter_nulls( [Url, Forward_text, Bot_username, Request_write_access] ). -spec encode_switch_inline_query_chosen_chat(switch_inline_query_chosen_chat()) -> gleam@json:json(). encode_switch_inline_query_chosen_chat(Switch_inline_query_chosen_chat) -> Query = {<<"query"/utf8>>, gleam@json:nullable( erlang:element(2, Switch_inline_query_chosen_chat), fun gleam@json:string/1 )}, Allow_user_chats = {<<"allow_user_chats"/utf8>>, gleam@json:nullable( erlang:element(3, Switch_inline_query_chosen_chat), fun gleam@json:bool/1 )}, Allow_bot_chats = {<<"allow_bot_chats"/utf8>>, gleam@json:nullable( erlang:element(4, Switch_inline_query_chosen_chat), fun gleam@json:bool/1 )}, Allow_group_chats = {<<"allow_group_chats"/utf8>>, gleam@json:nullable( erlang:element(5, Switch_inline_query_chosen_chat), fun gleam@json:bool/1 )}, Allow_channel_chats = {<<"allow_channel_chats"/utf8>>, gleam@json:nullable( erlang:element(6, Switch_inline_query_chosen_chat), fun gleam@json:bool/1 )}, json_object_filter_nulls( [Query, Allow_user_chats, Allow_bot_chats, Allow_group_chats, Allow_channel_chats] ). -spec encode_inline_keyboard_button(inline_keyboard_button()) -> gleam@json:json(). encode_inline_keyboard_button(Inline_keyboard_button) -> Text = {<<"text"/utf8>>, gleam@json:string(erlang:element(2, Inline_keyboard_button))}, Url = {<<"url"/utf8>>, gleam@json:nullable( erlang:element(3, Inline_keyboard_button), fun gleam@json:string/1 )}, Callback_data = {<<"callback_data"/utf8>>, gleam@json:nullable( erlang:element(4, Inline_keyboard_button), fun gleam@json:string/1 )}, Web_app = {<<"web_app"/utf8>>, gleam@json:nullable( erlang:element(5, Inline_keyboard_button), fun encode_web_app_info/1 )}, Login_url = {<<"login_url"/utf8>>, gleam@json:nullable( erlang:element(6, Inline_keyboard_button), fun encode_login_url/1 )}, Switch_inline_query = {<<"switch_inline_query"/utf8>>, gleam@json:nullable( erlang:element(7, Inline_keyboard_button), fun gleam@json:string/1 )}, Switch_inline_query_current_chat = {<<"switch_inline_query_current_chat"/utf8>>, gleam@json:nullable( erlang:element(8, Inline_keyboard_button), fun gleam@json:string/1 )}, Switch_inline_query_chosen_chat = {<<"switch_inline_query_chosen_chat"/utf8>>, gleam@json:nullable( erlang:element(9, Inline_keyboard_button), fun encode_switch_inline_query_chosen_chat/1 )}, Pay = {<<"pay"/utf8>>, gleam@json:nullable( erlang:element(10, Inline_keyboard_button), fun gleam@json:bool/1 )}, json_object_filter_nulls( [Text, Url, Callback_data, Web_app, Login_url, Switch_inline_query, Switch_inline_query_current_chat, Switch_inline_query_chosen_chat, Pay] ). -spec encode_inline_keyboard_markup(inline_keyboard_markup()) -> gleam@json:json(). encode_inline_keyboard_markup(Inline_keyboard_markup) -> Inline_keyboard = {<<"inline_keyboard"/utf8>>, gleam@json:array( erlang:element(2, Inline_keyboard_markup), fun(_capture) -> gleam@json:array(_capture, fun encode_inline_keyboard_button/1) end )}, json_object_filter_nulls([Inline_keyboard]). -spec encode_chat_administrator_rights(chat_administrator_rights()) -> gleam@json:json(). encode_chat_administrator_rights(Chat_administrator_rights) -> Is_anonymous = {<<"is_anonymous"/utf8>>, gleam@json:bool(erlang:element(2, Chat_administrator_rights))}, Can_manage_chat = {<<"can_manage_chat"/utf8>>, gleam@json:bool(erlang:element(3, Chat_administrator_rights))}, Can_delete_messages = {<<"can_delete_messages"/utf8>>, gleam@json:bool(erlang:element(4, Chat_administrator_rights))}, Can_manage_voice_chats = {<<"can_manage_voice_chats"/utf8>>, gleam@json:bool(erlang:element(5, Chat_administrator_rights))}, Can_restrict_members = {<<"can_restrict_members"/utf8>>, gleam@json:bool(erlang:element(6, Chat_administrator_rights))}, Can_promote_members = {<<"can_promote_members"/utf8>>, gleam@json:bool(erlang:element(7, Chat_administrator_rights))}, Can_change_info = {<<"can_change_info"/utf8>>, gleam@json:bool(erlang:element(8, Chat_administrator_rights))}, Can_invite_users = {<<"can_invite_users"/utf8>>, gleam@json:bool(erlang:element(9, Chat_administrator_rights))}, Can_post_stories = {<<"can_post_stories"/utf8>>, gleam@json:bool(erlang:element(10, Chat_administrator_rights))}, Can_edit_stories = {<<"can_edit_stories"/utf8>>, gleam@json:bool(erlang:element(11, Chat_administrator_rights))}, Can_delete_stories = {<<"can_delete_stories"/utf8>>, gleam@json:bool(erlang:element(12, Chat_administrator_rights))}, Can_post_messages = {<<"can_post_messages"/utf8>>, gleam@json:nullable( erlang:element(13, Chat_administrator_rights), fun gleam@json:bool/1 )}, Can_edit_messages = {<<"can_edit_messages"/utf8>>, gleam@json:nullable( erlang:element(14, Chat_administrator_rights), fun gleam@json:bool/1 )}, Can_pin_messages = {<<"can_pin_messages"/utf8>>, gleam@json:nullable( erlang:element(15, Chat_administrator_rights), fun gleam@json:bool/1 )}, Can_manage_topics = {<<"can_manage_topics"/utf8>>, gleam@json:nullable( erlang:element(16, Chat_administrator_rights), fun gleam@json:bool/1 )}, json_object_filter_nulls( [Is_anonymous, Can_manage_chat, Can_delete_messages, Can_manage_voice_chats, Can_restrict_members, Can_promote_members, Can_change_info, Can_invite_users, Can_post_stories, Can_edit_stories, Can_delete_stories, Can_post_messages, Can_edit_messages, Can_pin_messages, Can_manage_topics] ). -spec encode_keyboard_button_request_chat(keyboard_button_request_chat()) -> gleam@json:json(). encode_keyboard_button_request_chat(Keyboard_button_request_chat) -> Request_id = {<<"request_id"/utf8>>, gleam@json:int(erlang:element(2, Keyboard_button_request_chat))}, Chat_is_channel = {<<"chat_is_channel"/utf8>>, gleam@json:bool(erlang:element(3, Keyboard_button_request_chat))}, Chat_is_forum = {<<"chat_is_forum"/utf8>>, gleam@json:nullable( erlang:element(4, Keyboard_button_request_chat), fun gleam@json:bool/1 )}, Chat_has_username = {<<"chat_has_username"/utf8>>, gleam@json:nullable( erlang:element(5, Keyboard_button_request_chat), fun gleam@json:bool/1 )}, Chat_is_created = {<<"chat_is_created"/utf8>>, gleam@json:nullable( erlang:element(6, Keyboard_button_request_chat), fun gleam@json:bool/1 )}, User_administrator_rights = {<<"user_administrator_rights"/utf8>>, gleam@json:nullable( erlang:element(7, Keyboard_button_request_chat), fun encode_chat_administrator_rights/1 )}, Bot_administrator_rights = {<<"bot_administrator_rights"/utf8>>, gleam@json:nullable( erlang:element(8, Keyboard_button_request_chat), fun encode_chat_administrator_rights/1 )}, Bot_is_member = {<<"bot_is_member"/utf8>>, gleam@json:nullable( erlang:element(9, Keyboard_button_request_chat), fun gleam@json:bool/1 )}, Request_title = {<<"request_title"/utf8>>, gleam@json:nullable( erlang:element(10, Keyboard_button_request_chat), fun gleam@json:bool/1 )}, Request_username = {<<"request_username"/utf8>>, gleam@json:nullable( erlang:element(11, Keyboard_button_request_chat), fun gleam@json:bool/1 )}, Request_photo = {<<"request_photo"/utf8>>, gleam@json:nullable( erlang:element(12, Keyboard_button_request_chat), fun gleam@json:bool/1 )}, json_object_filter_nulls( [Request_id, Chat_is_channel, Chat_is_forum, Chat_has_username, Chat_is_created, User_administrator_rights, Bot_administrator_rights, Bot_is_member, Request_title, Request_username, Request_photo] ). -spec encode_keyboard_button(keyboard_button()) -> gleam@json:json(). encode_keyboard_button(Keyboard_button) -> Text = {<<"text"/utf8>>, gleam@json:string(erlang:element(2, Keyboard_button))}, Request_users = {<<"request_users"/utf8>>, gleam@json:nullable( erlang:element(3, Keyboard_button), fun encode_keyboard_button_request_users/1 )}, Request_chat = {<<"request_chat"/utf8>>, gleam@json:nullable( erlang:element(4, Keyboard_button), fun encode_keyboard_button_request_chat/1 )}, Request_contact = {<<"request_contact"/utf8>>, gleam@json:nullable( erlang:element(5, Keyboard_button), fun gleam@json:bool/1 )}, Request_location = {<<"request_location"/utf8>>, gleam@json:nullable( erlang:element(6, Keyboard_button), fun gleam@json:bool/1 )}, Request_poll = {<<"request_poll"/utf8>>, gleam@json:nullable( erlang:element(7, Keyboard_button), fun encode_keyboard_button_poll_type/1 )}, Web_app = {<<"web_app"/utf8>>, gleam@json:nullable( erlang:element(8, Keyboard_button), fun encode_web_app_info/1 )}, json_object_filter_nulls( [Text, Request_users, Request_chat, Request_contact, Request_location, Request_poll, Web_app] ). -spec encode_reply_markup(reply_markup()) -> gleam@json:json(). encode_reply_markup(Reply_markup) -> case Reply_markup of {reply_inline_keyboard_markup, Inline_keyboard} -> json_object_filter_nulls( [{<<"inline_keyboard"/utf8>>, gleam@json:array( Inline_keyboard, fun(_capture) -> gleam@json:array( _capture, fun encode_inline_keyboard_button/1 ) end )}] ); {reply_keyboard_markup, Keyboard, Is_persistent, Resize_keyboard, One_time_keyboard, Input_field_placeholder, Selective} -> json_object_filter_nulls( [{<<"keyboard"/utf8>>, gleam@json:array( Keyboard, fun(_capture@1) -> gleam@json:array( _capture@1, fun encode_keyboard_button/1 ) end )}, {<<"is_persistent"/utf8>>, gleam@json:nullable( Is_persistent, fun gleam@json:bool/1 )}, {<<"resize_keyboard"/utf8>>, gleam@json:nullable( Resize_keyboard, fun gleam@json:bool/1 )}, {<<"one_time_keyboard"/utf8>>, gleam@json:nullable( One_time_keyboard, fun gleam@json:bool/1 )}, {<<"input_field_placeholder"/utf8>>, gleam@json:nullable( Input_field_placeholder, fun gleam@json:string/1 )}, {<<"selective"/utf8>>, gleam@json:nullable(Selective, fun gleam@json:bool/1)}] ); {reply_keyboard_remove, Remove_keyboard, Selective@1} -> json_object_filter_nulls( [{<<"remove_keyboard"/utf8>>, gleam@json:bool(Remove_keyboard)}, {<<"selective"/utf8>>, gleam@json:nullable(Selective@1, fun gleam@json:bool/1)}] ); {force_reply, Force_reply, Input_field_placeholder@1, Selective@2} -> json_object_filter_nulls( [{<<"force_reply"/utf8>>, gleam@json:bool(Force_reply)}, {<<"input_field_placeholder"/utf8>>, gleam@json:string(Input_field_placeholder@1)}, {<<"selective"/utf8>>, gleam@json:bool(Selective@2)}] ) end. -spec encode_link_preview_options(link_preview_options()) -> gleam@json:json(). encode_link_preview_options(Link_preview_options) -> json_object_filter_nulls( [{<<"is_disabled"/utf8>>, gleam@json:nullable( erlang:element(2, Link_preview_options), fun gleam@json:bool/1 )}, {<<"url"/utf8>>, gleam@json:nullable( erlang:element(3, Link_preview_options), fun gleam@json:string/1 )}, {<<"prefer_small_media"/utf8>>, gleam@json:nullable( erlang:element(4, Link_preview_options), fun gleam@json:bool/1 )}, {<<"prefer_large_media"/utf8>>, gleam@json:nullable( erlang:element(5, Link_preview_options), fun gleam@json:bool/1 )}, {<<"show_above_text"/utf8>>, gleam@json:nullable( erlang:element(6, Link_preview_options), fun gleam@json:bool/1 )}] ). -spec encode_send_message_parameters(send_message_parameters()) -> gleam@json:json(). encode_send_message_parameters(Send_message_parameters) -> Business_connection_id = {<<"business_connection_id"/utf8>>, gleam@json:nullable( erlang:element(2, Send_message_parameters), fun gleam@json:string/1 )}, Chat_id = {<<"chat_id"/utf8>>, encode_int_or_string(erlang:element(3, Send_message_parameters))}, Message_thread_id = {<<"message_thread_id"/utf8>>, gleam@json:nullable( erlang:element(4, Send_message_parameters), fun gleam@json:int/1 )}, Text = {<<"text"/utf8>>, gleam@json:string(erlang:element(5, Send_message_parameters))}, Parse_mode = {<<"parse_mode"/utf8>>, gleam@json:nullable( erlang:element(6, Send_message_parameters), fun gleam@json:string/1 )}, Entities = {<<"entities"/utf8>>, gleam@json:nullable( erlang:element(7, Send_message_parameters), fun(_capture) -> gleam@json:array(_capture, fun encode_message_entity/1) end )}, Link_preview_options = {<<"link_preview_options"/utf8>>, gleam@json:nullable( erlang:element(8, Send_message_parameters), fun encode_link_preview_options/1 )}, Disable_notification = {<<"disable_notification"/utf8>>, gleam@json:nullable( erlang:element(9, Send_message_parameters), fun gleam@json:bool/1 )}, Protect_content = {<<"protect_content"/utf8>>, gleam@json:nullable( erlang:element(10, Send_message_parameters), fun gleam@json:bool/1 )}, Reply_parameters = {<<"reply_parameters"/utf8>>, gleam@json:nullable( erlang:element(11, Send_message_parameters), fun encode_reply_parameters/1 )}, Reply_markup = {<<"reply_markup"/utf8>>, gleam@json:nullable( erlang:element(12, Send_message_parameters), fun encode_reply_markup/1 )}, json_object_filter_nulls( [Business_connection_id, Chat_id, Message_thread_id, Text, Parse_mode, Entities, Link_preview_options, Disable_notification, Protect_content, Reply_parameters, Reply_markup] ). -spec encode_edit_message_text_parameters(edit_message_text_parameters()) -> gleam@json:json(). encode_edit_message_text_parameters(Params) -> Chat_id = {<<"chat_id"/utf8>>, gleam@json:nullable( erlang:element(2, Params), fun encode_int_or_string/1 )}, Message_id = {<<"message_id"/utf8>>, gleam@json:nullable(erlang:element(3, Params), fun gleam@json:int/1)}, Inline_message_id = {<<"inline_message_id"/utf8>>, gleam@json:nullable(erlang:element(4, Params), fun gleam@json:string/1)}, Text = {<<"text"/utf8>>, gleam@json:string(erlang:element(5, Params))}, Parse_mode = {<<"parse_mode"/utf8>>, gleam@json:nullable(erlang:element(6, Params), fun gleam@json:string/1)}, Entities = {<<"entities"/utf8>>, gleam@json:nullable( erlang:element(7, Params), fun(_capture) -> gleam@json:array(_capture, fun encode_message_entity/1) end )}, Link_preview_options = {<<"link_preview_options"/utf8>>, gleam@json:nullable( erlang:element(8, Params), fun encode_link_preview_options/1 )}, Reply_markup = {<<"reply_markup"/utf8>>, gleam@json:nullable( erlang:element(9, Params), fun encode_inline_keyboard_markup/1 )}, json_object_filter_nulls( [Chat_id, Message_id, Inline_message_id, Text, Parse_mode, Entities, Link_preview_options, Reply_markup] ). -spec encode_forward_message_parameters(forward_message_parameters()) -> gleam@json:json(). encode_forward_message_parameters(Params) -> json_object_filter_nulls( [{<<"chat_id"/utf8>>, encode_int_or_string(erlang:element(2, Params))}, {<<"from_chat_id"/utf8>>, encode_int_or_string(erlang:element(3, Params))}, {<<"message_id"/utf8>>, gleam@json:int(erlang:element(4, Params))}, {<<"disable_notification"/utf8>>, gleam@json:nullable( erlang:element(5, Params), fun gleam@json:bool/1 )}, {<<"message_thread_id"/utf8>>, gleam@json:nullable( erlang:element(6, Params), fun gleam@json:int/1 )}, {<<"protect_content"/utf8>>, gleam@json:nullable( erlang:element(7, Params), fun gleam@json:bool/1 )}] ). -spec encode_answer_callback_query_parameters( answer_callback_query_parameters() ) -> gleam@json:json(). encode_answer_callback_query_parameters(Params) -> Callback_query_id = {<<"callback_query_id"/utf8>>, gleam@json:string(erlang:element(2, Params))}, Text = {<<"text"/utf8>>, gleam@json:nullable(erlang:element(3, Params), fun gleam@json:string/1)}, Show_alert = {<<"show_alert"/utf8>>, gleam@json:nullable(erlang:element(4, Params), fun gleam@json:bool/1)}, Url = {<<"url"/utf8>>, gleam@json:nullable(erlang:element(5, Params), fun gleam@json:string/1)}, Cache_time = {<<"cache_time"/utf8>>, gleam@json:nullable(erlang:element(6, Params), fun gleam@json:int/1)}, json_object_filter_nulls( [Callback_query_id, Text, Show_alert, Url, Cache_time] ). -spec encode_set_webhook_parameters(set_webhook_parameters()) -> gleam@json:json(). encode_set_webhook_parameters(Params) -> json_object_filter_nulls( [{<<"url"/utf8>>, gleam@json:string(erlang:element(2, Params))}, {<<"max_connections"/utf8>>, gleam@json:nullable( erlang:element(3, Params), fun gleam@json:int/1 )}, {<<"ip_address"/utf8>>, gleam@json:nullable( erlang:element(4, Params), fun gleam@json:string/1 )}, {<<"allowed_updates"/utf8>>, gleam@json:nullable( erlang:element(5, Params), fun(_capture) -> gleam@json:array(_capture, fun gleam@json:string/1) end )}, {<<"drop_pending_updates"/utf8>>, gleam@json:nullable( erlang:element(6, Params), fun gleam@json:bool/1 )}, {<<"secret_token"/utf8>>, gleam@json:nullable( erlang:element(7, Params), fun gleam@json:string/1 )}] ).