added const variables in class headers

This commit is contained in:
Lukas-Heiligenbrunner 2019-06-18 11:42:26 +02:00
parent 07ce161155
commit c5b5029cb1
6 changed files with 8 additions and 12 deletions

View File

@ -6,11 +6,6 @@
int DynuAPI::refreshIp(std:: string ip) { int DynuAPI::refreshIp(std:: string ip) {
static std::string dynuapikey = "88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg";
static std::string domainid = "8506047"; //id of the dynu domain
static std::string domainname = "luki.dynu.net";
Hashmap<std::string, std::string> args; Hashmap<std::string, std::string> args;
args.add("name", domainname); args.add("name", domainname);
args.add("ipv4Address", ip); args.add("ipv4Address", ip);
@ -22,7 +17,7 @@ int DynuAPI::refreshIp(std:: string ip) {
std::string dynurepl = request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers); std::string dynurepl = request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers);
std::cout << "[DEBUG] api reply:: " << dynurepl << std::endl; // std::cout << "[DEBUG] api reply:: " << dynurepl << std::endl;
if (dynurepl != "{\"statusCode\":200}") { if (dynurepl != "{\"statusCode\":200}") {
return -1; return -1;

View File

@ -12,8 +12,10 @@ class DynuAPI : API{
public: public:
int refreshIp(std::string ip); int refreshIp(std::string ip);
private: private:
const std::string dynuapikey = "88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg";
const std::string domainid = "8506047"; //id of the dynu domain
const std::string domainname = "luki.dynu.net";
}; };

View File

@ -12,7 +12,6 @@
class IPAPI : API{ class IPAPI : API{
public: public:
std::string getGlobalIp(); std::string getGlobalIp();
}; };

View File

@ -12,5 +12,5 @@ void TelegramAPI::sendMessage(std::string text) {
std::vector<std::string> headers; std::vector<std::string> headers;
std::string reply = request("https://api.telegram.org/bot" + apikey + "/sendmessage", false, args, headers); std::string reply = request("https://api.telegram.org/bot" + apikey + "/sendmessage", false, args, headers);
std::cout << "[DEBUG] " << reply << std::endl; // std::cout << "[DEBUG] " << reply << std::endl;
} }

View File

@ -14,8 +14,8 @@ public:
void sendMessage(std::string text); void sendMessage(std::string text);
private: private:
std::string apikey = "717213769:AAHan1nSXhUsxLJAN1Dv8Oc0z8wqwDdYPn4"; const std::string apikey = "717213769:AAHan1nSXhUsxLJAN1Dv8Oc0z8wqwDdYPn4";
std::string chatid = "618154204"; const std::string chatid = "618154204";
}; };

View File

@ -42,9 +42,9 @@ int main(int argc, char *argv[]) {
std::cout << "[INFO] ip changed! -- from :" << oldip << "to: " << ip << std::endl; std::cout << "[INFO] ip changed! -- from :" << oldip << "to: " << ip << std::endl;
DynuAPI dynu; DynuAPI dynu;
TelegramAPI tele;
if(dynu.refreshIp(ip)){ if(dynu.refreshIp(ip)){
TelegramAPI tele;
tele.sendMessage(oldip + " moved to " + ip); tele.sendMessage(oldip + " moved to " + ip);
} else{ } else{
//error //error