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, config: WebhookHandlerConfig) -> WebhookHandler {
30 WebhookHandler::with_config(&self.api_token, config)
31 }
32}
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37 use std::time::Duration;
38
39 #[test]
40 fn test_webhook_handler_creation() {
41 let client = CryptoBot::test_client();
42
43 let config = WebhookHandlerConfigBuilder::new().build();
45 let handler = client.webhook_handler(config);
46
47 assert_eq!(handler.api_token, client.api_token);
48 assert_eq!(handler.config.expiration_time, Some(Duration::from_secs(600)));
49
50 let custom_config = WebhookHandlerConfigBuilder::new()
52 .expiration_time(Duration::from_secs(300))
53 .build();
54
55 let handler = client.webhook_handler(custom_config);
56
57 assert_eq!(handler.api_token, client.api_token);
58 assert_eq!(handler.config.expiration_time, Some(Duration::from_secs(300)));
59 }
60}