mod config;
mod handler;
pub use config::{WebhookHandlerConfig, WebhookHandlerConfigBuilder};
pub use handler::WebhookHandler;
use crate::client::CryptoBot;
impl CryptoBot {
pub fn webhook_handler(&self) -> WebhookHandlerConfigBuilder<'_> {
WebhookHandlerConfigBuilder::new_with_client(&self.api_token)
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::time::Duration;
#[test]
fn test_webhook_handler_creation() {
let client = CryptoBot::test_client();
let handler = client.webhook_handler().build();
assert_eq!(handler.api_token, client.api_token);
assert_eq!(handler.config.expiration_time, Some(Duration::from_secs(600)));
let handler = client
.webhook_handler()
.expiration_time(Duration::from_secs(300))
.build();
assert_eq!(handler.api_token, client.api_token);
assert_eq!(handler.config.expiration_time, Some(Duration::from_secs(300)));
}
}