-module(priv@aoc_client). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). -export([get_input/3]). -spec get_input(binary(), binary(), binary()) -> {ok, binary()} | {error, gleam@hackney:error()}. get_input(Year, Day, Session) -> _assert_subject = gleam@http@request:to( <<<<<<<<"https://adventofcode.com/"/utf8, Year/binary>>/binary, "/day/"/utf8>>/binary, Day/binary>>/binary, "/input"/utf8>> ), {ok, Request} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"priv/aoc_client"/utf8>>, function => <<"get_input"/utf8>>, line => 12}) end, gleam@result:'try'( begin _pipe = Request, _pipe@1 = gleam@http@request:prepend_header( _pipe, <<"Accept"/utf8>>, <<"application/json"/utf8>> ), _pipe@2 = gleam@http@request:prepend_header( _pipe@1, <<"Cookie"/utf8>>, <<<<"session="/utf8, Session/binary>>/binary, ";"/utf8>> ), gleam@hackney:send(_pipe@2) end, fun(Response) -> case erlang:element(2, Response) of Status when (Status >= 200) andalso (Status < 300) -> {ok, erlang:element(4, Response)}; Status@1 -> {error, {other, gleam@dynamic:from( <<<<(gleam@int:to_string(Status@1))/binary, " - "/utf8>>/binary, (erlang:element(4, Response))/binary>> )}} end end ).