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
//! Models for `GET /sms/3/reports` — fetching outbound delivery reports.
//!
//! Use this when you can't expose a real-time webhook for delivery
//! reports. Each report is returned **only once** per call; pass
//! `bulkId` or `messageId` to filter, or call repeatedly to drain the
//! report queue.

use serde::{Deserialize, Serialize};

use crate::models::common::{MessageError, Platform, Price, Status};

/// Response body for
/// [`Client::get_delivery_reports`](crate::Client::get_delivery_reports).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DeliveryReports {
    /// One [`DeliveryReport`] per message.
    #[serde(default)]
    pub results: Vec<DeliveryReport>,
}

/// Per-message delivery report.
///
/// Same shape is also POSTed to delivery webhooks — see
/// [`crate::models::webhooks::DeliveryReportPayload`].
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeliveryReport {
    /// Bulk ID this message belonged to.
    pub bulk_id: Option<String>,
    /// Per-recipient message ID.
    pub message_id: Option<String>,
    /// Destination address.
    pub to: Option<String>,
    /// Sender ID that delivered the message.
    pub sender: Option<String>,
    /// When the message was sent (or scheduled to be sent).
    /// Format `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
    pub sent_at: Option<String>,
    /// When Infobip finished processing the message (delivered to
    /// handset, network, expired, etc.).
    pub done_at: Option<String>,
    /// Number of SMS parts the message split into.
    pub message_count: Option<i32>,
    /// Mobile country + network code of the destination operator.
    pub mcc_mnc: Option<String>,
    /// `callbackData` that was supplied at send time, echoed back.
    pub callback_data: Option<String>,
    /// Cost of this message.
    pub price: Option<Price>,
    /// Final status (`DELIVERED`, `EXPIRED`, etc.).
    pub status: Option<Status>,
    /// Error details, if any.
    pub error: Option<MessageError>,
    /// Routing platform (entity / application IDs).
    pub platform: Option<Platform>,
    /// Marketing campaign reference, if set on send.
    pub campaign_reference_id: Option<String>,
}

/// Optional query parameters for
/// [`Client::get_delivery_reports`](crate::Client::get_delivery_reports).
///
/// Use [`Default::default`] for the unfiltered query.
///
/// ```
/// use infobip_sms::models::reports::DeliveryReportsQuery;
///
/// let query = DeliveryReportsQuery {
///     bulk_id: Some("BULK-ID-123-xyz".into()),
///     limit: Some(100),
///     ..Default::default()
/// };
/// # let _ = query;
/// ```
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DeliveryReportsQuery {
    /// Filter to one bulk.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bulk_id: Option<String>,
    /// Filter to one message.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<String>,
    /// Maximum reports to return. Defaults to 50; max 1000.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i32>,
    /// Filter by sending entity ID.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub entity_id: Option<String>,
    /// Filter by sending application ID.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub application_id: Option<String>,
    /// Filter by campaign reference ID.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub campaign_reference_id: Option<String>,
}