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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use crate::client::Bot;
use serde::Serialize;
/// Use this method to change the bot's name. Returns `true` on success.
/// # Documentation
/// <https://core.telegram.org/bots/api#setmyname>
/// # Returns
/// - `bool`
#[derive(Clone, Debug, Serialize)]
pub struct SetMyName {
/// New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<Box<str>>,
/// A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<Box<str>>,
}
impl SetMyName {
/// Creates a new `SetMyName`.
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new() -> Self {
Self {
name: None,
language_code: None,
}
}
/// New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
#[must_use]
pub fn name<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.name = Some(val.into());
this
}
/// New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
#[must_use]
pub fn name_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.name = val.map(Into::into);
this
}
/// A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
#[must_use]
pub fn language_code<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.language_code = Some(val.into());
this
}
/// A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
#[must_use]
pub fn language_code_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.language_code = val.map(Into::into);
this
}
}
impl Default for SetMyName {
fn default() -> Self {
Self::new()
}
}
impl super::TelegramMethod for SetMyName {
type Method = Self;
type Return = bool;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("setMyName", self, None)
}
}