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
use crate::errors::Result;
use crate::types::*;
use uuid::Uuid;

/// Returns users voted for the specified option in a non-anonymous polls. For optimal performance, the number of returned users is chosen by TDLib
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetPollVoters {
    #[doc(hidden)]
    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
    extra: Option<String>,
    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
    client_id: Option<i32>,
    /// Identifier of the chat to which the poll belongs

    #[serde(default)]
    chat_id: i64,
    /// Identifier of the message containing the poll

    #[serde(default)]
    message_id: i64,
    /// 0-based identifier of the answer option

    #[serde(default)]
    option_id: i32,
    /// Number of users to skip in the result; must be non-negative

    #[serde(default)]
    offset: i32,
    /// The maximum number of users to be returned; must be positive and can't be greater than 50. For optimal performance, the number of returned users is chosen by TDLib and can be smaller than the specified limit, even if the end of the voter list has not been reached

    #[serde(default)]
    limit: i32,

    #[serde(rename(serialize = "@type"))]
    td_type: String,
}

impl RObject for GetPollVoters {
    #[doc(hidden)]
    fn extra(&self) -> Option<&str> {
        self.extra.as_deref()
    }
    #[doc(hidden)]
    fn client_id(&self) -> Option<i32> {
        self.client_id
    }
}

impl RFunction for GetPollVoters {}

impl GetPollVoters {
    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
        Ok(serde_json::from_str(json.as_ref())?)
    }
    pub fn builder() -> GetPollVotersBuilder {
        let mut inner = GetPollVoters::default();
        inner.extra = Some(Uuid::new_v4().to_string());

        inner.td_type = "getPollVoters".to_string();

        GetPollVotersBuilder { inner }
    }

    pub fn chat_id(&self) -> i64 {
        self.chat_id
    }

    pub fn message_id(&self) -> i64 {
        self.message_id
    }

    pub fn option_id(&self) -> i32 {
        self.option_id
    }

    pub fn offset(&self) -> i32 {
        self.offset
    }

    pub fn limit(&self) -> i32 {
        self.limit
    }
}

#[doc(hidden)]
pub struct GetPollVotersBuilder {
    inner: GetPollVoters,
}

#[deprecated]
pub type RTDGetPollVotersBuilder = GetPollVotersBuilder;

impl GetPollVotersBuilder {
    pub fn build(&self) -> GetPollVoters {
        self.inner.clone()
    }

    pub fn chat_id(&mut self, chat_id: i64) -> &mut Self {
        self.inner.chat_id = chat_id;
        self
    }

    pub fn message_id(&mut self, message_id: i64) -> &mut Self {
        self.inner.message_id = message_id;
        self
    }

    pub fn option_id(&mut self, option_id: i32) -> &mut Self {
        self.inner.option_id = option_id;
        self
    }

    pub fn offset(&mut self, offset: i32) -> &mut Self {
        self.inner.offset = offset;
        self
    }

    pub fn limit(&mut self, limit: i32) -> &mut Self {
        self.inner.limit = limit;
        self
    }
}

impl AsRef<GetPollVoters> for GetPollVoters {
    fn as_ref(&self) -> &GetPollVoters {
        self
    }
}

impl AsRef<GetPollVoters> for GetPollVotersBuilder {
    fn as_ref(&self) -> &GetPollVoters {
        &self.inner
    }
}