tgbot-cpp
Loading...
Searching...
No Matches
Api.h
Go to the documentation of this file.
1#pragma once
2
4#include "tgbot/InputFile.h"
5#include "tgbot/Types.h"
6#include "tgbot/export.h"
7
8#include <nlohmann/json_fwd.hpp>
9
10#include <cstdint>
11#include <memory>
12#include <optional>
13#include <string>
14#include <string_view>
15#include <variant>
16#include <vector>
17
18namespace TgBot {
19
20class Bot;
21class HttpClient;
22
32 friend class Bot;
33
34public:
35 Api(std::string token, const HttpClient& httpClient, std::string url);
36
38
42 std::string downloadFile(std::string_view filePath, const std::vector<HttpFormField>& fields = { }) const;
43
45
46protected:
47 nlohmann::json sendRequest(std::string_view method, const std::vector<HttpFormField>& fields) const;
48
49 const std::string _token;
50 const std::string _url;
51};
52
53} // namespace TgBot
const std::string _url
Definition Api.h:50
const HttpClient & _httpClient
Definition Api.h:44
Api(std::string token, const HttpClient &httpClient, std::string url)
nlohmann::json sendRequest(std::string_view method, const std::vector< HttpFormField > &fields) const
const std::string _token
Definition Api.h:49
std::string downloadFile(std::string_view filePath, const std::vector< HttpFormField > &fields={ }) const
Downloads a Telegram file and returns its contents.
friend class Bot
Definition Api.h:32
This class makes http requests.
Definition HttpClient.h:31
#define TGBOT_API
Definition export.h:5
Definition Api.h:18