vaegram 0.3.0

Telegram MTProto client library for users and bots
Documentation
use crate::Client;
use crate::errors::Result;
use crate::methods::accepted;
use crate::raw::functions;
use crate::types::PeerRef;

impl Client {
    /// Cancels or restores a user's Stars subscription to the bot by its payment charge id.
    ///
    /// `is_canceled` false restores a canceled subscription.
    pub async fn edit_user_star_subscription(
        &self,
        user_id: impl Into<PeerRef>,
        telegram_payment_charge_id: &str,
        is_canceled: bool,
    ) -> Result<()> {
        let request = functions::payments::BotCancelStarsSubscription {
            restore: !is_canceled,
            user_id: self.resolve_user(&user_id.into()).await?,
            charge_id: telegram_payment_charge_id.into(),
        };
        accepted(self.invoke(&request).await?)
    }
}