diff --git a/src/types/keyboard_button.rs b/src/types/keyboard_button.rs index 2cefc957..aef83a28 100644 --- a/src/types/keyboard_button.rs +++ b/src/types/keyboard_button.rs @@ -49,7 +49,7 @@ impl KeyboardButton { pub enum ButtonRequest { Location, Contact, - KeyboardButtonPollType(KeyboardButtonPollType), + Poll(KeyboardButtonPollType), } /// Helper struct for (de)serializing [`ButtonRequest`](ButtonRequest) @@ -97,7 +97,7 @@ impl<'de> Deserialize<'de> for ButtonRequest { RawRequest { poll: Some(poll_type), .. - } => Ok(Self::KeyboardButtonPollType(poll_type)), + } => Ok(Self::Poll(poll_type)), _ => Err(D::Error::custom( "Either one of `request_contact` and `request_location` fields is required", )), @@ -123,7 +123,7 @@ impl Serialize for ButtonRequest { poll: None, } .serialize(serializer), - Self::KeyboardButtonPollType(poll_type) => RawRequest { + Self::Poll(poll_type) => RawRequest { contact: None, location: None, poll: Some(poll_type.clone()), diff --git a/src/types/keyboard_button_poll_type.rs b/src/types/keyboard_button_poll_type.rs index 07c7ddc6..6994fa72 100644 --- a/src/types/keyboard_button_poll_type.rs +++ b/src/types/keyboard_button_poll_type.rs @@ -1,25 +1,18 @@ use serde::{Deserialize, Serialize}; +/// This object represents type of a poll, which is allowed to be created and +/// sent when the corresponding button is pressed. #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] -pub struct KeyboardButtonPollType { - poll_type: String, -} - -impl KeyboardButtonPollType { - pub fn new(poll_type: S) -> Self - where - S: Into, - { - Self { - poll_type: poll_type.into(), - } - } - - pub fn poll_type(mut self, val: S) -> Self - where - S: Into, - { - self.poll_type = val.into(); - self - } +#[serde(rename_all = "snake_case")] +#[serde(tag = "type")] +pub enum KeyboardButtonPollType { + /// If [`Quiz`] is passed, the user will be allowed to create only polls in + /// the quiz mode. + Quiz, + /// If [`Regular`] is passed, only regular polls will be allowed. + Regular, + /// If [`Any`] is passed, the user will be allowed to create a poll of any + /// type. + #[serde(rename = "")] + Any, }