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
75
76
77
78
79
80
use serde::{Deserialize, Serialize};
/// This object describes the rating of a user based on their Telegram Star spendings.
/// # Documentation
/// <https://core.telegram.org/bots/api#userrating>
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UserRating {
/// Current level of the user, indicating their reliability when purchasing digital goods and services. A higher level suggests a more trustworthy customer; a negative level is likely reason for concern.
pub level: i64,
/// Numerical value of the user's rating; the higher the rating, the better
pub rating: i64,
/// The rating value required to get the current level
pub current_level_rating: i64,
/// The rating value required to get to the next level; omitted if the maximum level was reached
#[serde(skip_serializing_if = "Option::is_none")]
pub next_level_rating: Option<i64>,
}
impl UserRating {
/// Creates a new `UserRating`.
///
/// # Arguments
/// * `level` - Current level of the user, indicating their reliability when purchasing digital goods and services. A higher level suggests a more trustworthy customer; a negative level is likely reason for concern.
/// * `rating` - Numerical value of the user's rating; the higher the rating, the better
/// * `current_level_rating` - The rating value required to get the current level
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<i64>, T1: Into<i64>, T2: Into<i64>>(
level: T0,
rating: T1,
current_level_rating: T2,
) -> Self {
Self {
level: level.into(),
rating: rating.into(),
current_level_rating: current_level_rating.into(),
next_level_rating: None,
}
}
/// Current level of the user, indicating their reliability when purchasing digital goods and services. A higher level suggests a more trustworthy customer; a negative level is likely reason for concern.
#[must_use]
pub fn level<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.level = val.into();
this
}
/// Numerical value of the user's rating; the higher the rating, the better
#[must_use]
pub fn rating<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.rating = val.into();
this
}
/// The rating value required to get the current level
#[must_use]
pub fn current_level_rating<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.current_level_rating = val.into();
this
}
/// The rating value required to get to the next level; omitted if the maximum level was reached
#[must_use]
pub fn next_level_rating<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.next_level_rating = Some(val.into());
this
}
/// The rating value required to get to the next level; omitted if the maximum level was reached
#[must_use]
pub fn next_level_rating_option<T: Into<i64>>(self, val: Option<T>) -> Self {
let mut this = self;
this.next_level_rating = val.map(Into::into);
this
}
}