1use serde::{Deserialize, Serialize};
2
3use super::message::StatusCode;
4
5#[derive(Deserialize, Debug)]
6pub struct VerificationRequest {
7 #[serde(rename = "hub.mode")]
8 pub mode: String,
9 #[serde(rename = "hub.verify_token")]
10 pub verify_token: String,
11 #[serde(rename = "hub.challenge")]
12 pub challenge: String,
13}
14
15#[derive(Deserialize, Serialize, Debug, Clone)]
16pub struct NotificationPayload {
17 pub object: String,
18 pub entry: Vec<Entry>,
19}
20
21#[derive(Deserialize, Serialize, Debug, Clone)]
22pub struct Entry {
23 pub id: String,
24 pub changes: Vec<Change>,
25}
26
27#[derive(Deserialize, Serialize, Debug, Clone)]
28pub struct Change {
29 pub value: Value,
30 pub field: String,
31}
32
33#[derive(Deserialize, Serialize, Debug, Clone)]
34pub struct Value {
35 pub contacts: Option<Vec<Contact>>,
36 pub errors: Option<Vec<Error>>,
37 pub messaging_product: String,
38 pub metadata: Metadata,
39 pub messages: Option<Vec<NotificationMessage>>,
40 pub statuses: Option<Vec<Status>>,
41}
42
43#[derive(Deserialize, Serialize, Debug, Clone)]
44pub struct Contact {
45 pub wa_id: String,
46 pub profile: Profile,
47}
48
49#[derive(Deserialize, Serialize, Debug, Clone)]
50pub struct Profile {
51 pub name: String,
52}
53
54#[derive(Deserialize, Serialize, Debug, Clone)]
55pub struct Metadata {
56 pub display_phone_number: String,
57 pub phone_number_id: String,
58}
59
60#[derive(Deserialize, Serialize, Debug, Clone)]
61pub struct NotificationMessage {
62 pub from: String,
63 pub id: String,
64 pub context: Option<Context>,
65 pub errors: Option<Vec<Error>>,
66 pub timestamp: String,
67
68 #[serde(rename = "type")]
69 pub message_type: NotificationMessageType,
70 pub audio: Option<Audio>,
71 pub button: Option<Button>,
72 pub document: Option<Document>,
73 pub text: Option<Text>,
74 pub image: Option<Image>,
75 pub interactive: Option<Interactive>,
76 pub order: Option<Order>,
77 pub sticker: Option<Sticker>,
78 pub system: Option<System>,
79 pub video: Option<Video>,
80 pub location: Option<Location>,
81}
82
83#[derive(Deserialize, Serialize, Debug, Clone)]
84pub struct Context {
85 pub forwarded: Option<bool>,
86 pub frequently_forwarded: Option<bool>,
87 pub from: Option<String>,
88 pub id: Option<String>,
89 pub referred_product: Option<ReferredProduct>,
90}
91
92#[derive(Deserialize, Serialize, Debug, Clone)]
93pub struct ReferredProduct {
94 pub catalog_id: String,
95 pub product_retailer_id: String,
96}
97
98#[derive(Deserialize, Serialize, Debug, Clone)]
99pub struct Error {
100 pub code: i32,
101 pub title: String,
102 }
104
105#[derive(Deserialize, Serialize, Debug, Clone)]
106#[serde(rename_all = "snake_case")]
107pub enum NotificationMessageType {
108 Audio,
109 Button,
110 Document,
111 Text,
112 Image,
113 Interactive,
114 Order,
115 Sticker,
116 System,
117 Unknown,
118 Video,
119 Unsupported,
120 Location,
121}
122
123#[derive(Deserialize, Serialize, Debug, Clone)]
124pub struct Audio {
125 pub id: String,
126 pub mime_type: String,
127}
128
129#[derive(Deserialize, Serialize, Debug, Clone)]
130pub struct Button {
131 pub payload: String,
132 pub text: String,
133}
134
135#[derive(Deserialize, Serialize, Debug, Clone)]
136pub struct Document {
137 pub caption: Option<String>,
138 pub filename: String,
139 pub sha256: String,
140 pub mime_type: String,
141 pub id: String,
142}
143
144#[derive(Deserialize, Serialize, Debug, Clone)]
145pub struct Image {
146 pub caption: Option<String>,
147 pub sha256: String,
148 pub id: String,
149 pub mime_type: Option<String>,
150}
151
152#[derive(Deserialize, Serialize, Debug, Clone)]
153pub struct Interactive {
154 pub button_reply: Option<ButtonReply>,
155 pub list_reply: Option<ListReply>,
156}
157
158#[derive(Deserialize, Serialize, Debug, Clone)]
159pub struct ButtonReply {
160 pub id: String,
161 pub title: String,
162}
163
164#[derive(Deserialize, Serialize, Debug, Clone)]
165pub struct ListReply {
166 pub id: String,
167 pub title: String,
168 pub description: Option<String>,
169}
170
171#[derive(Deserialize, Serialize, Debug, Clone)]
172pub struct Order {
173 pub catalog_id: String,
174 pub product_items: Vec<ProductItem>,
175}
176
177#[derive(Deserialize, Serialize, Debug, Clone)]
178pub struct ProductItem {
179 pub product_retailer_id: String,
180 pub quantity: String,
181 pub item_price: String,
182 pub currency: String,
183}
184
185#[derive(Deserialize, Serialize, Debug, Clone)]
186pub struct Sticker {
187 pub mime_type: String,
188 pub sha256: String,
189 pub id: String,
190 pub animated: Option<bool>,
191}
192
193#[derive(Deserialize, Serialize, Debug, Clone)]
194pub struct System {
195 pub body: String,
196 pub identity: String,
197 pub new_wa_id: Option<String>,
198 pub wa_id: Option<String>,
199 pub system_type: String,
200 pub customer: String,
201}
202
203#[derive(Deserialize, Serialize, Debug, Clone)]
204pub struct Text {
205 pub body: String,
206}
207
208#[derive(Deserialize, Serialize, Debug, Clone)]
209pub struct Video {
210 pub caption: Option<String>,
211 pub filename: String,
212 pub sha256: String,
213 pub id: String,
214 pub mime_type: String,
215}
216
217#[derive(Deserialize, Serialize, Debug, Clone)]
218pub struct Location {
219 pub latitude: f64,
220 pub longitude: f64,
221 pub address: Option<String>,
222 pub name: Option<String>,
223}
224
225#[derive(Deserialize, Serialize, Debug, Clone)]
226pub struct Status {
227 pub biz_opaque_callback_data: Option<String>,
228 pub conversation: Option<Conversation>,
229 pub errors: Option<Vec<Error>>,
230 pub id: String,
231 pub pricing: Option<Pricing>,
232 pub recipient_id: String,
233 pub status: StatusCode,
234 pub timestamp: String,
235}
236
237#[derive(Deserialize, Serialize, Debug, Clone)]
238pub struct Conversation {
239 pub id: String,
240 pub origin: Origin,
241 }
243
244#[derive(Deserialize, Serialize, Debug, Clone)]
245pub struct Origin {
246 #[serde(rename = "type")]
247 pub origin_type: String,
248}
249
250#[derive(Deserialize, Serialize, Debug, Clone)]
251pub struct Pricing {
252 pub pricing_model: String,
253 }