flows_connector_dsi/
twilio.rs1use serde::Serialize;
2
3#[derive(Serialize)]
4pub struct OutboundData {
5 #[serde(rename = "To")]
6 to: String,
7 #[serde(rename = "Body")]
8 body: Option<String>,
9}
10
11impl OutboundData {
12 pub fn body<S: Into<String>>(mut self, body: S) -> OutboundData {
14 self.body = Some(body.into());
15 self
16 }
17
18 pub fn build(self) -> Result<String, String> {
20 if self.body.is_none() {
21 return Err("OutboundData build failed: Body is empty".to_string());
22 }
23
24 serde_json::to_string(&self)
25 .map_err(|e| format!("OutboundData build failed: {}", e.to_string()))
26 }
27}
28
29pub fn outbound<S: Into<String>>(phone_number: S) -> OutboundData {
38 OutboundData {
39 to: phone_number.into(),
40 body: None,
41 }
42}