yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
sendDocument.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <optional>
4 #include "methods/sendDocument.h"
5 
6 using namespace std;
7 using namespace yatbcpp;
8 
10 // Constructor Section //
12 
13 sendDocument::sendDocument(Chat C, string Document) :
14  telegram_methodJSON("sendDocument"), telegram_methodMultipart("sendDocument"),
15  chat_id(to_string(C.getId())), document(move(Document))
16 {
17 
18 }
19 
21  telegram_methodJSON("sendDocument"), telegram_methodMultipart("sendDocument"),
22  chat_id(to_string(chat_id)), document(move(Document))
23 {
24 
25 }
26 
28  telegram_methodJSON("sendDocument"), telegram_methodMultipart("sendDocument"),
29  chat_id(move(chat_id)), document(move(Document))
30 {
31 
32 }
33 
35 // Outgoing Section //
37 
38 
39 Json::Value sendDocument::toJson() {
40  Json::Value Outgoing;
41  Outgoing["chat_id"] = getChat_id();
42  Outgoing["document"] = getDocument();
43 
44  if(getCaption()){
45  Outgoing["caption"] = getCaption().value();
46  }
48  Outgoing["disable_notification"] = getDisable_notification().value();
49  }
51  Outgoing["reply_to_message_id"] = getReply_to_message_id().value();
52  }
53 
54  return Outgoing;
55 
56 }
57 
58 void sendDocument::add_to_post(struct curl_httppost **start, struct curl_httppost **end) {
59  curl_formadd(start,end,
60  CURLFORM_COPYNAME,"chat_id",
61  CURLFORM_COPYCONTENTS,chat_id.c_str(),
62  CURLFORM_END);
63  curl_formadd(start,end,
64  CURLFORM_COPYNAME,"document",
65  CURLFORM_FILE,document.c_str(),
66  CURLFORM_END);
67  if(caption){
68  curl_formadd(start,end,
69  CURLFORM_COPYNAME,"caption",
70  CURLFORM_COPYCONTENTS,caption.value().c_str(),
71  CURLFORM_END);
72  }
73 }
74 
76 // Setter Section //
78 
79 void sendDocument::setCaption(const optional<string> &caption) {
81 }
82 
83 
86 }
87 
90 }
91 
98 }
99 
106 }
107 
114 }
115 
117 // Getter Section //
119 
120 const string &sendDocument::getChat_id() const {
121  return chat_id;
122 }
123 
124 const string &sendDocument::getDocument() const {
125  return document;
126 }
127 
128 const optional<string> &sendDocument::getCaption() const {
129  return caption;
130 }
131 
132 const optional<bool> &sendDocument::getDisable_notification() const {
133  return disable_notification;
134 }
135 
136 const optional<int32_t > &sendDocument::getReply_to_message_id() const {
137  return reply_to_message_id;
138 }
139 
140 const optional<ReplyMarkup> &sendDocument::getReply_markup() const {
141  return reply_markup;
142 }
const std::optional< std::string > & getCaption() const
Definition: sendAudio.cc:150
const std::optional< bool > & getDisable_notification() const
void setCaption(const std::optional< std::string > &caption)
Definition: sendDocument.cc:79
std::optional< bool > disable_notification
Definition: sendDocument.h:75
std::optional< std::string > caption
Definition: sendDocument.h:74
void add_to_post(struct curl_httppost **start, struct curl_httppost **end)
Definition: sendDocument.cc:58
const std::optional< std::int32_t > & getReply_to_message_id() const
std::string chat_id
Definition: sendAudio.h:84
const std::string & getChat_id() const
Definition: sendAudio.cc:142
Json::Value toJson()
Definition: sendDocument.cc:39
const std::optional< ReplyMarkup > & getReply_markup() const
Definition: Bot.h:27
const std::string & getDocument() const
void setReplyMarkup(const ReplyKeyboardMarkup RKM)
Definition: sendDocument.cc:96
std::optional< bool > disable_notification
Definition: sendAudio.h:90
std::optional< ReplyMarkup > reply_markup
Definition: sendAudio.h:92
const std::optional< std::string > & getCaption() const
const std::optional< std::int32_t > & getReply_to_message_id() const
Definition: sendAudio.cc:170
const std::string & getChat_id() const
sendDocument(std::int64_t chat_id, std::string document)
std::optional< std::int32_t > reply_to_message_id
Definition: sendAudio.h:91
const std::optional< bool > & getDisable_notification() const
Definition: sendAudio.cc:166
void setDisable_notification(const std::optional< bool > &disable_notification)
Definition: sendDocument.cc:84
void setReply_to_message_id(const std::optional< int > &reply_to_message_id)
Definition: sendDocument.cc:88
std::optional< ReplyMarkup > reply_markup
Definition: sendDocument.h:77
std::optional< std::string > caption
Definition: sendAudio.h:86
std::optional< std::int32_t > reply_to_message_id
Definition: sendDocument.h:76