From 594bdf0740fe5a5f857dbaa0192e366fddcb5b56 Mon Sep 17 00:00:00 2001 From: Evan <0xIchigo@protonmail.com> Date: Mon, 6 May 2024 13:35:09 -0400 Subject: [PATCH] Update Webhook Documentation --- README.md | 5 +++++ src/webhook.rs | 30 +++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 779f9cd..be26640 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,11 @@ Enhanced Transactions API - [`parsed_transaction_history`](https://docs.helius.dev/solana-apis/enhanced-transactions-api/parsed-transaction-history) - Retrieves a parsed transaction history for a specific address ### Webhooks +- [`create_webhook`]() +- [`edit_webhook`]() +- [`append_addresses_to_webhook`]() +- [`get_webhook_by_id`]() +- [`get_all_webhooks`]() ### Helper Methods - [`get_priority_fee_estimate`](https://docs.helius.dev/solana-rpc-nodes/alpha-priority-fee-api) - Gets an estimate of the priority fees required for a transaction to be processed more quickly diff --git a/src/webhook.rs b/src/webhook.rs index cf06924..517177b 100644 --- a/src/webhook.rs +++ b/src/webhook.rs @@ -5,7 +5,13 @@ use crate::Helius; use reqwest::{Method, Url}; impl Helius { - /// Creates a webhook given account addresses, + /// Creates a webhook given account addresses + /// + /// # Arguments + /// * `request` - A `CreateWebhookRequest` containing the relevant webhook parameters for creation such as the webhook url and type + /// + /// # Returns + /// A `Result` wrapping a `Webhook` if the webhook is successfully created, or a `HeliusError` if creation fails pub async fn create_webhook(&self, request: CreateWebhookRequest) -> Result { let url: String = format!( "{}v0/webhooks/?api-key={}", @@ -22,6 +28,12 @@ impl Helius { } /// Edits a Helius webhook programmatically + /// + /// # Arguments + /// * `request` - An `EditWebhookRequest` containing the parameters to be updated for a given webhook + /// + /// # Returns + /// A `Result` wrapping the updated `Webhook`, or a `HeliusError` if the edit request fails pub async fn edit_webhook(&self, request: EditWebhookRequest) -> Result { let url: String = format!( "{}v0/webhooks/{}/?api-key={}", @@ -36,6 +48,13 @@ impl Helius { } /// Appends a set of addresses to a given webhook + /// + /// # Arguments + /// * `webhook_id` - The ID of the webhook to be updated + /// * `new_addresses` - A slice of strings representing the new account addresses to be added to the given webhook + /// + /// # Returns + /// A `Result` containing the updated `Webhook` object pub async fn append_addresses_to_webhook(&self, webhook_id: &str, new_addresses: &[String]) -> Result { let mut webhook: Webhook = self.get_webhook_by_id(webhook_id).await?; webhook.account_addresses.extend(new_addresses.to_vec()); @@ -54,6 +73,12 @@ impl Helius { } /// Gets a webhook config given a webhook ID + /// + /// # Arguments + /// * `webhook_id` - The ID of the webhook to be updated + /// + /// # Returns + /// A `Result` wrapping the `Webhook` queried, if it exists pub async fn get_webhook_by_id(&self, webhook_id: &str) -> Result { let url: String = format!( "{}v0/webhooks/{}/?api-key={}", @@ -67,6 +92,9 @@ impl Helius { /// Retrieves all Helius webhooks programmatically /// /// Due to response size limitations, we will truncate addresses returned to 100 per config + /// + /// # Returns + /// A `Result` containing a vector of `Webhook` representing all configured webhooks for a given account pub async fn get_all_webhooks(&self) -> Result> { let url: String = format!( "{}v0/webhooks/?api-key={}",