tgbotxx  1.1.6.9
Telegram Bot C++ Library
StickerSet.hpp
Go to the documentation of this file.
1 #pragma once
5 
6 namespace tgbotxx {
9  struct StickerSet {
10  StickerSet() = default;
11  explicit StickerSet(const nl::json& json) {
12  fromJson(json);
13  }
14 
16  std::string name;
17 
19  std::string title;
20 
23 
25  bool isAnimated{};
26 
28  bool isVideo{};
29 
31  std::vector<Ptr<Sticker>> stickers;
32 
35 
38  nl::json toJson() const {
39  nl::json json = nl::json::object();
40  OBJECT_SERIALIZE_FIELD(json, "name", name);
41  OBJECT_SERIALIZE_FIELD(json, "title", title);
42  json["type"] = Sticker::Type2Str[static_cast<std::size_t>(type)]; // enum
43  OBJECT_SERIALIZE_FIELD(json, "is_animated", isAnimated);
44  OBJECT_SERIALIZE_FIELD(json, "is_video", isVideo);
45  OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "stickers", stickers);
46  OBJECT_SERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail);
47  return json;
48  }
49 
51  void fromJson(const nl::json& json) {
52  OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
53  OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
54  type = Sticker::Str2Type(json["type"]); // enum
55  OBJECT_DESERIALIZE_FIELD(json, "is_animated", isAnimated, false, false);
56  OBJECT_DESERIALIZE_FIELD(json, "is_video", isVideo, false, false);
57  OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "stickers", stickers, false);
58  OBJECT_DESERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail, true);
59  }
60  };
61 }
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition: Object.hpp:22
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition: Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition: Object.hpp:70
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition: Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition: Object.hpp:44
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition: Object.hpp:87
Definition: Api.hpp:14
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
static constexpr const char * Type2Str[]
Definition: Sticker.hpp:29
Type
Enum of possible types of a Sticker.
Definition: Sticker.hpp:24
static constexpr Type Str2Type(const std::string &str)
Definition: Sticker.hpp:30
This object represents a sticker set. https://core.telegram.org/bots/api#stickerset.
Definition: StickerSet.hpp:9
Ptr< PhotoSize > thumbnail
Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format.
Definition: StickerSet.hpp:34
std::string title
Sticker set title.
Definition: StickerSet.hpp:19
StickerSet(const nl::json &json)
Definition: StickerSet.hpp:11
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: StickerSet.hpp:51
bool isVideo
True, if the sticker set contains video stickers
Definition: StickerSet.hpp:28
std::string name
Sticker set name.
Definition: StickerSet.hpp:16
Sticker::Type type
Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
Definition: StickerSet.hpp:22
bool isAnimated
True, if the sticker set contains animated stickers
Definition: StickerSet.hpp:25
nl::json toJson() const
Serializes this object to JSON.
Definition: StickerSet.hpp:38
std::vector< Ptr< Sticker > > stickers
List of all set stickers.
Definition: StickerSet.hpp:31