acumen/list_orders
List orders associated with an ACME account.
The ACME server provides a paginated list of order URLs for each account.
Use the next field in the response to fetch subsequent pages.
Example
import acumen
import acumen/list_orders.{type OrdersList}
import gleam/option
let assert option.Some(orders_url) = account.orders_url
let assert Ok(#(resp, ctx)) = acumen.execute(
ctx,
build: list_orders.build(orders_url, _, registered_key),
send: httpc.send,
)
let assert Ok(orders_list) = list_orders.response(resp)
Types
A paginated list of order URLs from the ACME server.
pub type OrdersList {
OrdersList(orders: List(url.Url), next: option.Option(url.Url))
}
Constructors
-
OrdersList(orders: List(url.Url), next: option.Option(url.Url))Arguments
- orders
-
The order URLs on this page.
- next
-
URL to fetch the next page, if one exists.
Values
pub fn build(
url: url.Url,
context: acumen.Context,
key: acumen.RegisteredKey,
) -> Result(request.Request(String), acumen.AcmeError)
Builds a signed POST-as-GET request to list orders for an account.
Targets the account’s orders URL from the registration response.
pub fn response(
resp: response.Response(String),
) -> Result(OrdersList, acumen.AcmeError)
Parses the orders list response.
Pagination is indicated by a Link header with rel="next".
Example
let assert Ok(orders_list) = list_orders.response(resp)
// Follow pagination if there are more pages
case orders_list.next {
option.Some(next_url) -> {
let assert Ok(#(resp, ctx)) = acumen.execute(
ctx,
build: list_orders.build(next_url, _, registered_key),
send: httpc.send,
)
let assert Ok(next_page) = list_orders.response(resp)
}
option.None -> {
// No more pages
}
}