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 <variant>
15#include <vector>
16
17namespace TgBot {
18
19class Bot;
20class HttpClient;
21
31 friend class Bot;
32
33public:
34 Api(std::string token, const HttpClient& httpClient, std::string url);
35
37
41 std::string downloadFile(const std::string& filePath, const std::vector<HttpFormField>& fields = { }) const;
42
44
45protected:
46 nlohmann::json sendRequest(const std::string& method, const std::vector<HttpFormField>& fields) const;
47
48 const std::string _token;
49 const std::string _url;
50};
51
52} // namespace TgBot
const std::string _url
Definition Api.h:49
const HttpClient & _httpClient
Definition Api.h:43
Api(std::string token, const HttpClient &httpClient, std::string url)
std::string downloadFile(const std::string &filePath, const std::vector< HttpFormField > &fields={ }) const
Downloads a Telegram file and returns its contents.
nlohmann::json sendRequest(const std::string &method, const std::vector< HttpFormField > &fields) const
const std::string _token
Definition Api.h:48
friend class Bot
Definition Api.h:31
This object holds other objects specific for this bot instance.
Definition Bot.h:20
This class makes http requests.
Definition HttpClient.h:18
#define TGBOT_API
Definition export.h:5
Definition Api.h:17