Skip to main content

brevo_v3/
lib.rs

1//! # `brevo-v3`
2//!
3//! An asynchronous, type-safe, and idiomatic Rust client library for the **[Brevo (Sendinblue) v3 REST API](https://developers.brevo.com/docs/api-clients)**.
4//!
5//! ## Overview
6//!
7//! - **Full API Coverage**: All 291 endpoints covering Transactional Emails, SMS, WhatsApp, Contacts, Campaigns, Deals, Companies, Tasks, Webhooks, Inbound Parsing, Ecommerce, and Account Management.
8//! - **Domain Invariants**: Strong unforgeable newtypes (`Email`, `PhoneNumber`, `ContactId`, `CampaignId`, `TemplateId`, `DealId`, `CompanyId`, etc.) following the *"Parse, Don't Validate"* philosophy.
9//! - **Async Runtime**: Built on `tokio` (1.x) and `reqwest` (0.12+ with hyper & rustls).
10//! - **Error Handling**: Structured API errors with `thiserror` and automatic 429 rate limit backoff parsing.
11//! - **Date/Time**: Powered by the `time` crate (0.3) for RFC3339 / ISO8601 formatting.
12//!
13//! ## Quick Start
14//!
15//! ```no_run
16//! use brevo_v3::client::BrevoClient;
17//! use brevo_v3::models::{SendTransacEmailRequest, SendTransacEmailRequestSender, SendTransacEmailRequestToItem};
18//! use brevo_v3::types::Email;
19//!
20//! #[tokio::main]
21//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
22//!     let client = BrevoClient::new("xkeysib-your-api-key")?;
23//!
24//!     let recipient = Email::new("alice@example.com")?;
25//!     let sender = Email::new("notifications@mycompany.com")?;
26//!
27//!     let request = SendTransacEmailRequest {
28//!         subject: Some("Order Confirmation".to_string()),
29//!         html_content: Some("<h1>Order Received!</h1>".to_string()),
30//!         sender: Some(SendTransacEmailRequestSender {
31//!             email: Some(sender),
32//!             name: Some("Store Notifications".to_string()),
33//!             id: None,
34//!         }),
35//!         to: Some(vec![SendTransacEmailRequestToItem {
36//!             email: recipient,
37//!             name: Some("Alice".to_string()),
38//!         }]),
39//!         ..Default::default()
40//!     };
41//!
42//!     let response = client.transactional_emails().send_transac_email(&request).await?;
43//!     println!("Sent message ID: {:?}", response.message_id);
44//!
45//!     Ok(())
46//! }
47//! ```
48
49pub mod api;
50pub mod client;
51pub mod error;
52pub mod models;
53pub mod types;
54
55mod client_accessors;
56
57// Re-exports
58pub use client::{BrevoClient, BrevoClientBuilder, BrevoConfig, DEFAULT_BASE_URL};
59pub use error::{Error, Result};
60pub use types::*;