safe_vk/responses/
update.rs

1use serde::Deserialize;
2use serde_json::Value;
3
4#[derive(Deserialize, Debug, PartialEq)]
5pub struct Ctx {
6    pub ts: String,
7    pub updates: Vec<Update>,
8}
9
10#[derive(Deserialize, Debug, PartialEq)]
11pub struct Update {
12    pub event_id: String,
13    // Bot group ID                         (bot)
14    pub group_id: i32,
15    // Update object                        (anything)
16    pub object: UpdateObject,
17    #[serde(rename = "type")]
18    pub update_type: String,
19    // VK api version                       (const / DO NOT CHANGE)
20    pub v: String,
21}
22
23#[derive(Debug, Deserialize, PartialEq)]
24pub struct UpdateObject {
25    // Information about user               (message)
26    pub client_info: Option<ClientInfo>,
27    // Message object                       (message)
28    pub message: Option<Message>,
29    // Conversation message ID              (message)
30    pub cmid: Option<i32>,
31    // unique ID for your button            (keyboard)
32    pub event_id: Option<String>,
33    // Unique ID for conversation / groups  (message)
34    pub peer_id: Option<i32>,
35    // Who wrote message                    (message)
36    pub user_id: Option<i32>,
37    // Your custom payload for your button  (keyboard)
38    pub payload: Option<Value>,
39    // Reacted id                           (message)
40    pub reacted_id: Option<i32>,
41    // Reaction id                          (message)
42    pub reaction_id: Option<i32>,
43}
44
45#[derive(Debug, Deserialize, PartialEq)]
46pub struct ClientInfo {
47    pub button_actions: Vec<String>,
48    pub carousel: bool,
49    pub inline_keyboard: bool,
50    pub keyboard: bool,
51    pub lang_id: usize,
52}
53
54#[derive(Debug, Deserialize, PartialEq)]
55pub struct Message {
56    pub attachments: Vec<Attachment>,
57    pub conversation_message_id: i32,
58    pub date: i32,
59    pub from_id: i32,
60    pub fwd_message: Option<Vec<String>>,
61    pub id: i32,
62    pub important: bool,
63    pub is_hidden: bool,
64    pub is_unavailable: bool,
65    pub out: i32,
66    pub peer_id: i32,
67    pub random_id: i32,
68    pub text: String,
69    pub version: u64,
70}
71
72#[derive(Debug, Deserialize, PartialEq)]
73pub struct Attachments {
74    photo: Option<Vec<Attachment>>,
75    video: Option<Vec<Attachment>>,
76    #[serde(rename = "type")]
77    attachment_type: String,
78}
79
80#[derive(Debug, Deserialize, PartialEq)]
81pub struct Attachment {
82    #[serde(rename = "type")]
83    pub attachment_type: String,
84    pub photo: Option<Photo>,
85    pub video: Option<Video>,
86}
87
88#[derive(Debug, Deserialize, PartialEq)]
89pub struct Photo {
90    pub access_key: String,
91    pub album_id: i32,
92    pub date: u32,
93    pub has_tags: bool,
94    pub id: i32,
95    pub owner_id: i32,
96    pub sizes: Vec<AttachmentSize>,
97    pub text: String,
98    pub web_view_token: String,
99}
100
101#[derive(Debug, Deserialize, PartialEq)]
102pub struct AttachmentSize {
103    height: usize,
104    #[serde(rename = "type")]
105    size_type: String,
106    url: String,
107    width: usize,
108}
109
110#[derive(Deserialize, Debug, PartialEq)]
111pub struct Video {
112    access_key: String,
113    can_add: i32,
114    content_restricted: i32,
115    date: i32,
116    duration: i32,
117    height: i32,
118    id: i32,
119    image: Vec<Image>,
120    is_private: i32,
121    owner_id: i32,
122    response_type: String,
123    restriction: Restriction,
124    title: String,
125    track_code: String,
126    #[serde(rename = "type")]
127    video_type: String,
128    views: i32,
129    width: i32,
130}
131
132#[derive(Deserialize, Debug, PartialEq)]
133pub struct Image {
134    height: i32,
135    url: String,
136    width: i32,
137    with_padding: i32,
138}
139
140#[derive(Deserialize, Debug, PartialEq)]
141pub struct Restriction {
142    blur: i32,
143    can_play: i32,
144    can_preview: i32,
145    card_icon: Vec<Icon>,
146    disclaimer_type: i32,
147    icon_name: String,
148    list_icon: Vec<Icon>,
149    text: String,
150    title: String,
151}
152
153#[derive(Deserialize, Debug, PartialEq)]
154pub struct Icon {
155    height: i32,
156    url: String,
157    width: i32,
158}