hueplusplus 1.2.0
Loading...
Searching...
No Matches
HueCommandAPI.h
Go to the documentation of this file.
1
23#ifndef INCLUDE_HUEPLUSPLUS_HUECOMMANDAPI_H
24#define INCLUDE_HUEPLUSPLUS_HUECOMMANDAPI_H
25
26#include <atomic>
27#include <chrono>
28#include <mutex>
29
30#include "HueException.h"
31#include "IHttpHandler.h"
32
33namespace hueplusplus
34{
38{
39public:
47 const std::string& ip, int port, const std::string& username, std::shared_ptr<const IHttpHandler> httpHandler);
48
51 HueCommandAPI(const HueCommandAPI&) = default;
55
62
73 nlohmann::json PUTRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
75 nlohmann::json PUTRequest(const std::string& path, const nlohmann::json& request) const;
76
88 nlohmann::json GETRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
90 nlohmann::json GETRequest(const std::string& path, const nlohmann::json& request) const;
91
103 nlohmann::json DELETERequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
105 nlohmann::json DELETERequest(const std::string& path, const nlohmann::json& request) const;
106
118 nlohmann::json POSTRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const;
120 nlohmann::json POSTRequest(const std::string& path, const nlohmann::json& request) const;
121
124 std::string combinedPath(const std::string& path) const;
125private:
126 struct TimeoutData
127 {
128 std::chrono::steady_clock::time_point timeout;
129 std::mutex mutex;
130 };
131
135 nlohmann::json HandleError(FileInfo fileInfo, const nlohmann::json& response) const;
136
137private:
138 std::string ip;
139 int port;
140 std::string username;
141 std::shared_ptr<const IHttpHandler> httpHandler;
142 std::shared_ptr<TimeoutData> timeout;
143};
144} // namespace hueplusplus
145
146#endif
const std::string username
Definition BridgeSetup.cpp:47
Definition HueCommandAPI.h:38
HueCommandAPI & operator=(const HueCommandAPI &)=default
Copy assign from other HueCommandAPI.
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
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
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
HueCommandAPI & operator=(HueCommandAPI &&)=default
Move assign from other HueCommandAPI.
std::string combinedPath(const std::string &path) const
Combines path with api prefix and username.
Definition HueCommandAPI.cpp:146
HueCommandAPI(const HueCommandAPI &)=default
Copy construct from other HueCommandAPI.
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
HueCommandAPI(HueCommandAPI &&)=default
Move construct from other HueCommandAPI.
Namespace for the hueplusplus library.
Definition Action.h:28
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition HueException.h:35