diff --git a/CHANGELOG.md b/CHANGELOG.md index ab2c37d5..707bf546 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Now Vec in requests serializes into [number] instead of [ {message_id: number} ], `forward_messages`, `copy_messages` and `delete_messages` now work properly +- Now `InlineQueryResultsButton` serializes properly ([issue 1181](https://github.com/teloxide/teloxide/issues/1181)) ## 0.13.0 - 2024-08-16 diff --git a/crates/teloxide-core/src/types/inline_query_results_button.rs b/crates/teloxide-core/src/types/inline_query_results_button.rs index 3219dd0d..d0c5ecec 100644 --- a/crates/teloxide-core/src/types/inline_query_results_button.rs +++ b/crates/teloxide-core/src/types/inline_query_results_button.rs @@ -17,6 +17,7 @@ pub struct InlineQueryResultsButton { } #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] pub enum InlineQueryResultsButtonKind { /// Description of the [Web App] that will be launched when the user presses /// the button. The Web App will be able to switch back to the inline mode @@ -44,3 +45,19 @@ pub enum InlineQueryResultsButtonKind { /// [switch_inline]: https://core.telegram.org/bots/api#inlinekeyboardmarkup StartParameter(String), } + +#[cfg(test)] +mod tests { + use crate::types::{InlineQueryResultsButton, InlineQueryResultsButtonKind}; + + #[test] + fn inline_query_results_button() { + let button = InlineQueryResultsButton { + text: "test".into(), + kind: InlineQueryResultsButtonKind::StartParameter("bot".into()), + }; + let expected = r#"{"text":"test","start_parameter":"bot"}"#; + let actual = serde_json::to_string(&button).unwrap(); + assert_eq!(expected, actual); + } +}