openai_core/resources/
webhooks.rs1use std::time::Duration;
4
5use crate::error::Result;
6use crate::webhooks::{HeaderLookup, WebhookVerifier};
7
8use super::WebhooksResource;
9
10impl WebhooksResource {
11 fn verifier(&self) -> WebhookVerifier {
12 WebhookVerifier::new(self.client.inner.options.webhook_secret.clone())
13 }
14
15 pub fn verify_signature<H>(
21 &self,
22 payload: &str,
23 headers: &H,
24 secret: Option<&str>,
25 tolerance: Duration,
26 ) -> Result<()>
27 where
28 H: HeaderLookup,
29 {
30 self.verifier()
31 .verify_signature(payload, headers, secret, tolerance)
32 }
33
34 pub fn unwrap<H, T>(
40 &self,
41 payload: &str,
42 headers: &H,
43 secret: Option<&str>,
44 tolerance: Duration,
45 ) -> Result<T>
46 where
47 H: HeaderLookup,
48 T: serde::de::DeserializeOwned,
49 {
50 self.verifier().unwrap(payload, headers, secret, tolerance)
51 }
52}