Example
let otherApp = this.homey.api.getApiApp('com.athom.otherApp');
otherApp
.on('realtime', (result) => console.log('otherApp.onRealtime', result))
.on('install', (result) => console.log('otherApp.onInstall', result))
.on('uninstall', (result) => console.log('otherApp.onUninstall', result));
otherApp.get('/')
.then((result) => console.log('otherApp.get', result))
.catch((error) => this.error('otherApp.get', error));
otherApp.getInstalled()
.then((result) => console.log('otherApp.getInstalled', result))
.catch((error) => this.error('otherApp.getInstalled', error));
otherApp.getVersion()
.then((result) => console.log('otherApp.getVersion', result))
.catch((error) => this.error('otherApp.getVersion', error));
Extends
Instance Methods
delete
(async) delete(uri): Promise.<any>Perform a DELETE request.
Parameters
Name | Type | Description |
---|---|---|
uri
|
string | The path to request, relative to the endpoint. |
Returns
get
(async) get(uri): Promise.<any>Perform a GET request.
Parameters
Name | Type | Description |
---|---|---|
uri
|
string | The path to request, relative to the endpoint. |
Returns
getInstalled
(async) getInstalled(): Promise.<boolean>This is a short-hand method to ManagerApps#getInstalled.
Returns
getVersion
(async) getVersion(): Promise.<string>This is a short-hand method to ManagerApps#getVersion.
Returns
post
(async) post(uri, body): Promise.<any>Perform a POST request.
Parameters
Name | Type | Description |
---|---|---|
uri
|
string | The path to request, relative to the endpoint. |
body
|
any | The body of the request. |
Returns
put
(async) put(uri, body): Promise.<any>Perform a PUT request.
Parameters
Name | Type | Description |
---|---|---|
uri
|
string | The path to request, relative to the endpoint. |
body
|
any | The body of the request. |
Returns
unregister
unregister()Unregister the API. This is a shorthand method for ManagerApi#unregisterApi.
Events
install
.on('install')This event is fired when the app is installed, enabled and running (accessible).
realtime
.on('realtime')This event is fired when a realtime event is received on this URI.
Parameters
Name | Type | Description |
---|---|---|
event
|
string | Name of the realtime event |
data
|
any
<optional> |
Data of the realtime event |
uninstall
.on('uninstall')This event is fired when the app is uninstalled, disabled or crashed (inaccessible).