Loading...
Searching...
No Matches
HueCommandAPI.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_HUECOMMANDAPI_H
#define INCLUDE_HUEPLUSPLUS_HUECOMMANDAPI_H
#include <atomic>
#include <chrono>
#include <mutex>
#include "HueException.h"
#include "IHttpHandler.h"
namespace hueplusplus
{
class HueCommandAPI
{
public:
HueCommandAPI(
const std::string& ip, int port, const std::string& username, std::shared_ptr<const IHttpHandler> httpHandler);
HueCommandAPI(const HueCommandAPI&) = default;
HueCommandAPI(HueCommandAPI&&) = default;
HueCommandAPI& operator=(const HueCommandAPI&) = default;
HueCommandAPI& operator=(HueCommandAPI&&) = default;
nlohmann::json PUTRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
nlohmann::json PUTRequest(const std::string& path, const nlohmann::json& request) const;
nlohmann::json GETRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
nlohmann::json GETRequest(const std::string& path, const nlohmann::json& request) const;
nlohmann::json DELETERequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
nlohmann::json DELETERequest(const std::string& path, const nlohmann::json& request) const;
nlohmann::json POSTRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
nlohmann::json POSTRequest(const std::string& path, const nlohmann::json& request) const;
std::string combinedPath(const std::string& path) const;
private:
struct TimeoutData
{
std::chrono::steady_clock::time_point timeout;
std::mutex mutex;
};
nlohmann::json HandleError(FileInfo fileInfo, const nlohmann::json& response) const;
private:
std::string ip;
int port;
std::string username;
std::shared_ptr<const IHttpHandler> httpHandler;
std::shared_ptr<TimeoutData> timeout;
};
} // namespace hueplusplus
#endif
username
const std::string username
Definition BridgeSetup.cpp:47
HueException.h
IHttpHandler.h
hueplusplus::HueCommandAPI
Definition HueCommandAPI.h:38
hueplusplus::HueCommandAPI::operator=
HueCommandAPI & operator=(const HueCommandAPI &)=default
Copy assign from other HueCommandAPI.
hueplusplus::HueCommandAPI::GETRequest
nlohmann::json GETRequest(const std::string &path, const nlohmann::json &request, FileInfo fileInfo) const
Sends a HTTP GET request to the bridge and returns the response.
Definition HueCommandAPI.cpp:93
hueplusplus::HueCommandAPI::POSTRequest
nlohmann::json POSTRequest(const std::string &path, const nlohmann::json &request, FileInfo fileInfo) const
Sends a HTTP POST request to the bridge and returns the response.
Definition HueCommandAPI.cpp:119
hueplusplus::HueCommandAPI::DELETERequest
nlohmann::json DELETERequest(const std::string &path, const nlohmann::json &request, FileInfo fileInfo) const
Sends a HTTP DELETE request to the bridge and returns the response.
Definition HueCommandAPI.cpp:106
hueplusplus::HueCommandAPI::operator=
HueCommandAPI & operator=(HueCommandAPI &&)=default
Move assign from other HueCommandAPI.
hueplusplus::HueCommandAPI::combinedPath
std::string combinedPath(const std::string &path) const
Combines path with api prefix and username.
Definition HueCommandAPI.cpp:146
hueplusplus::HueCommandAPI::HueCommandAPI
HueCommandAPI(const HueCommandAPI &)=default
Copy construct from other HueCommandAPI.
hueplusplus::HueCommandAPI::PUTRequest
nlohmann::json PUTRequest(const std::string &path, const nlohmann::json &request, FileInfo fileInfo) const
Sends a HTTP PUT request to the bridge and returns the response.
Definition HueCommandAPI.cpp:80
hueplusplus::HueCommandAPI::HueCommandAPI
HueCommandAPI(HueCommandAPI &&)=default
Move construct from other HueCommandAPI.
hueplusplus
Namespace for the hueplusplus library.
Definition Action.h:28
hueplusplus::FileInfo
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition HueException.h:35