-module(acumen@fetch_order). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/acumen/fetch_order.gleam"). -export([build/3, response/2]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Fetch an existing ACME order.\n" "\n" " Use this to check the status of an order after creating it or to poll\n" " for status changes during certificate issuance.\n" "\n" " ## Example\n" "\n" " ```gleam\n" " import acumen\n" " import acumen/fetch_order\n" " import acumen/order.{type Order}\n" "\n" " let assert Ok(#(resp, ctx)) = acumen.execute(\n" " ctx,\n" " build: fetch_order.build(existing_order.url, _, registered_key),\n" " send: httpc.send,\n" " )\n" "\n" " let assert Ok(updated_order) = fetch_order.response(resp, existing_order.url)\n" " ```\n" ). -file("src/acumen/fetch_order.gleam", 32). ?DOC( " Builds a signed POST-as-GET request to fetch an existing order.\n" "\n" " Used to poll order status during the authorization and finalization flow.\n" ). -spec build(acumen@url:url(), acumen:context(), acumen:registered_key()) -> {ok, gleam@http@request:request(binary())} | {error, acumen:acme_error()}. build(Url, Context, Key) -> acumen:build_fetch(Url, Context, Key). -file("src/acumen/fetch_order.gleam", 43). ?DOC( " Parses the order fetch response.\n" "\n" " Pass the order URL since the response doesn't include a Location header.\n" ). -spec response(gleam@http@response:response(binary()), acumen@url:url()) -> {ok, acumen@order:order()} | {error, acumen:acme_error()}. response(Resp, Url) -> case erlang:element(2, Resp) of 200 -> acumen@order:parse_order_response(Resp, Url); _ -> {error, {invalid_response, acumen@internal@utils:unexpected_status_message( erlang:element(2, Resp) )}} end.