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
use crate::Error;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct ButtonPressCallback<T> {
    /// The ID of the conversation message associated with the button press.
    pub conversation_message_id: i32,
    /// A unique identifier for this particular event occurrence.
    pub event_id: String,
    /// An object containing additional data sent with the button press.
    /// The structure of this object is defined by the button's payload.
    pub payload: T,
    /// The ID of the conversation (chat) where the button was pressed.
    pub peer_id: i32,
    /// The user ID of the user who pressed the button.
    pub user_id: i32,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct EventAnswer(i8);

impl EventAnswer {
    pub fn get_status(&self) -> crate::Result<i8> {
        let status = self.0;
        match status {
            1 => Ok(status),
            _ => Err(Error::EventAnswerUnkownStatus { status }),
        }
    }
}