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
use reqwest::Method;

use crate::api::{decode_response, ErrorKind};
use crate::client::Client;
use crate::error::Error;
use crate::models::logs::{LogsQuery, LogsResponse};

impl Client {
    /// Fetches outbound message logs (cursor-paginated).
    ///
    /// Wraps `GET /sms/3/logs`. Logs are kept for 48 hours and at most
    /// 1000 entries are returned per call.
    ///
    /// To page through more than 1000 entries, set
    /// [`LogsQuery::use_cursor`](crate::models::logs::LogsQuery::use_cursor)
    /// to `true` and feed
    /// [`CursorPageInfo::next_cursor`](crate::models::common::CursorPageInfo::next_cursor)
    /// back into
    /// [`LogsQuery::cursor`](crate::models::logs::LogsQuery::cursor)
    /// on each subsequent request. The
    /// [`logs` module docs][crate::models::logs] include a worked
    /// pagination example.
    ///
    /// # Errors
    ///
    /// On non-2xx responses, returns
    /// [`Error::Api`].
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use infobip_sms::Client;
    /// use infobip_sms::models::logs::LogsQuery;
    ///
    /// # async fn run(client: Client) -> Result<(), infobip_sms::Error> {
    /// let logs = client
    ///     .get_logs(&LogsQuery {
    ///         bulk_id: vec!["BULK-ID-123-xyz".into()],
    ///         limit: Some(200),
    ///         ..Default::default()
    ///     })
    ///     .await?;
    /// # let _ = logs;
    /// # Ok(()) }
    /// ```
    pub async fn get_logs(&self, query: &LogsQuery) -> Result<LogsResponse, Error> {
        let response = self
            .request(Method::GET, "sms/3/logs")?
            .query(query)
            .send()
            .await?;
        decode_response(response, ErrorKind::Rich).await
    }
}