pub struct Webhook { /* private fields */ }Expand description
Webhook for validating and accessing Sockudo webhook data
Implementations§
Source§impl Webhook
impl Webhook
Sourcepub fn new(
token: &Token,
headers: &BTreeMap<String, String>,
body: &str,
) -> Self
pub fn new( token: &Token, headers: &BTreeMap<String, String>, body: &str, ) -> Self
Creates a new webhook from request data
Sourcepub fn is_valid(&self, extra_tokens: Option<&[Token]>) -> bool
pub fn is_valid(&self, extra_tokens: Option<&[Token]>) -> bool
Validates the webhook signature and content
Sourcepub fn is_content_type_valid(&self) -> bool
pub fn is_content_type_valid(&self) -> bool
Checks if the content type is valid (application/json)
Sourcepub fn is_body_valid(&self) -> bool
pub fn is_body_valid(&self) -> bool
Checks if the body is valid JSON
Sourcepub fn get_data(&self) -> Result<&WebhookData>
pub fn get_data(&self) -> Result<&WebhookData>
Gets the parsed webhook data
Sourcepub fn get_raw_events(&self) -> Result<&Vec<HashMap<String, String>>>
pub fn get_raw_events(&self) -> Result<&Vec<HashMap<String, String>>>
Gets the raw events from webhook data
Sourcepub fn get_raw_json_events(&self) -> Result<&Vec<HashMap<String, Value>>>
pub fn get_raw_json_events(&self) -> Result<&Vec<HashMap<String, Value>>>
Gets the original JSON event objects without stringifying nested values.
Sourcepub fn get_events(&self) -> Result<Vec<WebhookEvent>>
pub fn get_events(&self) -> Result<Vec<WebhookEvent>>
Gets the events as strongly typed enums
Sourcepub fn get_time(&self) -> Result<SystemTime>
pub fn get_time(&self) -> Result<SystemTime>
Gets the timestamp from webhook data
Sourcepub fn find_events_by_type(&self, event_type: &str) -> Result<Vec<WebhookEvent>>
pub fn find_events_by_type(&self, event_type: &str) -> Result<Vec<WebhookEvent>>
Finds events by type
Sourcepub fn find_events_by_channel(&self, channel: &str) -> Result<Vec<WebhookEvent>>
pub fn find_events_by_channel(&self, channel: &str) -> Result<Vec<WebhookEvent>>
Finds events by channel
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Webhook
impl !UnwindSafe for Webhook
impl Freeze for Webhook
impl Send for Webhook
impl Sync for Webhook
impl Unpin for Webhook
impl UnsafeUnpin for Webhook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more