1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use super::base::{Request, TelegramMethod};

use crate::{client::Bot, types::BotName};

use serde::Serialize;
use serde_with::skip_serializing_none;

/// Use this method to get the current bot name for the given user language.
/// # Documentation
/// <https://core.telegram.org/bots/api#getmyname>
/// # Returns
/// Returns [`BotName`] on success
#[skip_serializing_none]
#[derive(Debug, Default, Clone, Hash, PartialEq, Eq, Serialize)]
pub struct GetMyName {
    /// A two-letter ISO 639-1 language code or an empty string
    pub language_code: Option<String>,
}

impl GetMyName {
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    #[must_use]
    pub fn language_code(self, val: impl Into<String>) -> Self {
        Self {
            language_code: Some(val.into()),
        }
    }
}

impl GetMyName {
    #[must_use]
    pub fn language_code_option(self, val: Option<impl Into<String>>) -> Self {
        Self {
            language_code: val.map(Into::into),
        }
    }
}

impl TelegramMethod for GetMyName {
    type Method = Self;
    type Return = BotName;

    fn build_request<Client>(&self, _bot: &Bot<Client>) -> Request<Self::Method> {
        Request::new("getMyName", self, None)
    }
}

impl AsRef<GetMyName> for GetMyName {
    fn as_ref(&self) -> &Self {
        self
    }
}