forked from TheCompez/Kavenegar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kavenegar.cpp
53 lines (44 loc) · 1.11 KB
/
kavenegar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "kavenegar.hpp"
#include "webservice/networkrequest.hpp"
namespace Kavenegar {
KavenegarApi::KavenegarApi(const Method &method, const std::string &senderLine, const std::string &apiKey)
: m_method(method), m_senderLine(senderLine), m_apiKey(apiKey)
{
//ToDo...
}
KavenegarApi::~KavenegarApi()
{
}
std::string KavenegarApi::apiKey() const
{
return m_apiKey;
}
void KavenegarApi::send(const std::string &receptor, const std::string &message)
{
WebService::NetworkRequest req;
{
std::string query = "senderLine="
+ m_senderLine
+ "&receptor="
+ receptor
+ "&message="
+ message;
std::string url { "https://api.kavenegar.com/v1/"
+ apiKey() + "/sms/send?receptor="
+ receptor + "&sender="
+ m_senderLine
+ "&message="
+ message
};
switch (m_method) {
case Method::GET:
req.get(url);
break;
case Method::POST:
req.post(url, query);
break;
default: req.get(url);
}
}
}
}