Skip to content

Commit

Permalink
Adding hooks endpoint (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougEfresh committed May 5, 2024
1 parent fa5dbf8 commit dd3f8b7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/api/hooks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use crate::api::Success;
use crate::types::hooks::HookResponse;
use crate::Client;
use crate::Result;
use serde_derive::{Deserialize, Serialize};

impl Client {
/// Resends all failed webhook notifications.
///
/// See
/// * [resendWebhooks](https://docs.fireblocks.com/api/swagger-ui/#/Webhooks/resendWebhooks)
#[tracing::instrument(level = "debug", skip(self))]
pub async fn hooks_resend(&self) -> Result<HookResponse> {
let u = self.build_url("webhooks/resend")?.0;
self.post::<HookResponse, ()>(u, None).await
}

/// Resend a specific transaction by txId
///
/// See
/// * [resendTransactionWebhooks](https://docs.fireblocks.com/api/swagger-ui/#/Webhooks/resendTransactionWebhooks)
#[tracing::instrument(level = "debug", skip(self))]
pub async fn hooks_resend_tx(&self, tx_id: &str, created: bool, updated: bool) -> Result<Success> {
#[derive(Debug, Deserialize, Serialize, Default)]
#[serde(rename_all = "camelCase")]
struct HookTransaction {
resend_created: bool,
resend_status_updated: bool,
}
let request = HookTransaction { resend_created: created, resend_status_updated: updated };
let u = self.build_url(format!("webhooks/resend/{tx_id}"))?.0;
self.post::<Success, HookTransaction>(u, Some(request).as_ref()).await
}
}
7 changes: 7 additions & 0 deletions src/types/hooks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use serde_derive::Deserialize;

#[derive(Debug, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct HookResponse {
pub message_count: u32,
}

0 comments on commit dd3f8b7

Please sign in to comment.