flows_connector_dsi/
notion.rs1use std::collections::HashMap;
2
3use serde::Serialize;
4
5#[derive(Serialize, Default)]
6pub struct OutboundData {
7 #[serde(flatten)]
8 inner: HashMap<String, String>,
9}
10
11impl OutboundData {
12 pub fn property<P: Into<String>, C: Into<String>>(
15 mut self,
16 property: P,
17 content: C,
18 ) -> OutboundData {
19 self.inner.insert(property.into(), content.into());
20 self
21 }
22
23 #[deprecated(
24 since = "0.1.4",
25 note = "Please use property() instead of page(), this name can be confusing."
26 )]
27 pub fn page<P: Into<String>, C: Into<String>>(self, property: P, content: C) -> OutboundData {
28 self.property(property, content)
29 }
30
31 pub fn build(self) -> Result<String, String> {
33 if self.inner.is_empty() {
34 return Err("OutboundData build failed: No properties to create a page".to_string());
35 }
36
37 serde_json::to_string(&self)
38 .map_err(|e| format!("OutboundData build failed: {}", e.to_string()))
39 }
40}
41
42pub fn outbound() -> OutboundData {
57 OutboundData::default()
58}