Skip to content

Implement Event Handler for Webhooks #1

@NewtTheWolf

Description

@NewtTheWolf

Description:

Implement an event handler to manage incoming webhooks from Sendblue. This feature should allow users to register callback functions for handling different types of webhook events, such as message status updates and received messages.

Acceptance Criteria:

  • Implement a generic listen function to register callback functions.
  • Use the hyper crate to create a server that listens for incoming webhooks.
  • Allow users to define a port on which the server should listen.
  • Document the usage of the event handler, including examples.

Example Usage:

use sendblue::SendblueClient;
use sendblue::models::{MessageStatusCallback, MessageResponse};
use sendblue::events::WebhookPayload;

#[tokio::main]
async fn main() {
    let mut client = SendblueClient::new("your_api_key".into(), "your_api_secret".into());

    client.listen(|payload| {
        match payload {
            WebhookPayload::Status(status) => {
                println!("Status update received: {:?}", status);
            }
            WebhookPayload::Message(message) => {
                println!("Message received: {:?}", message);
            }
        }
    }).await;

    client.start_webhook_server(8080).await;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions