-module(discord_gleam@ws@packets@hello). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/discord_gleam/ws/packets/hello.gleam"). -export([from_json_string/1]). -export_type([hello_packet_data/0, hello_packet/0]). -type hello_packet_data() :: {hello_packet_data, integer()}. -type hello_packet() :: {hello_packet, integer(), hello_packet_data()}. -file("src/discord_gleam/ws/packets/hello.gleam", 13). -spec from_json_string(binary()) -> {ok, hello_packet()} | {error, gleam@json:decode_error()}. from_json_string(Encoded) -> Decoder = begin gleam@dynamic@decode:field( <<"op"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Op) -> gleam@dynamic@decode:field( <<"d"/utf8>>, begin gleam@dynamic@decode:field( <<"heartbeat_interval"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Heartbeat_interval) -> gleam@dynamic@decode:success( {hello_packet_data, Heartbeat_interval} ) end ) end, fun(D) -> gleam@dynamic@decode:success({hello_packet, Op, D}) end ) end ) end, gleam@json:parse(Encoded, Decoder).