tgbotxx  1.1.6.9
Telegram Bot C++ Library
ChosenInlineResult.hpp
Go to the documentation of this file.
1 #pragma once
4 
5 namespace tgbotxx {
10  ChosenInlineResult() = default;
11  explicit ChosenInlineResult(const nl::json& json) {
12  fromJson(json);
13  }
14 
16  std::string resultId;
17 
20 
23 
26  std::string inlineMessageId;
27 
29  std::string query;
30 
33  nl::json toJson() const {
34  nl::json json = nl::json::object();
35  OBJECT_SERIALIZE_FIELD(json, "result_id", resultId);
36  OBJECT_SERIALIZE_FIELD_PTR(json, "from", from);
37  OBJECT_SERIALIZE_FIELD_PTR(json, "location", location);
38  OBJECT_SERIALIZE_FIELD(json, "inline_message_id", inlineMessageId);
39  OBJECT_SERIALIZE_FIELD(json, "query", query);
40  return json;
41  }
42 
44  void fromJson(const nl::json& json) {
45  OBJECT_DESERIALIZE_FIELD(json, "result_id", resultId, "", false);
46  OBJECT_DESERIALIZE_FIELD_PTR(json, "from", from, false);
47  OBJECT_DESERIALIZE_FIELD_PTR(json, "location", location, true);
48  OBJECT_DESERIALIZE_FIELD(json, "inline_message_id", inlineMessageId, "", true);
49  OBJECT_DESERIALIZE_FIELD(json, "query", query, "", false);
50  }
51  };
52 }
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition: Object.hpp:22
#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
Definition: Api.hpp:14
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
Represents a result of an inline query that was chosen by the user and sent to their chat partner....
Ptr< Location > location
Optional. Sender location, only for bots that require user location.
ChosenInlineResult(const nl::json &json)
std::string resultId
The unique identifier for the result that was chosen.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string inlineMessageId
Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attach...
nl::json toJson() const
Serializes this object to JSON.
Ptr< User > from
The user that chose the result.
std::string query
The query that was used to obtain the result.