yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
sendPhoto.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <optional>
4 #include <iostream>
5 #include "methods/sendPhoto.h"
6 
7 using namespace std;
8 using namespace yatbcpp;
9 
11 // Constructor Section //
13 
14 sendPhoto::sendPhoto(Chat C, string photo) :
15  telegram_methodJSON("sendPhoto"), telegram_methodMultipart("sendPhoto"),
16  chat_id(to_string(C.getId())), Photo(move(photo))
17 {
18 
19 }
20 
21 sendPhoto::sendPhoto(int64_t chat_id, string photo) :
22  telegram_methodJSON("sendPhoto"), telegram_methodMultipart("sendPhoto"),
23  chat_id(to_string(chat_id)), Photo(move(photo))
24 {
25 
26 }
27 
28 sendPhoto::sendPhoto(string chat_id, string photo) :
29  telegram_methodJSON("sendPhoto"), telegram_methodMultipart("sendPhoto"),
30  chat_id(move(chat_id)), Photo(move(photo))
31 {
32 
33 }
34 
36 // Outgoing Section //
38 
39 Json::Value sendPhoto::toJson() {
40  Json::Value Outgoing;
41  Outgoing["chat_id"] = getChat_id();
42  Outgoing["photo"] = getPhoto();
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 sendPhoto::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,"photo",
65  CURLFORM_FILE,Photo.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  if(disable_notification.value_or(false)){
74  curl_formadd(start,end,
75  CURLFORM_COPYNAME,"disable_notification",
76  CURLFORM_COPYCONTENTS,"true",
77  CURLFORM_END);
78  }
79  if(reply_to_message_id.value_or(false)){
80  curl_formadd(start,end,
81  CURLFORM_COPYNAME,"reply_to_message_id",
82  CURLFORM_COPYCONTENTS,"true",
83  CURLFORM_END);
84  }
85 
86 }
87 
89 // Setter Section //
91 
92 void sendPhoto::setCaption(const optional<string> &caption) {
93  sendPhoto::caption = caption;
94 }
95 
96 
99 }
100 
103 }
104 
111 }
112 
119 }
120 
127 }
128 
130 // Getter Section //
132 
133 const string &sendPhoto::getChat_id() const {
134  return chat_id;
135 }
136 
137 const string &sendPhoto::getPhoto() const {
138  return Photo;
139 }
140 
141 const optional<string> &sendPhoto::getCaption() const {
142  return caption;
143 }
144 
145 
146 const optional<bool> &sendPhoto::getDisable_notification() const {
147  return disable_notification;
148 }
149 
150 const optional<int32_t> &sendPhoto::getReply_to_message_id() const {
151  return reply_to_message_id;
152 }
153 
154 const optional<ReplyMarkup> &sendPhoto::getReply_markup() const {
155  return reply_markup;
156 }
const std::string & getChat_id() const
Definition: sendPhoto.cc:133
const std::string & getChat_id() const
Definition: sendMessage.cc:108
std::optional< bool > disable_notification
Definition: sendPhoto.h:75
const std::optional< std::int32_t > & getReply_to_message_id() const
Definition: sendMessage.cc:128
const std::string & getPhoto() const
Definition: sendPhoto.cc:137
void setReplyMarkup(const ReplyKeyboardMarkup RKM)
Definition: sendPhoto.cc:109
const std::optional< ReplyMarkup > & getReply_markup() const
Definition: sendPhoto.cc:154
std::optional< std::int32_t > reply_to_message_id
Definition: sendMessage.h:61
void setCaption(const std::optional< std::string > &caption)
Definition: sendPhoto.cc:92
Definition: Bot.h:27
void setReply_to_message_id(const std::optional< std::int32_t > &reply_to_message_id)
Definition: sendPhoto.cc:101
const std::optional< bool > & getDisable_notification() const
Definition: sendPhoto.cc:146
std::optional< std::string > caption
Definition: sendPhoto.h:73
std::optional< ReplyMarkup > reply_markup
Definition: sendPhoto.h:77
const std::optional< std::string > & getCaption() const
Definition: sendPhoto.cc:141
std::optional< ReplyMarkup > reply_markup
Definition: sendMessage.h:62
Json::Value toJson()
Definition: sendPhoto.cc:39
const std::optional< bool > & getDisable_notification() const
Definition: sendMessage.cc:124
const std::optional< std::int32_t > & getReply_to_message_id() const
Definition: sendPhoto.cc:150
void setDisable_notification(const std::optional< bool > &disable_notification)
Definition: sendPhoto.cc:97
void add_to_post(struct curl_httppost **start, struct curl_httppost **end)
Definition: sendPhoto.cc:58
std::optional< std::int32_t > reply_to_message_id
Definition: sendPhoto.h:76
std::optional< bool > disable_notification
Definition: sendMessage.h:60
std::string chat_id
Definition: sendMessage.h:56
sendPhoto(std::int64_t chat_id, std::string photo)