vaegram 0.3.0

Telegram MTProto client library for users and bots
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::Client;
use crate::errors::Result;
use crate::raw::functions;

use super::check_gift_code::gift_code_slug;

impl Client {
    /// Redeems a gift code for Premium on the current account.
    ///
    /// `slug` is a bare slug or a `t.me/giftcode/...` or `tg://giftcode?slug=...` link. Fails with
    /// `Error::InvalidArgument` if no slug can be read from it.
    pub async fn apply_gift_code(&self, slug: &str) -> Result<()> {
        self.invoke(&functions::payments::ApplyGiftCode { slug: gift_code_slug(slug)?.into() }).await.map(drop)
    }
}