omnihook 0.1.2

Webhook client with payload builders for Slack, Discord, Telegram and generic webhooks with optional HMAC signing and idempotency key support.
Documentation
use serde_json::json;

use super::WebhookPayloadBuilder;

/// A payload builder for generic webhooks. Produces a simple `{title, body}`
/// JSON object.
///
/// ### JSON Output
/// ```json
/// {
///   "title": "Title",
///   "body": "Body message"
/// }
/// ```
#[derive(Default)]
pub struct GenericWebhookPayloadBuilder;

impl WebhookPayloadBuilder for GenericWebhookPayloadBuilder {
    fn build_payload(&self, title: &str, body: &str) -> serde_json::Value {
        json!({
            "title": title,
            "body": body
        })
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_generic_webhook_payload_builder() {
        let payload = GenericWebhookPayloadBuilder.build_payload("Test Title", "Test Message");
        assert_eq!(
            payload,
            json!({ "title": "Test Title", "body": "Test Message" })
        );
    }
}