-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathApiCodec.cpp
More file actions
30 lines (24 loc) · 883 Bytes
/
Copy pathApiCodec.cpp
File metadata and controls
30 lines (24 loc) · 883 Bytes
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
#include "tgbot/ApiCodec.h"
namespace TgBot::ApiRequest {
void appendField(std::vector<HttpFormField>& fields, const char* name, const std::string& value) {
fields.push_back({ name, value });
}
void appendField(std::vector<HttpFormField>& fields, const char* name, const std::shared_ptr<InputFile>& value) {
if (value) {
fields.push_back({
name,
HttpFile { value->data, value->mimeType, value->fileName },
});
}
}
void appendOptionalField(std::vector<HttpFormField>& fields, const char* name, const std::string& value) {
if (!value.empty()) {
appendField(fields, name, value);
}
}
void appendOptionalField(std::vector<HttpFormField>& fields, const char* name, const nlohmann::json& value) {
if (!value.is_null()) {
appendField(fields, name, value.dump());
}
}
} // namespace TgBot::ApiRequest