51 explicit ProductsLog(std::string product_name, std::string product_version,
57 ProductsLog(std::string product_name, std::string product_version,
58 std::string base_url, std::string username, std::string password,
77 bool SendStat(int64_t product_id,
const std::string &comment);
82 static std::string
UrlEncode(
const std::string &s);
83 static std::string
JsonEscape(
const std::string &s);
84 static std::optional<int64_t>
ParseProductId(
const std::string &body);
bool PostShutdown()
Отправить "Program shutdown".
bool enabled() const
Активен ли клиент (все credentials заданы).
std::string product_version_
bool PostStart()
Отправить "Program started".
std::string product_name_
ProductsLog(std::string product_name, std::string product_version, Transport transport=DefaultTransport())
bool PostMessage(const std::string &comment)
Отправить запись статистики. Возвращает false при любой ошибке.
static std::string JsonEscape(const std::string &s)
static std::string UrlEncode(const std::string &s)
ProductsLog(const ProductsLog &)=delete
bool SendStat(int64_t product_id, const std::string &comment)
std::optional< int64_t > FindProductId()
ProductsLog & operator=(const ProductsLog &)=delete
static std::optional< int64_t > ParseProductId(const std::string &body)
static Transport DefaultTransport()
std::optional< int64_t > RegisterProduct()
std::optional< int64_t > product_id_
std::function< HttpResponse(const HttpRequest &)> Transport
Транспорт HTTP — функция, выполняющая запрос. Заменяемая для тестов.
HTTP-запрос, описывающий обращение к Products API.
std::string method
"GET" или "POST".
int timeout_seconds
Таймаут запроса в секундах.
std::string username
Basic-auth пользователь (пусто = без авторизации).
std::string body
Тело запроса (для POST).
std::string url
Полный URL (путь уже URL-закодирован).
std::string password
Basic-auth пароль.
std::string error
Описание ошибки (без секретов).
std::string body
Тело ответа.
bool ok
true, если транспорт донёс запрос до сервера.
int status
HTTP-код статуса (0 при транспортной ошибке).