1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Action objects
//! # Note
//! These are types of actions for your bot to take when a user taps a button or an image in a message.
//! <https://developers.line.biz/en/reference/messaging-api/#action-objects>
use serde_derive::Serialize;

/// Action object
/// # Note
#[derive(Serialize, Debug)]
pub struct Action {
    #[serde(flatten)]
    pub r#type: ActionType,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub label: Option<String>,
}

/// Action object types
#[derive(Serialize, Debug)]
#[serde(tag = "type")]
pub enum ActionType {
    #[serde(rename = "postback")]
    Postback {
        data: String,
        #[serde(skip_serializing_if = "Option::is_none")]
        display_text: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        text: Option<String>,
    },
    #[serde(rename = "message")]
    Message { text: String },
    #[serde(rename = "uri")]
    Uri {
        uri: String,
        #[serde(rename = "altUri", skip_serializing_if = "Option::is_none")]
        alt_uri: Option<AltUri>,
    },
    #[serde(rename = "datetimepicker")]
    Datetimepicker {
        data: String,
        mode: String,
        #[serde(skip_serializing_if = "Option::is_none")]
        initial: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        max: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        min: Option<String>,
    },
    #[serde(rename = "camera")]
    Camera {},
    #[serde(rename = "cameraRoll")]
    CameraRoll {},
    #[serde(rename = "location")]
    Location {},
}

/// Alt uri object
/// # Note
/// URI opened on LINE for macOS and Windows when the action is performed.
#[derive(Serialize, Debug)]
pub struct AltUri {
    pub desktop: String,
}