use std::time::Duration;
use crate::error::Result;
use crate::webhooks::{HeaderLookup, WebhookVerifier};
use super::WebhooksResource;
impl WebhooksResource {
fn verifier(&self) -> WebhookVerifier {
WebhookVerifier::new(self.client.inner.options.webhook_secret.clone())
}
pub fn verify_signature<H>(
&self,
payload: &str,
headers: &H,
secret: Option<&str>,
tolerance: Duration,
) -> Result<()>
where
H: HeaderLookup,
{
self.verifier()
.verify_signature(payload, headers, secret, tolerance)
}
pub fn unwrap<H, T>(
&self,
payload: &str,
headers: &H,
secret: Option<&str>,
tolerance: Duration,
) -> Result<T>
where
H: HeaderLookup,
T: serde::de::DeserializeOwned,
{
self.verifier().unwrap(payload, headers, secret, tolerance)
}
}