Skip to main content

infraqueue_twilio/
models.rs

1use serde::{Deserialize, Serialize};
2
3#[cfg(feature = "utoipa")]
4use utoipa::ToSchema;
5#[cfg(feature = "validator")]
6use validator::Validate;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[cfg_attr(feature = "utoipa", derive(ToSchema))]
10#[cfg_attr(feature = "validator", derive(Validate))]
11pub struct MessageCreateRequest {
12    /// The recipient's phone number in E.164 format (e.g., +14155551212).
13    #[cfg_attr(feature = "validator", validate(length(min = 8, max = 20)))]
14    pub to: String,
15    /// The message content. Limited to 1600 characters for SMS.
16    #[cfg_attr(feature = "validator", validate(length(min = 1, max = 1600)))]
17    pub body: String,
18    /// Optional sender SID; if both from and messaging_service_sid are omitted,
19    /// the client will use its default from the config.
20    pub messaging_service_sid: Option<String>,
21    /// Optional sender phone number; if both from and messaging_service_sid are omitted,
22    /// the client will use its default from the config.
23    pub from: Option<String>,
24    /// Optional list of media URLs for MMS.
25    pub media_urls: Option<Vec<String>>,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[cfg_attr(feature = "utoipa", derive(ToSchema))]
30pub struct MessageCreateResponse {
31    /// The unique Twilio identifier for the message (prefix SM... or MM...).
32    pub sid: String,
33    /// The destination phone number.
34    pub to: String,
35    /// Initial status (usually "queued" or "sent").
36    pub status: String,
37}