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
//! This module provides a `PersistentMenuModel` struct that represents a persistent menu in a Messenger conversation.
//!
//! ## PersistentMenuModel Struct
//!
//! The `PersistentMenuModel` struct represents a persistent menu in a Messenger conversation. The persistent menu is an always-on user interface element inside Messenger conversations. It's an easy way to help people discover and access the core functionality of your Messenger bot at any point in the conversation.
//!
//! ### Fields
//!
//! * `psid: String` - The ID of the recipient.
//! * `persistent_menu: Vec<Menu>` - The items in the persistent menu.
//!
//! ### Methods
//!
//! * `new(sender: &'p str, buttons: Vec<Button>) -> Self` - Creates a new `PersistentMenuModel` instance.
//!
//! ## Examples
//!
//! Creating a `PersistentMenuModel` and sending it:
//!
//! ```rust
//! use russenger::prelude::*;
//!
//! async fn index(res: Res, req: Req) -> Result<()> {
//! // Need GetStart First Before Send PersistenceMenu
//! res.send(GetStartedButtonModel::new(Payload::default())).await?;
//! let buttons = vec![
//! Button::Postback {
//! title: "Option 1",
//! payload: Payload::new("/option_1", None),
//! },
//! // More buttons
//! ];
//!
//! let menu = PersistentMenuModel::new(&req.user, buttons);
//! res.send(menu).await?;
//!
//! Ok(())
//! }
//!
//! async fn option_1(res: Res, req: Req) -> Result<()> {
//! res.send(TextModel::new(&req.user, "Option_1")).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Returns
//!
//! A POST request to the Facebook API to send a persistent menu.
//!
//! ## Reference
//!
//! [Facebook Messenger Platform - Persistent Menu](https://developers.facebook.com/docs/messenger-platform/send-messages/persistent-menu)
use Button;
use ResponseModel;
use Serialize;
use Value;
/// `PersistentMenuModel` is a struct that represents a persistent menu in a Messenger conversation.
///
/// The persistent menu is an always-on user interface element inside Messenger conversations.
/// It's an easy way to help people discover and access the core functionality of your Messenger bot at any point in the conversation.
///
/// # Fields
///
/// * `psid`: A string that represents the ID of the recipient.
/// * `persistent_menu`: A vector of `Menu` structs that represent the items in the persistent menu.
///
/// # Methods
///
/// * `new(sender: &'p str, buttons: Vec<Button>) -> Self` - Creates a new `PersistentMenuModel` instance.
///
/// # Examples
///
/// Creating a `PersistentMenuModel` and sending it:
///
/// ```rust
/// use russenger::prelude::*;
///
/// async fn index(res: Res, req: Req) -> Result<()> {
/// // Need GetStart First Before Send PersistenceMenu
/// res.send(GetStartedButtonModel::new(Payload::default())).await?;
/// let buttons = vec![
/// Button::Postback {
/// title: "Option 1",
/// payload: Payload::new("/option_1", None),
/// },
/// // More buttons
/// ];
///
/// let menu = PersistentMenuModel::new(&req.user, buttons);
/// res.send(menu).await?;
///
/// Ok(())
/// }
///
///
/// async fn option_1(res: Res, req: Req) -> Result<()> {
/// res.send(TextModel::new(&req.user, "Option_1")).await?;
///
/// Ok(())
/// }
/// ```
///
/// [Facebook Documentation](https://developers.facebook.com/docs/messenger-platform/send-messages/persistent-menu)