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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//! This module provides `QuickReply` and `QuickReplyModel` structs that represent a quick reply button and a message with quick reply buttons in a Messenger conversation.
//!
//! ## QuickReply Struct
//!
//! The `QuickReply` struct represents a quick reply button in a Messenger conversation. Quick replies provide a way to present a set of up to 13 buttons in-conversation that contain a title and optional image, and appear prominently above the composer.
//!
//! ### Fields
//!
//! * `content_type: String` - The type of content. In this case, it's always "text".
//! * `title: String` - The title of the quick reply button.
//! * `payload: String` - The payload of the quick reply button.
//! * `image_url: String` - The URL of the image to be displayed on the quick reply button.
//!
//! ### Methods
//!
//! * `new(title: &str, image_url: &str, payload: Payload) -> Self` - Creates a new `QuickReply` instance.
//!
//! ## QuickReplyModel Struct
//!
//! The `QuickReplyModel` struct represents a message with quick reply buttons in a Messenger conversation.
//!
//! ### Fields
//!
//! * `messaging_type: String` - The type of messaging. For quick reply messages, this is always "RESPONSE".
//! * `recipient: Recipient` - The recipient of the quick reply message.
//! * `message: QuickMessage` - The message that contains the text and the quick reply buttons.
//!
//! ### Methods
//!
//! * `new(sender: &'q str, text: &'q str, quick_replies: Vec<QuickReply>) -> Self` - Creates a new `QuickReplyModel` instance.
//!
//! ## Examples
//!
//! Creating a `QuickReply` and a `QuickReplyModel`:
//!
//! ```rust
//! use russenger::prelude::*;
//!
//! async fn index(res: Res, req: Req) -> Result<()> {
//! let data = Data::new("HelloWorld");
//! let payload = Payload::new("/hello_world", Some(data));
//! let quick_replies = vec![QuickReply::new("Button Title", Some(&"https://example.com/image.png".to_string()), payload)];
//! let quick_reply = QuickReplyModel::new(&req.user, "Choose an option:", quick_replies);
//! res.send(quick_reply).await?;
//!
//! Ok(())
//! }
//!
//!
//! async fn hello_world(res: Res, req: Req) -> Result<()> {
//! let hello_world: String = req.data.get_value()?;
//! res.send(TextModel::new(&req.user, &hello_world)).await?;
//!
//! Ok(())
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! App::init().await?
//! .attach(router![("/", index), ("/hello_world", hello_world)])
//! .launch()
//! .await?;
//! Ok(())
//! }
//! ```
//!
//! ## Returns
//!
//! A POST request to the Facebook API to send a quick reply button or a message with quick reply buttons.
//!
//! ## Reference
//!
//! [Facebook Messenger Platform - Quick Replies](https://developers.facebook.com/docs/messenger-platform/send-messages/quick-replies)
use Serialize;
use ResponseModel;
use ;
/// `QuickReply` is a struct that represents a quick reply button in a Messenger conversation.
///
/// Quick replies provide a way to present a set of up to 13 buttons in-conversation that contain a title and optional image, and appear prominently above the composer.
///
/// # Fields
///
/// * `content_type: String` - The type of content. In this case, it's always "text".
/// * `title: String` - The title of the quick reply button.
/// * `payload: String` - The payload of the quick reply button.
/// * `image_url: String` - The URL of the image to be displayed on the quick reply button.
///
/// # Methods
///
/// * `new(title: &str, image_url: &str, payload: Payload) -> Self` - Creates a new `QuickReply` instance.
///
/// # Examples
///
/// Creating a `QuickReply`:
///
/// ```rust
/// use russenger::prelude::*;
///
/// let data = Data::new("HelloWorld");
/// let payload = Payload::new("/hello_world", Some(data));
/// let quick_reply = QuickReply::new("Button Title", Some(&"https://example.com/image.png".to_string()), payload);
///
/// async fn hello_world(res: Res, req: Req) -> Result<()> {
/// let hello_world: String = req.data.get_value()?;
/// res.send(TextModel::new(&req.user, &hello_world)).await?;
///
/// Ok(())
/// }
/// ```
/// `QuickReplyModel` is a struct that represents a message with quick reply buttons in a Messenger conversation.
///
/// # Fields
///
/// * `recipient: Recipient<'q>` - The recipient of the message.
/// * `messaging_type: &'q str` - The type of messaging. In this case, it's always "RESPONSE".
/// * `message: QuickMessage` - The message with quick reply buttons.
///
/// # Methods
///
/// * `new(sender: &'q str, message: &str, quick_replies: Vec<QuickReply>) -> Self` - Creates a new `QuickReplyModel` instance.
///
/// # Examples
///
/// Creating a `QuickReplyModel`:
///
/// ```rust
/// use russenger::prelude::*;
///
/// async fn some_action(res: Res, req: Req) -> Result<()> {
/// let payload = Payload::new("/some_action", None);
/// let quick_reply = QuickReply::new("Button Title", Some(&"https://example.com/image.png".to_string()), payload);
/// let quick_reply_model = QuickReplyModel::new(&req.user, "Message Text", vec![quick_reply]);
/// res.send(quick_reply_model).await?;
///
/// Ok(())
/// }
/// ```