hueplusplus  1.0.0
IHttpHandler.h
Go to the documentation of this file.
1 
23 #ifndef INCLUDE_HUEPLUSPLUS_IHTTPHANDLER_H
24 #define INCLUDE_HUEPLUSPLUS_IHTTPHANDLER_H
25 
26 #include <chrono>
27 #include <iostream>
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include "json/json.hpp"
33 
34 namespace hueplusplus
35 {
38 {
39 public:
41  virtual ~IHttpHandler() = default;
42 
50  virtual std::string send(const std::string& msg, const std::string& adr, int port = 80) const = 0;
51 
60  virtual std::string sendGetHTTPBody(const std::string& msg, const std::string& adr, int port = 80) const = 0;
61 
73  virtual std::vector<std::string> sendMulticast(const std::string& msg, const std::string& adr = "239.255.255.250",
74  int port = 1900, std::chrono::steady_clock::duration timeout = std::chrono::seconds(5)) const = 0;
75 
87  virtual std::string sendHTTPRequest(const std::string& method, const std::string& uri,
88  const std::string& contentType, const std::string& body, const std::string& adr, int port = 80) const = 0;
89 
101  virtual std::string GETString(const std::string& uri, const std::string& contentType, const std::string& body,
102  const std::string& adr, int port = 80) const = 0;
103 
115  virtual std::string POSTString(const std::string& uri, const std::string& contentType, const std::string& body,
116  const std::string& adr, int port = 80) const = 0;
117 
129  virtual std::string PUTString(const std::string& uri, const std::string& contentType, const std::string& body,
130  const std::string& adr, int port = 80) const = 0;
131 
143  virtual std::string DELETEString(const std::string& uri, const std::string& contentType, const std::string& body,
144  const std::string& adr, int port = 80) const = 0;
145 
156  virtual nlohmann::json GETJson(
157  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
158 
169  virtual nlohmann::json POSTJson(
170  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
171 
182  virtual nlohmann::json PUTJson(
183  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
184 
195  virtual nlohmann::json DELETEJson(
196  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
197 };
198 } // namespace hueplusplus
199 
200 #endif
virtual std::string POSTString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP POST request to the specified host and return the body of the response.
virtual std::string DELETEString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP DELETE request to the specified host and return the body of the response.
virtual nlohmann::json PUTJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON...
virtual ~IHttpHandler()=default
Virtual dtor.
Namespace for the hueplusplus library.
Definition: Action.h:27
virtual std::vector< std::string > sendMulticast(const std::string &msg, const std::string &adr="239.255.255.250", int port=1900, std::chrono::steady_clock::duration timeout=std::chrono::seconds(5)) const =0
Send a multicast request with a specified message.
Abstract class for classes that handle http requests and multicast requests.
Definition: IHttpHandler.h:37
virtual std::string send(const std::string &msg, const std::string &adr, int port=80) const =0
Send a message to a specified host and return the response.
virtual nlohmann::json POSTJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP POST request to the specified host and return the body of the response parsed as JSON...
virtual nlohmann::json GETJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP GET request to the specified host and return the body of the response parsed as JSON...
virtual std::string sendGetHTTPBody(const std::string &msg, const std::string &adr, int port=80) const =0
Send a message to a specified host and return the body of the response.
virtual std::string GETString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP GET request to the specified host and return the body of the response.
virtual std::string PUTString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP PUT request to the specified host and return the body of the response.
virtual nlohmann::json DELETEJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON...
virtual std::string sendHTTPRequest(const std::string &method, const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP request with the given method to the specified host and return the body of the response...