-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,37 @@ | ||
use crate::error::Result; | ||
use crate::types::{CreateWebhookRequest, EditWebhookRequest, Webhook}; | ||
use crate::Helius; | ||
|
||
use reqwest::{Method, Url}; | ||
|
||
impl Helius { | ||
/// Creates a webhook given account addresses, | ||
pub async fn create_webhook(&self, request: CreateWebhookRequest) -> Result<Webhook> { | ||
let url: String = format!( | ||
"{}v0/webhooks/?api-key={}", | ||
self.config.endpoints.api, self.config.api_key | ||
); | ||
|
||
let parsed_url: Url = Url::parse(&url).expect("Failed to parse URL"); | ||
println!("PARSED URL: {}", parsed_url); | ||
|
||
self.rpc_client | ||
.handler | ||
.send(Method::POST, parsed_url, Some(&request)) | ||
.await | ||
} | ||
|
||
/// Edits a Helius webhook programmatically | ||
pub async fn edit_webhook(&self, request: EditWebhookRequest) -> Result<Webhook> { | ||
let url: String = format!( | ||
"{}v0/webhooks/{}/?api-key={}", | ||
self.config.endpoints.api, request.webhook_id, self.config.api_key | ||
); | ||
let parsed_url: Url = Url::parse(&url).expect("Failed to parse URL"); | ||
|
||
self.rpc_client | ||
.handler | ||
.send(Method::PUT, parsed_url, Some(&request)) | ||
.await | ||
} | ||
} |