Skip to content

Commit

Permalink
refactor!: use MessageOrBool over EditMessageResponse (#212)
Browse files Browse the repository at this point in the history
* refactor!: use MessageOrBool over EditMessageResponse

BREAKING CHANGE: EditMessageResponse is gone

* fixup! refactor!: use MessageOrBool over EditMessageResponse
  • Loading branch information
EdJoPaTo authored Sep 14, 2024
1 parent a708573 commit d20ad40
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct ErrorResponse {

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum EditMessageResponse {
Message(MethodResponse<Message>),
Bool(MethodResponse<bool>),
pub enum MessageOrBool {
Message(Message),
Bool(bool),
}
16 changes: 8 additions & 8 deletions src/trait_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ use crate::objects::User;
use crate::objects::UserChatBoosts;
use crate::objects::UserProfilePhotos;
use crate::objects::WebhookInfo;
use crate::response::{EditMessageResponse, MethodResponse};
use crate::response::{MessageOrBool, MethodResponse};
use async_trait::async_trait;
use std::path::PathBuf;

Expand Down Expand Up @@ -477,14 +477,14 @@ pub trait AsyncTelegramApi {
async fn edit_message_live_location(
&self,
params: &EditMessageLiveLocationParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageLiveLocation", Some(params)).await
}

async fn stop_message_live_location(
&self,
params: &StopMessageLiveLocationParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("stopMessageLiveLocation", Some(params)).await
}

Expand Down Expand Up @@ -938,21 +938,21 @@ pub trait AsyncTelegramApi {
async fn edit_message_text(
&self,
params: &EditMessageTextParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageText", Some(params)).await
}

async fn edit_message_caption(
&self,
params: &EditMessageCaptionParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageCaption", Some(params)).await
}

async fn edit_message_media(
&self,
params: &EditMessageMediaParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
let method_name = "editMessageMedia";
let mut files: Vec<(String, PathBuf)> = vec![];

Expand Down Expand Up @@ -1080,7 +1080,7 @@ pub trait AsyncTelegramApi {
async fn edit_message_reply_markup(
&self,
params: &EditMessageReplyMarkupParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageReplyMarkup", Some(params)).await
}

Expand Down Expand Up @@ -1330,7 +1330,7 @@ pub trait AsyncTelegramApi {
async fn set_game_score(
&self,
params: &SetGameScoreParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("setGameScore", Some(params)).await
}

Expand Down
16 changes: 8 additions & 8 deletions src/trait_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ use crate::objects::User;
use crate::objects::UserChatBoosts;
use crate::objects::UserProfilePhotos;
use crate::objects::WebhookInfo;
use crate::response::{EditMessageResponse, MethodResponse};
use crate::response::{MessageOrBool, MethodResponse};
use std::path::PathBuf;

pub trait TelegramApi {
Expand Down Expand Up @@ -452,14 +452,14 @@ pub trait TelegramApi {
fn edit_message_live_location(
&self,
params: &EditMessageLiveLocationParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageLiveLocation", Some(params))
}

fn stop_message_live_location(
&self,
params: &StopMessageLiveLocationParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("stopMessageLiveLocation", Some(params))
}

Expand Down Expand Up @@ -888,21 +888,21 @@ pub trait TelegramApi {
fn edit_message_text(
&self,
params: &EditMessageTextParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageText", Some(params))
}

fn edit_message_caption(
&self,
params: &EditMessageCaptionParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageCaption", Some(params))
}

fn edit_message_media(
&self,
params: &EditMessageMediaParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
let method_name = "editMessageMedia";
let mut files: Vec<(String, PathBuf)> = vec![];

Expand Down Expand Up @@ -1029,7 +1029,7 @@ pub trait TelegramApi {
fn edit_message_reply_markup(
&self,
params: &EditMessageReplyMarkupParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("editMessageReplyMarkup", Some(params))
}

Expand Down Expand Up @@ -1268,7 +1268,7 @@ pub trait TelegramApi {
fn set_game_score(
&self,
params: &SetGameScoreParams,
) -> Result<EditMessageResponse, Self::Error> {
) -> Result<MethodResponse<MessageOrBool>, Self::Error> {
self.request("setGameScore", Some(params))
}

Expand Down

0 comments on commit d20ad40

Please sign in to comment.