infobip-sms-sdk 0.1.0

Async Rust SDK for the Infobip SMS API: send messages, manage scheduled bulks, query delivery reports and logs, fetch inbound SMS, and parse webhook payloads.
Documentation
//! Async Rust SDK for the [Infobip SMS API].
//!
//! This crate wraps the latest revision of every Infobip SMS endpoint into
//! strongly-typed Rust structs and async methods on a single [`Client`].
//! Requests and responses are JSON; XML responses are not supported.
//!
//! [Infobip SMS API]: https://www.infobip.com/docs/api/channels/sms
//!
//! # Quick start
//!
//! ```no_run
//! use infobip_sms::{Auth, Client};
//! use infobip_sms::models::send::{
//!     SmsMessage, SmsMessageContent, SmsRequest, SmsTextMessageContent, SmsToDestination,
//! };
//!
//! # async fn run() -> Result<(), infobip_sms::Error> {
//! // Your account base URL is shown in the Infobip portal — usually
//! // something like `https://xxxxx.api.infobip.com`.
//! let client = Client::builder()
//!     .base_url("https://xxxxx.api.infobip.com")
//!     .auth(Auth::api_key("YOUR_API_KEY"))
//!     .build()?;
//!
//! let request = SmsRequest {
//!     messages: vec![SmsMessage {
//!         sender: Some("InfoSMS".into()),
//!         destinations: vec![SmsToDestination {
//!             to: "41793026727".into(),
//!             ..Default::default()
//!         }],
//!         content: SmsMessageContent::Text(SmsTextMessageContent {
//!             text: "Hello from Rust!".into(),
//!             ..Default::default()
//!         }),
//!         ..Default::default()
//!     }],
//!     options: None,
//! };
//!
//! let response = client.send_messages(&request).await?;
//! println!("Bulk ID: {:?}", response.bulk_id);
//! # Ok(())
//! # }
//! ```
//!
//! # Endpoints
//!
//! Only the **latest** version of every endpoint is exposed. Deprecated v1
//! and v2 send / log / report endpoints are intentionally omitted.
//!
//! | Method | Path | Client method |
//! |---|---|---|
//! | `POST` | `/sms/3/messages` | [`Client::send_messages`] |
//! | `POST` | `/sms/1/preview` | [`Client::preview_message`] |
//! | `GET` | `/sms/3/reports` | [`Client::get_delivery_reports`] |
//! | `GET` | `/sms/3/logs` | [`Client::get_logs`] |
//! | `GET` | `/sms/1/inbox/reports` | [`Client::get_inbound_messages`] |
//! | `GET` | `/sms/1/bulks` | [`Client::get_scheduled_bulk`] |
//! | `PUT` | `/sms/1/bulks` | [`Client::reschedule_bulk`] |
//! | `GET` | `/sms/1/bulks/status` | [`Client::get_bulk_status`] |
//! | `PUT` | `/sms/1/bulks/status` | [`Client::update_bulk_status`] |
//! | `POST` | `/ct/1/log/end/{messageId}` | [`Client::end_conversion_log`] |
//!
//! # Authentication
//!
//! Every Infobip endpoint accepts four authentication schemes. Pick one
//! that matches what your account is provisioned for:
//!
//! ```no_run
//! use infobip_sms::Auth;
//!
//! // `Authorization: App <key>` — recommended for service-to-service.
//! let _ = Auth::api_key("YOUR_API_KEY");
//!
//! // HTTP Basic auth.
//! let _ = Auth::basic("username", "password");
//!
//! // `Authorization: IBSSO <token>` — Infobip Single Sign-On.
//! let _ = Auth::ibsso("YOUR_IBSSO_TOKEN");
//!
//! // `Authorization: Bearer <token>` — OAuth2 client credentials.
//! let _ = Auth::bearer("YOUR_OAUTH2_TOKEN");
//! ```
//!
//! See [`Auth`] for details.
//!
//! # Error handling
//!
//! Every fallible call returns [`Result<T, Error>`](Error). The two main
//! error variants you care about are:
//!
//! - [`Error::Api`] — emitted by the v3 endpoints (`/sms/3/*`). Wraps a
//!   structured [`ApiError`] with `errorCode`, `description`, `action`,
//!   and a list of validation violations.
//! - [`Error::Exception`] — emitted by the legacy `/sms/1/*` endpoints.
//!   Wraps an [`ApiException`] with a `messageId` / `text` pair.
//!
//! Inspect the HTTP status via the `status` field on either variant. See
//! the [`error`] module for the full type tree.
//!
//! # Models and webhooks
//!
//! All wire schemas live in [`models`]. The [`models::webhooks`] module
//! exposes the payload shapes Infobip POSTs to your callback URLs — use
//! them as `Deserialize` targets in your webhook handlers.
//!
//! # Building blocks
//!
//! - [`Client`] — async, cheaply cloneable wrapper around a
//!   [`reqwest::Client`].
//! - [`ClientBuilder`] — configure base URL, auth, timeout, user-agent,
//!   or supply a custom `reqwest::Client`.
//! - [`Auth`] — authentication scheme.
//!
//! # Cargo features
//!
//! No optional features are exposed in this version. The default feature
//! set links `reqwest` with `rustls-tls`; if you need `native-tls`
//! instead, build a `reqwest::Client` yourself and hand it to
//! [`ClientBuilder::http_client`].
//!
//! # MSRV
//!
//! Edition 2024. The crate tracks the latest stable Rust release.

#![warn(missing_docs)]
#![warn(rustdoc::broken_intra_doc_links)]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod client;
pub mod error;
pub mod models;

mod api;

pub use client::{Auth, Client, ClientBuilder};
pub use error::{ApiError, ApiException, Error};