1 //
2 // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 #pragma once
8 
9 #include "td/telegram/Location.h"
10 #include "td/telegram/SecretInputMedia.h"
11 #include "td/telegram/td_api.h"
12 #include "td/telegram/telegram_api.h"
13 #include "td/telegram/Version.h"
14 
15 #include "td/utils/common.h"
16 #include "td/utils/Status.h"
17 #include "td/utils/StringBuilder.h"
18 #include "td/utils/tl_helpers.h"
19 
20 namespace td {
21 
22 class Venue {
23   Location location_;
24   string title_;
25   string address_;
26   string provider_;
27   string id_;
28   string type_;
29 
30   friend bool operator==(const Venue &lhs, const Venue &rhs);
31   friend bool operator!=(const Venue &lhs, const Venue &rhs);
32 
33   friend StringBuilder &operator<<(StringBuilder &string_builder, const Venue &venue);
34 
35  public:
36   Venue() = default;
37 
38   Venue(const tl_object_ptr<telegram_api::GeoPoint> &geo_point_ptr, string title, string address, string provider,
39         string id, string type);
40 
41   Venue(Location location, string title, string address, string provider, string id, string type);
42 
43   explicit Venue(const tl_object_ptr<td_api::venue> &venue);
44 
45   bool empty() const;
46 
47   Location &location();
48 
49   const Location &location() const;
50 
51   tl_object_ptr<td_api::venue> get_venue_object() const;
52 
53   tl_object_ptr<telegram_api::inputMediaVenue> get_input_media_venue() const;
54 
55   SecretInputMedia get_secret_input_media_venue() const;
56 
57   tl_object_ptr<telegram_api::inputBotInlineMessageMediaVenue> get_input_bot_inline_message_media_venue(
58       tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const;
59 
60   template <class StorerT>
store(StorerT & storer)61   void store(StorerT &storer) const {
62     using td::store;
63     store(location_, storer);
64     store(title_, storer);
65     store(address_, storer);
66     store(provider_, storer);
67     store(id_, storer);
68     store(type_, storer);
69   }
70 
71   template <class ParserT>
parse(ParserT & parser)72   void parse(ParserT &parser) {
73     using td::parse;
74     parse(location_, parser);
75     parse(title_, parser);
76     parse(address_, parser);
77     parse(provider_, parser);
78     parse(id_, parser);
79     if (parser.version() >= static_cast<int32>(Version::AddVenueType)) {
80       parse(type_, parser);
81     }
82   }
83 };
84 
85 bool operator==(const Venue &lhs, const Venue &rhs);
86 bool operator!=(const Venue &lhs, const Venue &rhs);
87 
88 StringBuilder &operator<<(StringBuilder &string_builder, const Venue &venue);
89 
90 Result<Venue> process_input_message_venue(td_api::object_ptr<td_api::InputMessageContent> &&input_message_content)
91     TD_WARN_UNUSED_RESULT;
92 
93 }  // namespace td
94