line_bot_messaging_api/entity/action/
uri.rs

1use crate::action::LineActionObject;
2use serde_derive::{Deserialize, Serialize};
3use serde_json::json;
4
5#[derive(Debug, Default, Deserialize, Serialize, Clone)]
6pub struct LineActionUri {
7    #[serde(rename = "type")]
8    message_type: String,
9    label: String,
10    uri: String,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    #[serde(rename = "altUri")]
13    alt_uri: Option<LineMessageActionUriAltUri>,
14}
15
16impl LineActionUri {
17    pub fn new<T: ToString, U: ToString>(label: T, uri: U) -> Self {
18        Self {
19            message_type: "uri".to_string(),
20            label: label.to_string(),
21            uri: uri.to_string(),
22            alt_uri: None,
23        }
24    }
25    pub fn set_alt_uri(&mut self, alt_uri: LineMessageActionUriAltUri) {
26        self.alt_uri = Some(alt_uri);
27    }
28}
29
30#[derive(Debug, Default, Deserialize, Serialize, Clone)]
31pub struct LineMessageActionUriAltUri {
32    desktop: String,
33}
34
35impl LineActionObject for LineActionUri {
36    fn build(&self) -> serde_json::Value {
37        json!(self)
38    }
39}