tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
InputProfilePhoto.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
5
9 InputProfilePhoto() = default;
10 explicit InputProfilePhoto(const nl::json& json) {
11 _fromJson(json);
12 }
13 virtual ~InputProfilePhoto() = default;
14
16 std::string type;
17
18 virtual nl::json toJson() const {
19 nl::json json = nl::json::object();
20 OBJECT_SERIALIZE_FIELD(json, "type", type);
21 return json;
22 }
23
24 virtual void fromJson(const nl::json& json) {
25 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
26 }
27
28 private:
29 void _fromJson(const nl::json& json) {
30 fromJson(json);
31 }
32 };
33
40 explicit InputProfilePhotoStatic(const nl::json& json) : InputProfilePhoto(json) {
41 InputProfilePhoto::type = "static";
42 }
43
46 std::string photo;
47
50 nl::json toJson() const override {
51 nl::json json = InputProfilePhoto::toJson();
52 OBJECT_SERIALIZE_FIELD(json, "photo", photo);
53 return json;
54 }
55
57 void fromJson(const nl::json& json) override {
59 OBJECT_DESERIALIZE_FIELD(json, "photo", photo, "", false);
60 }
61 };
62
69 explicit InputProfilePhotoAnimated(const nl::json& json) : InputProfilePhoto(json) {
70 InputProfilePhoto::type = "animated";
71 }
72
75 std::string animation;
76
78 double mainFrameTimestamp{0.0};
79
82 nl::json toJson() const override {
83 nl::json json = InputProfilePhoto::toJson();
84 OBJECT_SERIALIZE_FIELD(json, "animation", animation);
85 OBJECT_SERIALIZE_FIELD(json, "main_frame_timestamp", mainFrameTimestamp);
86 return json;
87 }
88
90 void fromJson(const nl::json& json) override {
92 OBJECT_DESERIALIZE_FIELD(json, "animation", animation, "", false);
93 OBJECT_DESERIALIZE_FIELD(json, "main_frame_timestamp", mainFrameTimestamp, 0.0, true);
94 }
95 };
96
97}
#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:46
An animated profile photo in the MPEG4 format https://core.telegram.org/bots/api#inputprofilephotoani...
nl::json toJson() const override
Serializes this object to JSON.
InputProfilePhotoAnimated(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
double mainFrameTimestamp
Optional. Timestamp in seconds of the frame that will be used as the static profile photo....
std::string animation
The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file,...
Base class for profile photos to set https://core.telegram.org/bots/api#inputprofilephoto.
std::string type
Type of the profile photo.
virtual ~InputProfilePhoto()=default
InputProfilePhoto(const nl::json &json)
virtual nl::json toJson() const
virtual void fromJson(const nl::json &json)
A static profile photo in the .JPG format https://core.telegram.org/bots/api#inputprofilephotostatic.
std::string photo
The static profile photo. Profile photos can't be reused and can only be uploaded as a new file,...
nl::json toJson() const override
Serializes this object to JSON.
InputProfilePhotoStatic(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.