Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account order #48

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions .github/workflows/publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "instant-acme"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
rust-version = "1.64"
license = "Apache-2.0"
Expand Down
25 changes: 24 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ impl Order {
Ok(&self.state)
}

/// Extract the URL and last known state from the `Order`
pub fn into_parts(self) -> (String, OrderState) {
(self.url, self.state)
}

/// Get the last known state of the order
///
/// Call `refresh()` to get the latest state from the server.
Expand Down Expand Up @@ -347,7 +352,7 @@ impl Account {
/// Create a new order based on the given [`NewOrder`]
///
/// Returns an [`Order`] instance. Use the [`Order::state()`] method to inspect its state.
pub async fn new_order<'a>(&'a self, order: &NewOrder<'_>) -> Result<Order, Error> {
pub async fn new_order(&self, order: &NewOrder<'_>) -> Result<Order, Error> {
let rsp = self
.inner
.post(Some(order), None, &self.inner.client.urls.new_order)
Expand All @@ -371,6 +376,24 @@ impl Account {
})
}

/// Fetch the order state for an existing order based on the given `url`
///
/// This might fail if the given URL's order belongs to a different account.
///
/// Returns an [`Order`] instance. Use the [`Order::state`] method to inspect its state.
pub async fn order(&self, url: String) -> Result<Order, Error> {
let rsp = self.inner.post(None::<&Empty>, None, &url).await?;
Ok(Order {
account: self.inner.clone(),
nonce: nonce_from_response(&rsp),
// Order of fields matters! We return errors from Problem::check
// before emitting an error if there is no order url. Or the
// simple no url error hides the causing error in `Problem::check`.
state: Problem::check::<OrderState>(rsp).await?,
url,
})
}

/// Revokes a previously issued certificate
pub async fn revoke<'a>(&'a self, payload: &RevocationRequest<'a>) -> Result<(), Error> {
let revoke_url = match self.inner.client.urls.revoke_cert.as_deref() {
Expand Down