tgbotxx 1.2.9.5
Telegram Bot C++ Library
Loading...
Searching...
No Matches
UserRating.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
7 struct UserRating {
8 UserRating() = default;
9 explicit UserRating(const nl::json& json);
10
13 std::int32_t level{};
14
16 std::int32_t rating{};
17
19 std::int32_t currentLevelRating{};
20
22 std::int32_t nextLevelRating{};
23
24
27 nl::json toJson() const {
28 nl::json json = nl::json::object();
31 OBJECT_SERIALIZE_FIELD(json, "current_level_rating", currentLevelRating);
32 OBJECT_SERIALIZE_FIELD(json, "next_level_rating", nextLevelRating);
33 return json;
34 }
35
37 void fromJson(const nl::json& json) {
38 OBJECT_DESERIALIZE_FIELD(json, "level", level, 0, false);
39 OBJECT_DESERIALIZE_FIELD(json, "rating", rating, 0, false);
40 OBJECT_DESERIALIZE_FIELD(json, "current_level_rating", currentLevelRating, 0, false);
41 OBJECT_DESERIALIZE_FIELD(json, "next_level_rating", nextLevelRating, 0, true);
42 }
43 };
44}
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Serialize.
Definition Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:64
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object describes the rating of a user based on their Telegram Star spendings....
Definition UserRating.hpp:7
UserRating(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::int32_t level
Current level of the user, indicating their reliability when purchasing digital goods and services....
nl::json toJson() const
Serializes this object to JSON.
std::int32_t rating
Numerical value of the user's rating; the higher the rating, the better.
std::int32_t currentLevelRating
The rating value required to get the current level.
std::int32_t nextLevelRating
Optional. The rating value required to get to the next level; omitted if the maximum level was reache...