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/1/inbox/reports` — fetching inbound (mobile-
//! originated, "MO") SMS.
//!
//! Use this when you can't expose a real-time webhook for inbound
//! messages. Each message is returned **only once** per call.
//!
//! Receiving inbound SMS at all requires you to first [purchase a
//! number][1] capable of receiving SMS traffic and configure its
//! forwarding endpoint.
//!
//! [1]: https://www.infobip.com/docs/api/platform/numbers/phone-numbers/purchase-number

use serde::{Deserialize, Serialize};

use crate::models::common::Price;

/// Response body for
/// [`Client::get_inbound_messages`](crate::Client::get_inbound_messages).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InboundSmsResponse {
    /// Inbound messages returned by this call.
    #[serde(default)]
    pub results: Vec<InboundSms>,
    /// Number of messages in [`Self::results`].
    pub message_count: Option<i32>,
    /// How many additional messages are still queued for retrieval.
    /// Drain by calling again.
    pub pending_message_count: Option<i32>,
}

/// One inbound SMS.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InboundSms {
    /// Application ID this message was routed to.
    pub application_id: Option<String>,
    /// Unique inbound message ID.
    pub message_id: Option<String>,
    /// Sender's address (the end user's number).
    pub from: Option<String>,
    /// Recipient address (your number / short code).
    pub to: Option<String>,
    /// Full message body, including any keyword.
    pub text: Option<String>,
    /// Message body with the leading keyword stripped (if any).
    pub clean_text: Option<String>,
    /// Keyword that triggered routing, if applicable.
    pub keyword: Option<String>,
    /// Receipt timestamp on Infobip's side
    /// (`yyyy-MM-dd'T'HH:mm:ss.SSSZ`).
    pub received_at: Option<String>,
    /// Number of SMS parts the inbound message arrived in.
    pub sms_count: Option<i32>,
    /// Cost charged for the inbound (often zero).
    pub price: Option<Price>,
    /// Account-supplied callback data set on the inbound configuration.
    pub callback_data: Option<String>,
    /// Entity ID this message was routed to.
    pub entity_id: Option<String>,
    /// Marketing campaign reference, if applicable.
    pub campaign_reference_id: Option<String>,
}

/// Optional query parameters for
/// [`Client::get_inbound_messages`](crate::Client::get_inbound_messages).
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InboundQuery {
    /// Maximum messages to return. Defaults to 50; max 1000.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i32>,
    /// Filter to one application ID.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub application_id: Option<String>,
    /// Filter to one entity ID.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub entity_id: Option<String>,
    /// Filter by campaign reference ID.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub campaign_reference_id: Option<String>,
}