![]() |
Helper Class Reference 2.0
HomeGenie - Automation Programs API
|
API Helper class.
Class instance accessor: Api
More...
Public Member Functions | |
| ApiHelper | Handle (string apiCall, Func< object, object > handler) |
Defines a handler function that will be called when a web service call starting with apiCall is received. Use this to add user-defined web service API methods. | |
| MigInterfaceCommand | Parse (object apiCall) |
Parses the given (api call) string as a MigInterfaceCommand object. | |
| object | Call (string apiCommand, object data=null) |
| Invokes an API command and gets the result. | |
API Helper class.
Class instance accessor: Api
| ApiHelper Handle | ( | string | apiCall, |
| Func< object, object > | handler | ||
| ) |
Defines a handler function that will be called when a web service call starting with apiCall is received. Use this to add user-defined web service API methods.
| apiCall | API call. |
| handler | Handler. |
API methods should respect the following format:
For instance, a program that control Philips Hue lights will implement API methods like this:
So an API call to set a Philips Hue light with address 3 to 50% can be done via HTTP GET
or from a csharp program
When this call is received by the handler, the object args passed to it must be parsed using Program.ParseApiCall method, which will return an object containing the following fields
This object also provide a method request.GetOption(<index>) to get eventual options passed with this call.
Example
| MigInterfaceCommand Parse | ( | object | apiCall | ) |
Parses the given (api call) string as a MigInterfaceCommand object.
| apiCall | Api Command instance (MigInterfaceCommand) or string (eg. "HomeAutomation.X10/A5/Control.Level/50"). |
| object Call | ( | string | apiCommand, |
| object | data = null |
||
| ) |
Invokes an API command and gets the result.
| apiCommand | Any MIG/APP API command without the /api/ prefix. |
| data | Data object. (optional) |