tgbotxx  1.1.6.9
Telegram Bot C++ Library
InlineQuery.hpp
Go to the documentation of this file.
1 #pragma once
5 
6 namespace tgbotxx {
10  struct InlineQuery {
11  InlineQuery() = default;
12  explicit InlineQuery(const nl::json& json) {
13  fromJson(json);
14  }
15 
17  std::string id;
18 
21 
23  std::string query;
24 
26  std::string offset;
27 
31  std::string chatType;
32 
35 
38  nl::json toJson() const {
39  nl::json json = nl::json::object();
40  OBJECT_SERIALIZE_FIELD(json, "id", id);
41  OBJECT_SERIALIZE_FIELD_PTR(json, "from", from);
42  OBJECT_SERIALIZE_FIELD(json, "query", query);
43  OBJECT_SERIALIZE_FIELD(json, "offset", offset);
44  OBJECT_SERIALIZE_FIELD(json, "chat_type", chatType);
45  OBJECT_SERIALIZE_FIELD_PTR(json, "location", location);
46  return json;
47  }
48 
50  void fromJson(const nl::json& json) {
51  OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
52  OBJECT_DESERIALIZE_FIELD_PTR(json, "from", from, false);
53  OBJECT_DESERIALIZE_FIELD(json, "query", query, "", false);
54  OBJECT_DESERIALIZE_FIELD(json, "offset", offset, "", false);
55  OBJECT_DESERIALIZE_FIELD(json, "chat_type", chatType, "", true);
56  OBJECT_DESERIALIZE_FIELD_PTR(json, "location", location, true);
57  }
58  };
59 }
#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
This object represents an incoming inline query. When the user sends an empty query,...
Definition: InlineQuery.hpp:10
nl::json toJson() const
Serializes this object to JSON.
Definition: InlineQuery.hpp:38
std::string offset
Offset of the results to be returned, can be controlled by the bot.
Definition: InlineQuery.hpp:26
std::string query
Text of the query (up to 256 characters)
Definition: InlineQuery.hpp:23
InlineQuery(const nl::json &json)
Definition: InlineQuery.hpp:12
Ptr< Location > location
Optional. Sender location, only for bots that request user location.
Definition: InlineQuery.hpp:34
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: InlineQuery.hpp:50
Ptr< User > from
Sender.
Definition: InlineQuery.hpp:20
std::string chatType
Optional. Type of the chat, from which the inline query was sent. Can be either “sender” for a privat...
Definition: InlineQuery.hpp:31
std::string id
Unique identifier for this query.
Definition: InlineQuery.hpp:17