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
//! This module provides `Message` and `MessageModel` structs that represent a message in a Messenger conversation.
//!
//! ## Message Struct
//!
//! The `Message` struct represents a message in a Messenger conversation. This struct is used to send a message to the recipient.
//!
//! ### Fields
//!
//! * `text: String` - The text of the message.
//!
//! ## MessageModel Struct
//!
//! The `MessageModel` struct is used to send a message to the recipient. This struct contains the recipient, the type of messaging, and the message itself.
//!
//! ### Fields
//!
//! * `recipient: Recipient` - The recipient of the message.
//! * `messaging_type: String` - The type of messaging. For messages, this is always "RESPONSE".
//! * `message: Message` - The message to send.
//!
//! ### Methods
//!
//! * `new(sender: &'s str, text: &'s str) -> Self` - Creates a new `MessageModel` instance.
//!
//! ## Examples
//!
//! Sending a message:
//!
//! ```rust
//! use russenger::prelude::*;
//!
//! async fn index(res: Res, req: Req) -> Result<()> {
//! res.send(TextModel::new(&req.user, "Hello World!")).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Returns
//!
//! A POST request to the Facebook API to send a message.
//!
//! ## Reference
//!
//! [Facebook Messenger Platform - Send Messages](https://developers.facebook.com/docs/messenger-platform/send-messages)
use Serialize;
use Recipient;
use ResponseModel;
/// `TextModel` is used to send text messages to the recipient.
///
/// The `TextModel` struct contains the following fields:
/// - `recipient`: A `Recipient` struct that specifies the recipient of the text message.
/// - `messaging_type`: A string that specifies the type of messaging. For text messages, this is always "RESPONSE".
/// - `message`: A `Text` struct that contains the text of the message.
///
/// # Methods
///
/// * `new(sender: &'s str, text: &'s str) -> Self` - Creates a new `TextModel` instance.
///
/// # Examples
///
/// Sending a text message:
///
/// ```rust
/// use russenger::prelude::*;
///
/// async fn index(res: Res, req: Req) -> Result<()> {
/// res.send(TextModel::new(&req.user, "Hello World!")).await?;
///
/// Ok(())
/// }
/// ```
///
/// ```rust
/// use russenger::response_models::text::TextModel;
/// let message = TextModel::new("sender_id", "Hello, world!");
/// ```
///
/// [Facebook Documentation](https://developers.facebook.com/docs/messenger-platform/send-messages/text)