yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
sendVideo.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <optional>
4 #include "methods/sendVideo.h"
5 
6 using namespace std;
7 using namespace yatbcpp;
8 
10 // Constructor Section //
12 
13 sendVideo::sendVideo(Chat C, string video) :
14  telegram_methodJSON("sendVideo"), telegram_methodMultipart("sendVideo"),
15  chat_id(to_string(C.getId())), video(move(video))
16 {
17 
18 }
19 
20 sendVideo::sendVideo(int64_t chat_id, string video) :
21  telegram_methodJSON("sendVideo"), telegram_methodMultipart("sendVideo"),
22  chat_id(to_string(chat_id)), video(move(video))
23 {
24 
25 }
26 
27 sendVideo::sendVideo(string chat_id, string video) :
28  telegram_methodJSON("sendVideo"), telegram_methodMultipart("sendVideo"),
29  chat_id(move(chat_id)), video(move(video))
30 {
31 
32 }
33 
35 // Outgoing Section //
37 
38 
39 Json::Value sendVideo::toJson() {
40  Json::Value Outgoing;
41  Outgoing["chat_id"] = getChat_id();
42  Outgoing["video"] = getVideo();
43 
44  if(getCaption()){
45  Outgoing["caption"] = getCaption().value();
46  }
47  if(getDuration()){
48  Outgoing["duration"] = getDuration().value();
49  }
50  if(getWidth()){
51  Outgoing["width"] = getWidth().value();
52  }
53  if(getHeight()){
54  Outgoing["height"] = getHeight().value();
55  }
57  Outgoing["disable_notification"] = getDisable_notification().value();
58  }
60  Outgoing["reply_to_message_id"] = getReply_to_message_id().value();
61  }
62 
63  return Outgoing;
64 
65 }
66 
67 void sendVideo::add_to_post(struct curl_httppost **start, struct curl_httppost **end) {
68  curl_formadd(start,end,
69  CURLFORM_COPYNAME,"chat_id",
70  CURLFORM_COPYCONTENTS,chat_id.c_str(),
71  CURLFORM_END);
72  curl_formadd(start,end,
73  CURLFORM_COPYNAME,"video",
74  CURLFORM_FILE,video.c_str(),
75  CURLFORM_END);
76  if(caption){
77  curl_formadd(start,end,
78  CURLFORM_COPYNAME,"caption",
79  CURLFORM_COPYCONTENTS,caption.value().c_str(),
80  CURLFORM_END);
81  }
82 }
83 
85 // Setter Section //
87 
88 void sendVideo::setCaption(const optional<string> &caption) {
90 }
91 
92 
93 void sendVideo::setDuration(const optional<unsigned int> &duration) {
94  sendVideo::duration = duration;
95 }
96 
97 void sendVideo::setWidth(const optional<unsigned int> &width) {
98  sendVideo::width = width;
99 }
100 
101 void sendVideo::setHeight(const optional<unsigned int> &height) {
102  sendVideo::height = height;
103 }
104 
107 }
108 
111 }
112 
119 }
120 
127 }
128 
135 }
136 
138 // Getter Section //
140 
141 const string &sendVideo::getChat_id() const {
142  return chat_id;
143 }
144 
145 const string &sendVideo::getVideo() const {
146  return video;
147 }
148 
149 const optional<string> &sendVideo::getCaption() const {
150  return caption;
151 }
152 
153 const optional<unsigned int> &sendVideo::getDuration() const {
154  return duration;
155 }
156 
157 const optional<unsigned int> &sendVideo::getWidth() const {
158  return width;
159 }
160 
161 const optional<unsigned int> &sendVideo::getHeight() const {
162  return height;
163 }
164 
165 const optional<bool> &sendVideo::getDisable_notification() const {
166  return disable_notification;
167 }
168 
169 const optional<int32_t> &sendVideo::getReply_to_message_id() const {
170  return reply_to_message_id;
171 }
172 
173 const optional<ReplyMarkup> &sendVideo::getReply_markup() const {
174  return reply_markup;
175 }
std::optional< bool > disable_notification
Definition: sendVideo.h:90
const std::optional< std::int32_t > & getReply_to_message_id() const
Definition: sendVideo.cc:169
void setDuration(const std::optional< unsigned int > &duration)
Definition: sendVideo.cc:93
const std::string & getChat_id() const
Definition: sendPhoto.cc:133
const std::optional< std::string > & getCaption() const
Definition: sendVideo.cc:149
std::optional< bool > disable_notification
Definition: sendPhoto.h:75
const std::optional< unsigned int > & getHeight() const
Definition: sendVideo.cc:161
void setDisable_notification(const std::optional< bool > &disable_notification)
Definition: sendVideo.cc:105
void setWidth(const std::optional< unsigned int > &width)
Definition: sendVideo.cc:97
std::optional< std::string > caption
Definition: sendVideo.h:86
const std::string & getChat_id() const
Definition: sendVideo.cc:141
std::optional< unsigned int > height
Definition: sendVideo.h:89
const std::optional< unsigned int > & getWidth() const
Definition: sendVideo.cc:157
Json::Value toJson()
Definition: sendVideo.cc:39
void setCaption(const std::optional< std::string > &caption)
Definition: sendVideo.cc:88
const std::optional< ReplyMarkup > & getReply_markup() const
Definition: sendVideo.cc:173
Definition: Bot.h:27
const std::optional< bool > & getDisable_notification() const
Definition: sendVideo.cc:165
std::string chat_id
Definition: sendPhoto.h:71
void add_to_post(struct curl_httppost **start, struct curl_httppost **end)
Definition: sendVideo.cc:67
std::optional< ReplyMarkup > reply_markup
Definition: sendVideo.h:92
const std::optional< bool > & getDisable_notification() const
Definition: sendPhoto.cc:146
std::optional< std::string > caption
Definition: sendPhoto.h:73
void setReplyMarkup(const ReplyKeyboardMarkup RKM)
Definition: sendVideo.cc:117
std::optional< ReplyMarkup > reply_markup
Definition: sendPhoto.h:77
const std::optional< std::string > & getCaption() const
Definition: sendPhoto.cc:141
const std::optional< unsigned int > & getDuration() const
Definition: sendVideo.cc:153
sendVideo(std::int64_t chat_id, std::string video)
const std::string & getVideo() const
Definition: sendVideo.cc:145
const std::optional< std::int32_t > & getReply_to_message_id() const
Definition: sendPhoto.cc:150
std::optional< unsigned int > width
Definition: sendVideo.h:88
void setReply_to_message_id(const std::optional< int > &reply_to_message_id)
Definition: sendVideo.cc:109
std::optional< unsigned int > duration
Definition: sendVideo.h:87
void setHeight(const std::optional< unsigned int > &height)
Definition: sendVideo.cc:101
std::optional< std::int32_t > reply_to_message_id
Definition: sendPhoto.h:76
std::optional< std::int32_t > reply_to_message_id
Definition: sendVideo.h:91