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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! This module provides `Actions` enum and `SenderActionModel` struct that represent sender actions in a Messenger conversation.
//!
//! ## Actions Enum
//!
//! The `Actions` enum is used to specify the type of sender action to send to the recipient. Sender actions include `MarkSeen`, `TypingOn`, and `TypingOff`. These actions allow you to control the status of the conversation, such as marking a message as seen or showing a typing indicator.
//!
//! ### Variants
//!
//! * `MarkSeen` - Marks the last message as seen. This will show a "seen" receipt to the user.
//! * `TypingOn` - Turns the typing indicators on. This will show a "typing..." indicator to the user.
//! * `TypingOff` - Turns the typing indicators off. This will hide the "typing..." indicator from the user.
//!
//! ## SenderActionModel Struct
//!
//! The `SenderActionModel` struct is used to send sender actions to the recipient. Sender actions include `mark_seen`, `typing_on`, and `typing_off`. These actions allow you to control the status of the conversation, such as marking a message as seen or showing a typing indicator.
//!
//! ### Fields
//!
//! * `messaging_type: String` - The type of messaging. For sender actions, this is always "RESPONSE".
//! * `recipient: Recipient` - The recipient of the sender action.
//! * `sender_action: String` - The sender action to send.
//!
//! ## Examples
//!
//! Using `Actions` and `SenderActionModel`:
//!
//! ```rust
//! use russenger::response_models::sender_action::{Actions, SenderActionModel};
//!
//! let action = SenderActionModel::new("sender_id", Actions::MarkSeen);
//! let action = SenderActionModel::new("sender_id", Actions::TypingOn);
//! let action = SenderActionModel::new("sender_id", Actions::TypingOff);
//! ```
//!
//! Use case:
//!
//! ```rust
//! use russenger::prelude::*;
//!
//! async fn index(res: Res, req: Req) -> Result<()> {
//! res.send(SenderActionModel::new(&req.user, MarkSeen)).await?;
//! res.send(TextModel::new(&req.user, "Hello, world!")).await?;
//!
//! Ok(())
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! App::init().await?
//! .attach(router![("/", index)])
//! .launch().await?;
//! Ok(())
//! }
//! ```
//!
//!
//! ## Reference
//!
//! [Facebook Messenger Platform - Sender Actions](https://developers.facebook.com/docs/messenger-platform/send-messages/sender-actions)
use ;
use Serialize;
/// `Actions` is an enum used to specify the type of sender action to send to the recipient.
///
/// Sender actions include `MarkSeen`, `TypingOn`, and `TypingOff`.
///
/// These actions allow you to control the status of the conversation, such as marking a message as seen or showing a typing indicator.
///
/// # Variants
///
/// * `MarkSeen` - Marks the last message as seen. This will show a "seen" receipt to the user.
/// * `TypingOn` - Turns the typing indicators on. This will show a "typing..." indicator to the user.
/// * `TypingOff` - Turns the typing indicators off. This will hide the "typing..." indicator from the user.
///
/// # Examples
///
/// Using `Actions::MarkSeen` to mark a message as seen:
///
/// ```rust
/// use russenger::response_models::sender_action::{Actions, SenderActionModel};
/// let action = SenderActionModel::new("sender_id", Actions::MarkSeen);
/// ```
///
/// Using `Actions::TypingOn` to turn the typing indicators on:
///
/// ```rust
/// use russenger::response_models::sender_action::{Actions, SenderActionModel};
/// let action = SenderActionModel::new("sender_id", Actions::TypingOn);
/// ```
///
/// Using `Actions::TypingOff` to turn the typing indicators off:
///
/// ```rust
/// use russenger::response_models::sender_action::{Actions, SenderActionModel};
/// let action = SenderActionModel::new("sender_id", Actions::TypingOff);
/// ```
/// `SenderActionModel` is used to send sender actions to the recipient.
/// Sender actions include `mark_seen`, `typing_on`, and `typing_off`.
///
/// These actions allow you to control the status of the conversation, such as marking a message as seen or showing a typing indicator.
///
/// The `SenderActionModel` struct contains the following fields:
/// - `messaging_type`: A string that specifies the type of messaging. For sender actions, this is always "RESPONSE".
/// - `recipient`: A `Recipient` struct that specifies the recipient of the sender action.
/// - `sender_action`: A string that specifies the sender action to send.
///
/// # Examples
///
/// ``` rust
/// use russenger::prelude::*;
///
/// async fn index(res: Res, req: Req) -> Result<()> {
/// let action = SenderActionModel::new(&req.user, MarkSeen);
/// res.send(action).await?;
///
/// Ok(())
/// }
/// ```
///
/// Sending a `mark_seen` action:
///
/// ```rust
/// use russenger::response_models::sender_action::{Actions, SenderActionModel};
/// let action = SenderActionModel::new("sender_id", Actions::MarkSeen);
/// ```
///
/// Sending a `typing_on` action:
///
/// ```rust
/// use russenger::response_models::sender_action::{Actions, SenderActionModel};
/// let action = SenderActionModel::new("sender_id", Actions::TypingOn);
/// ```
///
/// Sending a `typing_off` action:
///
/// ```rust
/// use russenger::response_models::sender_action::{Actions, SenderActionModel};
/// let action = SenderActionModel::new("sender_id", Actions::TypingOff);
/// ```
///
/// [Facebook Documentation](https://developers.facebook.com/docs/messenger-platform/send-messages/sender-actions)