Loading...
Searching...
No Matches
hueplusplus::HueCommandAPI Class Reference

`#include <hueplusplus/HueCommandAPI.h>`

## Public Member Functions

| HueCommandAPI (const std::string &ip, int port, const std::string &username, std::shared_ptr< const IHttpHandler > httpHandler)
| Construct from ip, username and HttpHandler.
| HueCommandAPI (const HueCommandAPI &)=default
| Copy construct from other HueCommandAPI.
| HueCommandAPI (HueCommandAPI &&)=default
| Move construct from other HueCommandAPI.
HueCommandAPI & | operator= (const HueCommandAPI &)=default
| Copy assign from other HueCommandAPI.
HueCommandAPI & | operator= (HueCommandAPI &&)=default
| Move assign 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.
nlohmann::json | PUTRequest (const std::string &path, const nlohmann::json &request) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
nlohmann::json | GETRequest (const std::string &path, const nlohmann::json &request) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
nlohmann::json | DELETERequest (const std::string &path, const nlohmann::json &request) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
nlohmann::json | POSTRequest (const std::string &path, const nlohmann::json &request) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::string | combinedPath (const std::string &path) const
| Combines path with api prefix and username.

## Detailed Description

Handles communication to the bridge via IHttpHandler and enforces a timeout between each request

## Constructor & Destructor Documentation

## HueCommandAPI() [1/3]

hueplusplus::HueCommandAPI::HueCommandAPI | ( | const std::string & | ip,
|  | int | port,
|  | const std::string & | username,
|  | std::shared_ptr< const IHttpHandler > | httpHandler
| ) |  |

Construct from ip, username and HttpHandler.

Parameters

  ip | ip address of the Hue bridge in dotted decimal notation like "192.168.2.1"
  port | of the hue bridge
  username | username that is used to control the bridge
  httpHandler | HttpHandler for communication with the bridge

## HueCommandAPI() [2/3]

hueplusplus::HueCommandAPI::HueCommandAPI | ( | const HueCommandAPI & |  | ) |

default

Copy construct from other HueCommandAPI.

Note
  All copies refer to the same timeout data, so even calls from different objects will be delayed

## HueCommandAPI() [3/3]

hueplusplus::HueCommandAPI::HueCommandAPI | ( | HueCommandAPI && |  | ) |

default

Move construct from other HueCommandAPI.

Note
  All copies refer to the same timeout data, so even calls from different objects will be delayed

## Member Function Documentation

## combinedPath()

std::string hueplusplus::HueCommandAPI::combinedPath | ( | const std::string & | path | ) | const

Combines path with api prefix and username.

Returns
  "/api/<username>/<path>"

## DELETERequest() [1/2]

nlohmann::json hueplusplus::HueCommandAPI::DELETERequest | ( | const std::string & | path,
|  | const nlohmann::json & | request
| ) |  | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## DELETERequest() [2/2]

nlohmann::json hueplusplus::HueCommandAPI::DELETERequest | ( | const std::string & | path,
|  | const nlohmann::json & | request,
|  | FileInfo | fileInfo
| ) |  | const

Sends a HTTP DELETE request to the bridge and returns the response.

This function will block until at least Config::getBridgeRequestDelay() has passed to any previous request

Parameters

  path | API request path (appended after /api/{username})
  request | Request to the api, may be empty
  fileInfo | File information for thrown exceptions.

Returns
  The return value of the underlying IHttpHandler::DELETEJson call

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contains no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## GETRequest() [1/2]

nlohmann::json hueplusplus::HueCommandAPI::GETRequest | ( | const std::string & | path,
|  | const nlohmann::json & | request
| ) |  | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## GETRequest() [2/2]

nlohmann::json hueplusplus::HueCommandAPI::GETRequest | ( | const std::string & | path,
|  | const nlohmann::json & | request,
|  | FileInfo | fileInfo
| ) |  | const

Sends a HTTP GET request to the bridge and returns the response.

This function will block until at least Config::getBridgeRequestDelay() has passed to any previous request

Parameters

  path | API request path (appended after /api/{username})
  request | Request to the api, may be empty
  fileInfo | File information for thrown exceptions.

Returns
  The return value of the underlying IHttpHandler::GETJson call

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contains no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## operator=() [1/2]

HueCommandAPI & hueplusplus::HueCommandAPI::operator= | ( | const HueCommandAPI & |  | ) |

default

Copy assign from other HueCommandAPI.

Note
  All copies refer to the same timeout data, so even calls from different objects will be delayed

## operator=() [2/2]

HueCommandAPI & hueplusplus::HueCommandAPI::operator= | ( | HueCommandAPI && |  | ) |

default

Move assign from other HueCommandAPI.

Note
  All copies refer to the same timeout data, so even calls from different objects will be delayed

## POSTRequest() [1/2]

nlohmann::json hueplusplus::HueCommandAPI::POSTRequest | ( | const std::string & | path,
|  | const nlohmann::json & | request
| ) |  | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## POSTRequest() [2/2]

nlohmann::json hueplusplus::HueCommandAPI::POSTRequest | ( | const std::string & | path,
|  | const nlohmann::json & | request,
|  | FileInfo | fileInfo
| ) |  | const

Sends a HTTP POST request to the bridge and returns the response.

This function will block until at least Config::getBridgeRequestDelay() has passed to any previous request

Parameters

  path | API request path (appended after /api/{username})
  request | Request to the api, may be empty
  fileInfo | File information for thrown exceptions.

Returns
  The return value of the underlying IHttpHandler::POSTJson call

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contains no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## PUTRequest() [1/2]

nlohmann::json hueplusplus::HueCommandAPI::PUTRequest | ( | const std::string & | path,
|  | const nlohmann::json & | request
| ) |  | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## PUTRequest() [2/2]

nlohmann::json hueplusplus::HueCommandAPI::PUTRequest | ( | const std::string & | path,
|  | const nlohmann::json & | request,
|  | FileInfo | fileInfo
| ) |  | const

Sends a HTTP PUT request to the bridge and returns the response.

This function will block until at least Config::getBridgeRequestDelay() has passed to any previous request

Parameters

  path | API request path (appended after /api/{username})
  request | Request to the api, may be empty
  fileInfo | File information for thrown exceptions.

Returns
  The return value of the underlying IHttpHandler::PUTJson call

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contains no body
  HueAPIResponseException | when response contains an error

The documentation for this class was generated from the following files:

- include/hueplusplus/HueCommandAPI.h
- src/HueCommandAPI.cpp