crypto_pay_api/webhook/
mod.rs1mod config;
2mod handler;
3
4pub use config::{WebhookHandlerConfig, WebhookHandlerConfigBuilder};
5pub use handler::WebhookHandler;
6
7use crate::client::CryptoBot;
8
9impl CryptoBot {
10 pub fn webhook_handler(&self) -> WebhookHandlerConfigBuilder<'_> {
28 WebhookHandlerConfigBuilder::new_with_client(&self.api_token)
29 }
30}
31
32#[cfg(test)]
33mod tests {
34 use super::*;
35 use std::time::Duration;
36
37 #[test]
38 fn test_webhook_handler_creation() {
39 let client = CryptoBot::test_client();
40
41 let handler = client.webhook_handler().build();
43
44 assert_eq!(handler.api_token, client.api_token);
45 assert_eq!(handler.config.expiration_time, Some(Duration::from_secs(600)));
46
47 let handler = client
49 .webhook_handler()
50 .expiration_time(Duration::from_secs(300))
51 .build();
52
53 assert_eq!(handler.api_token, client.api_token);
54 assert_eq!(handler.config.expiration_time, Some(Duration::from_secs(300)));
55 }
56}